I need to query the bounding box of a table (in WGS 84, srid 4326), and transform it to Web Mercator to be consumed by an OpenLayers map.
Currently, I am using this to retrieve the bounding box:
SELECT ST_Extent(geom) FROM mytable
Which returns the string
"BOX(2067507.49369776 650368.674310103,2095742.80207396 691604.021270793)". I have tried a variety of ways to transform this, but none have worked.
Transforming the geometry before getting the extent doesn't work:
SELECT ST_Extent(ST_Transform(geom, 3857)) FROM mytable
ERROR: transform: couldn't project point (2.0841e+06 678457 0): latitude or longitude exceeded limits (-14)
Does anyone know what would be causing this error?