[postgis-users] How to get the centroid of an bounding box using st_extent
Paul Ramsey
pramsey at refractions.net
Wed Sep 19 09:46:33 PDT 2007
In particular, these ones are used by the casts.
-- Availability: 1.2.2
CREATEFUNCTION ST_geometry(box2d)
RETURNS geometry
AS '@MODULE_FILENAME@','BOX2DFLOAT4_to_LWGEOM'
LANGUAGE 'C' _IMMUTABLE_STRICT; -- WITH (isstrict,iscachable);
-- Availability: 1.2.2
CREATEFUNCTION ST_geometry(box3d)
RETURNS geometry
AS '@MODULE_FILENAME@','BOX3D_to_LWGEOM'
LANGUAGE 'C' _IMMUTABLE_STRICT; -- WITH (isstrict,iscachable);
Paul Ramsey wrote:
> 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