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

Martin Davis mbdavis at refractions.net
Wed Sep 19 11:34:28 PDT 2007


Charlie, this is not a problem.  Floating point rounding error only 
comes into play when you are doing computations using numeric 
operations.  Extent computation only uses comparison operations, and 
these are exact.  So if a BBox is computed for a geometry and it has the 
max and min x and y being exactly the same, it can be determined to be a 
Point, with no worry about error.  (Conversely, if a geometry is not a 
point, it must have at least two coordinates with different Xs or Ys, 
and so its BBox will have a non-zero extent.

Charlie Savage wrote:
>> PostgreSQL will rewrite Centroid(Extent()) to 
>> Centroid(Box2Geom(Extent())
>
> Right.  I was thinking more about how you would change Box2Geom to 
> recognize the extent is actually a point (being wary of comparing 
> floating point numbers).
>
> Charlie
> ------------------------------------------------------------------------
>
> _______________________________________________
> postgis-users mailing list
> postgis-users at postgis.refractions.net
> http://postgis.refractions.net/mailman/listinfo/postgis-users
>   

-- 
Martin Davis
Senior Technical Architect
Refractions Research, Inc.
(250) 383-3022




More information about the postgis-users mailing list