[Mapserver-users] Accessing the spatial part of a shp file

Lowell Filak lfilak at medinaco.org
Mon Jan 13 09:04:14 EST 2003


If your using/use Mapscript you can access the least bounding rectangle of a shape via shapeObj->{bounds}.
If your dealing with standard shapefile data, for searching and selecting using the attributes you have different choices.
The critical thing is to make sure you have an attribute that identifies the record number starting at 0 as that value will relate to the shape index.
After you query and select a record by the attributes you can use the record number attribute to select that shape by it's index and then read the bounds of the shape.
You can either 'use' an XBase module in your code that will allow you to read the DBF files directly or you can load the DBF files into a different database and 'use' the module(s) that allow you to read from that database.
You should be able to find a Lot more discussion on this topic in the archives.
HTH
Lowell F.


The following message was sent by "Steve McCrone" <mccrone at pc.jaring.my> on Sun, 12 Jan 2003 22:25:29 +0800.

> Hi gain,
> 
> Would like to get some ideas on how to access the coordinates of a spatial
> shape.
> My goal is to have the user 'locate' (i.e. pan & zoom) to a spatial data.
> 
> In other words, the user would select from a list of roads, for example, and
> then push a 'find' button. The
> map would zom and pan to the road. Once I extract the coordinates that make
> up the road
> I could adjust the map extants to zoom & pan.
> 
> I was hoping that i could perform a record search on the shape file, find
> the record that contains the attribute (name for example),
> extract the coordinates of the polyline, point or polygon and then adjust
> the map.
> 
> Or do I have to create a separate table that contains a pre-defined centre
> coordinate of the spatial data and then use this
> to adjust the map extents.
> 
> Thanks
> Steve
> 
> 
> _______________________________________________
> 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