[postgis-users] parsing postgis answers

Ralf Suhr Ralf.Suhr at itc-halle.de
Mon Dec 5 03:56:15 PST 2011

Hi Michal,

parse the output from St_Extent() with regexp_replace().

SELECT  regexp_replace( ST_Extent(geom_column)::text, E'BOX\\((.*) (.*),(.*) 
(.*)\\)', E'\\1,\\2,\\3,\\4') 
FROM table;


On Montag 05 Dezember 2011 12:26:54 Michał Drożdż wrote:
> Hi List!
> I am fresh Postgis user and have a problem with ST_EXTENT. I am using it to
> get data for map.zoomToExtent in openLayers. 
> The problem is that zoomToExtens takes parameters as
> zoomToExtent(value,value,value,value)
> http://dev.openlayers.org/docs/files/OpenLayers/Map-js.html#OpenLayers.Map
> .zoomToExtent 
> from ST_EXTENT a receive WKT like this:
> "BOX(2294970.88258299 6588308.80462897,2295532.89622321 6588616.7042758)"
> How to parse that answer to get paremeters for OpenLayers in appropirate
> format? I checked that OpenLayers is able to parse WKT but it is
> impossible with BOX type.
> http://dev.openlayers.org/docs/files/OpenLayers/Format/WKT-js.html 
> Thank for help!
> Michal
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20111205/a6673610/attachment.html>

More information about the postgis-users mailing list