I'm using PostGIS, GeoServer and OpenLayers, and the thing is that I want to display the geometry result from a query like this:

SELECT ST_Buffer(ST_GeomFromText('POINT(100 100)'), 500);

To perform queries I'm using Java, the line I use to perform a query is the following:

resulset = statement.executeQuery(query);

where resulset is a ResultSet type object, when I convert it to String I get the following:


My question is how do I interpret that to display the POLYGON I suppose is in there in a layer? or am I doing something wrong? Hope someone can help me with this question.


You can perform operations with WKT you return from consultations in postgis

SELECT ST_ASTEXT(ST_Buffer(ST_GeomFromText('POINT(100 100)'), 500));

you recieve WKT and use Openlayer to convert the wkt to geometry and feature. for example : var elemento = New OpenLayers.Format.WKT().read('textWktFromRecordColumn');

I hope it helps. greetings

| improve this answer | |

Have a look at the WPS addon for GeoServer - http://docs.geoserver.org/stable/en/user/extensions/wps/processes.html which provides a clean interface for this sort of query.

| improve this answer | |

if you use geodjango from server side, you can achieve this with performing raw SQL queries...

for example :

with models in model.py

Person.objects.raw('''SELECT ST_Buffer(ST_GeomFromText('POINT(100 100)'), 500);''');

or importing some module for connection and directly querying:

from django.db import connection, transaction
cursor = connection.cursor()

cursor.execute(SELECT ST_Buffer(ST_GeomFromText('POINT(100 100)'), 500))
row = cursor.fetchone() # .fetcall()

this is data retrievalling work for executing raw sql...

and last word about this geoquery

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.