[postgis-users] psycopg : web service

Åsmund Tokheim asmundto at gmail.com
Tue May 20 16:28:01 PDT 2014


Hi

As a simple start, you can select geometries nearby click-coordinates by
doing a sql-query like

SELECT ST_AsGeoJSON(geometry_column)
FROM geometry_table
WHERE ST_DWithin(geometry_column, ST_SetSRID(ST_Point(<lon>, <lat>),
<srid>), <srid_distance>)

The geometry data will then be in a geojson string which is supported by
openlayers (see
http://dev.openlayers.org/docs/files/OpenLayers/Format/GeoJSON-js.html).
You can read more about the functions used in the SQL-query here
http://postgis.net/docs/reference.html.

Feel free to ask if you have any more questions
Åsmund


On Tue, May 20, 2014 at 5:49 PM, dandrigo
<lcelati at latitude-geosystems.com>wrote:

> Dear all,
>
> I would like code a web service with python. I have already imported
> several vector data (land cover) and one Digital Elevation Model
> (raster layer) into my postgresql/postgis database (server side).
>
> I succeed in connecting to my pg db via psycopg2 (postgresql 's python api)
>
> Client side, operators use a client application (Developed with PHP /
> javascript / openlayers).
>
> Objectives :  Client side, once the layer would be selected,and once
> the operators have clicked on the map  , they would like that usefull
> informations appear on the interface of the client application(kind of
> land cover, z of the DEM).
>
>
> => Regarding my python script, i have to type a SQL query in order to
> select usefull informations of the db layers. And, of course, the
> information must  depend on geographic coordinates (Latitude
> Y/Longitute X).
> In a 2nd time, my script must  produce a result(JSon type) for the
> client side.
>
>
> It would be possible to help me regarding the coding in order to
> select usefull informations of the db layers. (depends on geographic
> coordinates x/y  ? Could you throw light for me regarding the way to
> do this SQL query ?
>
> In advance, thank you to throw light for me.
>
>
>
> --
> View this message in context:
> http://postgis.17.x6.nabble.com/psycopg-web-service-tp5006366.html
> Sent from the PostGIS - User mailing list archive at Nabble.com.
> _______________________________________________
> postgis-users mailing list
> postgis-users at lists.osgeo.org
> http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20140521/92952791/attachment.html>


More information about the postgis-users mailing list