[mapserver-users] Finding the centroid given the feature

Adam Eskreis aeskreis at gmail.com
Thu May 28 10:34:44 PDT 2009


I'm not sure if this is what you are doing, but I have done something
similar I think.

When I want to use the centroid geometry of a polygon, what I do is load the
layer into postgis, create a new geometry field called "points_geom" or
something like that, and write a stand alone program to find the centroid of
each feature, adn insert that geometry into the new geometry field.  I
usually use Java since it has a really nice PostGIS object library

Hope this helps

-Adam

On Thu, May 28, 2009 at 11:01 AM, Varun saraf <vsaraf.gmu at gmail.com> wrote:

> Hi,
>
> I know mapserver uses a point-in-polygon method to find a feature
> given a set of co-ordinates, but can it do the same thing reversed?
> For example. Each polygon I draw has a number associated with it which
> is in a "dbf" file with the same name as the "shp" file that mapserver
> uses to draw the polygons. My current map file allows me to fetch that
> unique number whenever I pass the co-ordinates of any point inside
> that polygon (mapserver uses the point-in-polygon method to fetch me
> the polygonID). The query I use is
>
>
> http://127.0.0.1:8123/cgi-bin/mapserv.exe?&map=C:/ms4w/apps/workshop-5.0/testMap.map&mode=query&mapxy=-77.098617
> 38.87795
>
> where mapxy keeps changing based on the user's click. The html
> template I send just has the variable name [polygonID] which helps me
> get the polygon ID of the point I specify in the mapxy variable. Now,
> is there a way in which I can send this polygonID to mapserver and get
> hold of any point (perhaps the centroid) inside of this polygon? Can
> someone point me in the right direction here?
>
> Thanks a lot.
>
> -Varun
> _______________________________________________
> mapserver-users mailing list
> mapserver-users at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/mapserver-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/mapserver-users/attachments/20090528/df2b2e5b/attachment.htm>


More information about the MapServer-users mailing list