[postgis-users] How to get the centroid of an bounding box using st_extent

Paul Ramsey pramsey at refractions.net
Wed Sep 19 08:56:53 PDT 2007


Charlie Savage wrote:

> As an aside, its not obvious to me how to actually fix this bug. Somehow 
> the conversion from Box2D/Box3D to geometry needs to figure out if the 
> bbox has 0 width and/or 0 height and if so create a Point instead of a 
> Polygon.  

The problem will live in the function that casts from Box* to GEOMETRY. 
  PostgreSQL does automatic casting, so

Extent(GEOMETRY) return BOX*
Centroid(GEOMETRY) returns GEOMETRY

PostgreSQL will rewrite Centroid(Extent()) to Centroid(Box2Geom(Extent())

P.


-- 

   Paul Ramsey
   Refractions Research
   http://www.refractions.net
   pramsey at refractions.net
   Phone: 250-383-3022
   Cell: 250-885-0632



More information about the postgis-users mailing list