Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

Im 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 ResulSet type object, when I convert it to String I get the following:

org.postgresql.jdbc4.Jdbc4ResultSet@163b102

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, thanks.

share|improve this question
add comment

3 Answers

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

share|improve this answer
add comment

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.

share|improve this answer
add comment

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

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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