[GIS] Displaying geometry returned from ST_Buffer in PostGIS with OpenLayers

buffergeoserveropenlayers-2polygonpostgis

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:

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.

Best Answer

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