polygon points from shapefile

John jkim at SCIENCES.SDSU.EDU
Wed Jun 29 01:34:31 EDT 2005


> is it possible, to get the points of a polygon from a shapefile in an
> array via phpmapscript?
> So that I get e.g. ((49.12390,5.283990),(49,238238,5,23423442),....)
> Joerg

According to a message posted 18 Nov 2002 by Daniel Morissette, you can:

-----------
A shapeObj is composed of a number of lineObj which in turn are composed
of a number of pointObj which contain the vertices.  For instance to
dump all vertices in a shape you would have to do something like this:

  for($i=0; $i < $shape->numlines; $i++)
  {
     $line = $shape->line($i);

     for($j=0; $j<$line->numpoints; $j++)
     {
        $point = $line->point($j);

        // Do something with the vertices:
        // $point->x, $point->y
     }
  }

Daniel
----------

The full message/thread is here:
http://mapserver.gis.umn.edu/data2/wilma/mapserver-users/0211/msg00317.html

I haven't tried the code, although I've thought about it. I'd love to hear
how it works out for you.

-John



More information about the mapserver-users mailing list