[Mapserver-users] How do i display only the points i want? (PHP/Mapscript)

Eric Bridger eric at gomoos.org
Mon Jan 5 06:52:30 PST 2004


Ed,
Sorry I don't have a php example but I do have a perl example which
illustrates the basic idea, which is to read the shapefile in a loop and
draw the points yourself in php mapscript.

my $input_town_id = 345;
my $layer = $map->getLayerByName('all_towns');
$layer->{status} = $mapscript::MS_ON;

my $shpfile = new mapscript::shapefileObj($layer->{data}, -1);
if($shpfile){
    my $dbfile = $layer->{data} . '.dbf';
    my $hDBF = new XBase "$dbfile" or warn XBase->errstr;
    my $shape = new mapscript::shapeObj($mapscript::MS_POINT);
    my $numshapes = $shpfile->{numshapes};
    for my $i (0 .. $numshapes - 1){
        my $ret = $shpfile->get($i, $shape);
        if($ret != -1){
            my $town_id = ($hDBF->get_record_nf($i, 0))[1] or warn
$hDBF->errstr . "\n";
            if($town_id eq $input_town_id){
           	 my $class = $layer->getClass(0);
           	 # you could set class attributes here.
           	 $shape->draw($map, $layer, $img, undef);
            }
        }
    } # end for numshapes
    $hDBF->close();
}

On Sun, 2004-01-04 at 15:06, Ed Martin wrote:
> i'm using php mapscript and can't figure out how i get it to only 
> display the points i want, i have a shapefile that has all the towns in 
> the US (they are all points) and i have the index of every point i want 
> to display, i can't figure out how to do this
> 
> so basically what do i do to first make it so that by default the 
> points don't show up on the map, but when i give the index of one of 
> the points it shows up
> 
> i looked at the php mapscript class reference stuff and can't find 
> anything that looks like it will do this
> 
> _______________________________________________
> Mapserver-users mailing list
> Mapserver-users at lists.gis.umn.edu
> http://lists.gis.umn.edu/mailman/listinfo/mapserver-users
> 





More information about the MapServer-users mailing list