[mapserver-users] Accessing Vertices of a Shape - PHP MapScript

Daniel Morissette morissette at dmsolutions.ca
Mon Nov 18 17:54:15 EST 2002


"Hankley, Chip" wrote:
> 
\> It doesn't look like there's a way to access the vertices information
of a
> shape object in MapScript... anybody have any other ideas on how to do this?
> 

There is a way... it's just a bit tricky.  :)

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
-- 
------------------------------------------------------------
 Daniel Morissette               morissette at dmsolutions.ca
 DM Solutions Group              http://www.dmsolutions.ca/
------------------------------------------------------------



More information about the mapserver-users mailing list