Skip to content

Instantly share code, notes, and snippets.

@ns-1m
ns-1m / postgis_geojson.php
Created April 3, 2012 22:54 — forked from bmcbride/postgis_geojson.php
PHP PostGIS to GeoJSON
<?php
/**
* PostGIS to GeoJSON
* Query a PostGIS table or view and return the results in GeoJSON format, suitable for use in OpenLayers, Leaflet, etc.
*
* @param string $geotable The PostGIS layer name *REQUIRED*
* @param string $geomfield The PostGIS geometry field *REQUIRED*
* @param string $srid The SRID of the returned GeoJSON *OPTIONAL (If omitted, EPSG: 4326 will be used)*
* @param string $fields Fields to be returned *OPTIONAL (If omitted, all fields will be returned)* NOTE- Uppercase field names should be wrapped in double quotes
* @param string $parameters SQL WHERE clause parameters *OPTIONAL*
@ns-1m
ns-1m / sqlite_geojson.php
Created April 3, 2012 02:56 — forked from bmcbride/sqlite_geojson.php
PHP SQLite to GeoJSON
<?php
/**
* SQLite to GeoJSON (Requires https://github.com/phayes/geoPHP)
* Query a SQLite table or view (with a WKB GEOMETRY field) and return the results in GeoJSON format, suitable for use in OpenLayers, Leaflet, etc.
*
* @param string $geotable The SQLite table name *REQUIRED*
* @param string $geomfield The WKB GEOMETRY field *REQUIRED*
* @param string $fields Fields to be returned *OPTIONAL (If omitted, all fields will be returned)*
* @param string $parameters SQL WHERE clause parameters *OPTIONAL*
* @param string $orderby SQL ORDER BY constraint *OPTIONAL*