[postgis-tickets] [PostGIS] #2869: St_Centroid doesn't work on curved geom
PostGIS
trac at osgeo.org
Fri Aug 1 07:49:03 PDT 2014
#2869: St_Centroid doesn't work on curved geom
-------------------------+--------------------------------------------------
Reporter: remic | Owner: pramsey
Type: enhancement | Status: new
Priority: medium | Milestone:
Component: postgis | Version: 2.1.x
Keywords: |
-------------------------+--------------------------------------------------
Comment(by remic):
Here is a wrapper ,
totally non optimal
DROP FUNCTION IF EXISTS public.rc_centroid( igeom GEOMETRY);
CREATE OR REPLACE FUNCTION public.rc_centroid(
igeom GEOMETRY
) RETURNS GEOMETRY AS
$BODY$
-- at brief : this function is a thin wrapper around st_centroid than
enable to use it with circularstring
-- at param : a geom whose centroid we want
-- at return : teh centroid
DECLARE
BEGIN
--RAISE EXCEPTION 'hello, % , %',
st_astext(igeom), st_geometrytype(igeom) ;
IF ST_GeometryType(igeom) ILIKE '%CircularString%'
THEN
--special case, we cast the circularstring
to multipoint
RETURN ST_Centroid(ST_Collect(dmp.geom))
FROM ST_DumpPoints(igeom) as dmp
WHERE dmp.path =ARRAY[1] OR dmp.path
=ARRAY[3];
END IF ; --cicular string
RETURN ST_Centroid(igeom) ;
END ;
--test
--SELECT ST_AsText(rc_centroid(geom ))
--FROM st_geomfromtext('circularstring(0 0 , 1 1, 2 0)') as geom ;
$BODY$
LANGUAGE plpgsql IMMUTABLE STRICT;
--
Ticket URL: <http://trac.osgeo.org/postgis/ticket/2869#comment:2>
PostGIS <http://trac.osgeo.org/postgis/>
The PostGIS Trac is used for bug, enhancement & task tracking, a user and developer wiki, and a view into the subversion code repository of PostGIS project.
More information about the postgis-tickets
mailing list