polygon points from shapefile
joerg p
superbla3000 at GMX.NET
Wed Jun 29 04:47:46 PDT 2005
> 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
>
Thanks, it works. My full version for beginners:
$testshape = ms_newShapefileObj("data/country", -1);
print_r($testshape);
echo "<br><hr>";
for($i=0; $i < $testshape->numshapes; $i++){
echo $i.": ";
print_r($singleshape = $testshape->getShape($i));
echo "<br>";
for($j=0; $j < $singleshape->numlines; $j++){
$singleline = $singleshape->line($j);
for($k=0; $k < $singleline->numpoints; $k++){
$singlepoint = $singleline->point($k);
print_r($singlepoint);
}
}
echo "<hr><br><br>";
}
cheers
Joerg
More information about the MapServer-users
mailing list