AW: [postgis-users] Re:PHP access to PostGIS

Düster Horst Horst.Duester at bd.so.ch
Fri Mar 11 06:31:07 PST 2005


Martin

Your geometry class sounds very interesting. Could you made some further
explanations particulary the snap functions.
I couldn't understand what you do mean with the snapLayerStr.


With best regards

Horst



---------------------------------
 
Dr. Horst Düster 
GIS-Koordinator /Amtschef Stv.

Kanton Solothurn 
Amt für Geoinformation
Abteilung SO!GIS Koordination
Werkhofstr. 65
CH-4509 Solothurn 

Tel.: ++41 (0)32 627 25 32 
Fax: ++41 (0)32 627 22 14

horst.duester at bd.so.ch 
www.sogis.so.ch



-----Ursprüngliche Nachricht-----
Von: Martin Høgh [mailto:mh at svaj.dk]
Gesendet am: Freitag, 11. März 2005 13:31
An: postgis-users at postgis.refractions.net
Betreff: [postgis-users] Re:PHP access to PostGIS

Hi,
I've written a php geometry lib which can do this. It's a part of the 
MapLink projekt at http://sourceforge.net/projects/maplink/

the lib is called "libs/phpgeometry_class.php" get the latest from cvs. 
The one in distro is buggy

some examples of uses
<?
$wkt="MULTILINESTRING((1 1,2 2,3 3),(20 20,30 30,40 40))"

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 array you want!

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
?>

new object in the next release of the lib

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

/martin



Hi all,

I new to working with PostGIS. I'm using PHP and I need to get my 
ployline into a PHP array. What is the best way to do this?

What I'm doing so far is:

     // get the segment and offset the point right/left
     // retrieve the segment geometry

     $sql = "select AsText(geom) as geom from geocode" .
            " where id = $this->oRefId";

     // execute SQL query
     $result = @pg_query($this->conn, $sql);
     if (!$result) {
       return false;
     }

     // get the number of rows in the resultset - must be one
     $rows = pg_num_rows($result);
     if ($rows < 1) {
       return false;
     }

     // read the points
    $row = pg_fetch_array($result, 0, PGSQL_ASSOC);
print_r($row);
echo "<br>\n";

Which gives me:
Array ( [geom] => LINESTRING(-73.338249206543 
41.1630020141602,-73.3395233154297 41.1648445129395) )

So I'm wondering if I need to parse the text, or if there is an easier 
way this into a PHP structure, like:

$line = [ [-73.338249206543,  41.1630020141602],
           [-73.3395233154297, 41.1648445129395] ];

or some other array structure.

-Steve W.


-- 
Martin Høgh
Sven Allan Jensen as
Sankelmarksgade 9
9000 Aalborg
Tlf. 98129300
Direkte tlf. 96314082


_______________________________________________
postgis-users mailing list
postgis-users at postgis.refractions.net
http://postgis.refractions.net/mailman/listinfo/postgis-users



More information about the postgis-users mailing list