[Mapserver-users] unclear on the concept

Eric Bridger eric at gomoos.org
Thu Jul 22 09:23:07 EDT 2004


On Wed, 2004-07-21 at 23:43, Joel Gwynn wrote:
> Perhaps I'm going about this the wrong way.  I'm using perl mapscript, 
> and I've got a postgis points layer and I want to get some points, say 
> within a certain radius of Boston:
> 
> my $map = new mapscript::mapObj("$map_path/world_cities.map");
> my $boston = new mapscript::pointObj(-71.1029968261719, 42.375);
> my $city_layer = $map->getLayer(1);
> 
> if(my $r = $city_layer->queryByPoint($map, $boston, 
> $mapscript::MS_MULTIPLE,10)){
>     print "no results.\n";
> }else{
>     my $i = 0;
>     print "status: $r\n";
>     while(my $rc = $city_layer->getResult($i)){
>     my $si = $rc->{shapeindex};
>     print "shapeindex: $si\n";
>     $i++;
>     }
> }
> 
> This prints out a bunch of shapeindex numbers.  What are those numbers? 
> They don't seem to show up in my cities table in the database.  Can I 
> use the mapscript object to access the points?

Those numbers are unique numeric keys. For a shapefile they are the
index into the dbf file which accompanies every shape file and holds the
shape's attribute information.  In that case you would open the dbf
file, e.g. using Xbase.pm, and get the $i record.

[Note: I have not done this for PostGIS layers so take this with a grain
of salt]
For PostGIS layers I think it is a bit more complicated and would depend
on what your PostGIS DATA statement looks like. I think the
PostGIS/Mapserver code will use Postgres's oid as a default unique key,
but you can specify the column to use by appending a "using unique
<column_name>" to your DATA statement.  In any case you should be able
to open a connection to Postgres and do something like: "select * from
cities where oid = $i".

HTH.
Eric





More information about the mapserver-users mailing list