pggeodb.nancy.inra.fr/db_robot - db_robot on pggeodb.nancy.inra.fr
Previous topic Chapter index Next topic

Function: _st_dumppoints

 

 

Schema

public

 

Owner

albenard

 

Descriptions

There is no description for function _st_dumppoints

 

Options

Option

Value

Returns

Set of public.geometry_dump

Language

plpgsql

Parameters

the_geom public.geometry

cur_path integer []

 

Definition

CREATE OR REPLACE FUNCTION public._st_dumppoints (
 the_geom public.geometry,
 cur_path integer []
)
RETURNS SETOF public.geometry_dump AS
$span$
DECLARE

 tmp geometry_dump;
 tmp2 geometry_dump;
 nb_points integer;
 nb_geom integer;
 i integer;
 j integer;
 g geometry;

BEGIN

 -- RAISE DEBUG '%,%', cur_path, public.ST_GeometryType(the_geom);

 -- Special case collections : iterate and return the DumpPoints of the geometries


 IF (public.ST_IsCollection(the_geom)) THEN

   i = 1;
   FOR tmp2 IN SELECT (public.ST_Dump(the_geom)).* LOOP

     FOR tmp IN SELECT * FROM public._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 (public.ST_GeometryType(the_geom) = 'ST_Polygon') THEN

   FOR
tmp IN SELECT * FROM public._ST_DumpPoints(public.ST_ExteriorRing(the_geom), cur_path || ARRAY[1]) LOOP
     RETURN NEXT tmp;
   END LOOP;

   j := public.ST_NumInteriorRings(the_geom);
   FOR i IN 1..j LOOP
       FOR tmp IN SELECT * FROM public._ST_DumpPoints(public.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 (public.ST_GeometryType(the_geom) = 'ST_Triangle') THEN

   FOR
tmp IN SELECT * FROM public._ST_DumpPoints(public.ST_ExteriorRing(the_geom), cur_path || ARRAY[1]) LOOP
     RETURN NEXT tmp;
   END LOOP;

   RETURN;
 END IF;


 -- Special case (POINT) : return the point
 IF (public.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 public.ST_NumPoints(the_geom) INTO nb_points;

 -- This should never happen
 IF (nb_points IS NULL) THEN
   RAISE EXCEPTION
'Unexpected error while dumping geometry %', public.ST_AsText(the_geom);
 END IF;

 FOR i IN 1..nb_points LOOP
   tmp.path = cur_path || ARRAY[i];
   tmp.geom := public.ST_PointN(the_geom, i);
   RETURN NEXT tmp;
 END LOOP;

END
$span$
LANGUAGE
'plpgsql'
VOLATILE
CALLED ON NULL INPUT
SECURITY INVOKER
COST
100 ROWS 1000;

This file was generated with SQL Manager for PostgreSQL (www.pgsqlmanager.com) at 26/02/2014 11:51
Previous topic Chapter index Next topic