[OpenLayers-Users] PostGIS layer

Micha Silver micha at arava.co.il
Thu Mar 25 12:28:19 EDT 2010


On 03/25/2010 04:03 PM, Mapmaker wrote:
> You can query PostGIS and use a PHP script to return the results as KML, GML,
> GeoJson- and add that layer directly in OpenLayers.
>    
Thanks.
Just to complete the thread, I'm doing the following in php to 
dynamically create each GML layer from PostGIS views as needed:

     $ogrcmd =   "/usr/local/bin/ogr2ogr ";
     $ogrcmd.=   " -f \"GML\" -a_srs \"EPSG:2039\" -overwrite ";
     $ogrcmd.=   $gml_path." PG:\"user=xxxxxxx dbname=xxxxxxx\" ";
     $ogrcmd.=   " ".$event_code;
     system($ogrcmd, $resp);

( $gml_path and $event_code are php vars created within the function)
Then in I create the openlayers vector like:
      echo "var cur_data = new OpenLayers.Layer.GML(\"Current Rain 
Data\",\"".$url_path."\",";
....

-- 
Micha Silver
http://www.surfaces.co.il/
Arava Development Co.  +972-52-3665918

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-users/attachments/20100325/e95949c1/attachment.html


More information about the Users mailing list