the_geom -> PHP?

Web Form 2 mh at SVAJ.DK
Mon Oct 24 13:05:16 EDT 2005


I've written a php geometry lib which may can help. It's a part of the
appformap projekt at http://sourceforge.net/projects/appformap/

the lib is called "libs/phpgeometry_class.php" get the latest from cvs.

some examples of uses
<?
$wkt="MULTILINESTRING((1 1,2 2,3 3),(20 20,30 30,40 40))"; //the wkt u fetch
from postgis

include("phpgeometry_class.php"); // include the lib
$f=new geometryfactory; // new object which can create geometry objects
$g=$f->createGeometry($wkt);// $g is a new geometry object

$ver=  $g->getVertices(); // get all vertices in one string. EXPLODE
THIS STRING e.g. explode(",",$ver) and you've the a array of vertices

some other methods of $g

$array=$g->getShapeArray();// array of shapes

$gml = $g->getGML(); // get the feature in gml format

$num= $g->getNumOfShapes();// numbers of shapes. In this case 2

$type= $g->getGeomType();// get the type of geometry. Here MULTILINESTRING

$g->updateShape("4 4,5 5,6 6",0);// updates the wkt on shape level. Each
shape of feature has a id starting from 0

$g->snapShape($shapeId,$snapTolerance,$snapLayerStr);// snaps shape with
$shapeId to $snapLayerStr using tolerance of $snapTolerance

$wkt=  $g->getWKT();// get the wkt string back. Altered in this case

//from gml to wkt

$con= new gmlConverter;
$con->gmlToWKT($gml); // where $gml is a gml stream. Return an array
with WKT strings for each feature member
print_r($con);
?>

/martin



More information about the mapserver-users mailing list