maya
.public
Tables
(current)
Columns
Constraints
Relationships
Orphan Tables
Anomalies
Routines
_st_dumppoints(geometry, integer[])
Parameters
Name
Type
Mode
the_geom
USER-DEFINED
IN
cur_path
ARRAY
IN
Definition
DECLARE tmp geometry_dump; tmp2 geometry_dump; nb_points integer; nb_geom integer; i integer; j integer; g geometry; BEGIN -- RAISE DEBUG '%,%', cur_path, ST_GeometryType(the_geom); -- Special case collections : iterate and return the DumpPoints of the geometries IF (ST_IsCollection(the_geom)) THEN i = 1; FOR tmp2 IN SELECT (ST_Dump(the_geom)).* LOOP FOR tmp IN SELECT * FROM _ST_DumpPoints(tmp2.geom, cur_path || tmp2.path) LOOP RETURN NEXT tmp; END LOOP; i = i + 1; END LOOP; RETURN; END IF; -- Special case (POLYGON) : return the points of the rings of a polygon IF (ST_GeometryType(the_geom) = 'ST_Polygon') THEN FOR tmp IN SELECT * FROM _ST_DumpPoints(ST_ExteriorRing(the_geom), cur_path || ARRAY[1]) LOOP RETURN NEXT tmp; END LOOP; j := ST_NumInteriorRings(the_geom); FOR i IN 1..j LOOP FOR tmp IN SELECT * FROM _ST_DumpPoints(ST_InteriorRingN(the_geom, i), cur_path || ARRAY[i+1]) LOOP RETURN NEXT tmp; END LOOP; END LOOP; RETURN; END IF; -- Special case (TRIANGLE) : return the points of the external rings of a TRIANGLE IF (ST_GeometryType(the_geom) = 'ST_Triangle') THEN FOR tmp IN SELECT * FROM _ST_DumpPoints(ST_ExteriorRing(the_geom), cur_path || ARRAY[1]) LOOP RETURN NEXT tmp; END LOOP; RETURN; END IF; -- Special case (POINT) : return the point IF (ST_GeometryType(the_geom) = 'ST_Point') THEN tmp.path = cur_path || ARRAY[1]; tmp.geom = the_geom; RETURN NEXT tmp; RETURN; END IF; -- Use ST_NumPoints rather than ST_NPoints to have a NULL value if the_geom isn't -- a LINESTRING, CIRCULARSTRING. SELECT ST_NumPoints(the_geom) INTO nb_points; -- This should never happen IF (nb_points IS NULL) THEN RAISE EXCEPTION 'Unexpected error while dumping geometry %', ST_AsText(the_geom); END IF; FOR i IN 1..nb_points LOOP tmp.path = cur_path || ARRAY[i]; tmp.geom := ST_PointN(the_geom, i); RETURN NEXT tmp; END LOOP; END