Changes between Version 81 and Version 82 of WKTRaster/SpecificationWorking01


Ignore:
Timestamp:
Dec 18, 2009, 1:45:39 PM (14 years ago)
Author:
pracine
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • WKTRaster/SpecificationWorking01

    v81 v82  
    235235 '''Implementation details'''
    236236
    237  This function could be roughly implemented as a SQL or PL/pgSQL function looking like 'SELECT ST_Collect(ST_AsPolygon(raster))'. For sure a more specialised version could be faster than ST_AsPolygon.
     237 This function could be roughly implemented as a SQL function looking like 'SELECT ST_Collect((ST_AsPolygon(raster)).geom)'. For sure a more specialised version could be faster than ST_AsPolygon.
    238238
    239239'''ST_AsPolygon(raster) -> polygon geometry set''' - Returns a set of geometry, one for each group of pixel having the same value.
     
    249249 This function is at the base of the first version of ST_Intersection which compute the intersection between a raster and a geometry.
    250250
    251  To avoid linking directly with PostGIS (see "Why avoid to link with PostGIS?" below) It should be implemented as a PL/pgSQL wrapper around ST_AsWKTPolygon() looking something like this:
     251 To avoid linking directly with PostGIS (see "Why avoid to link with PostGIS?" below) It should be implemented as a SQL wrapper around ST_AsWKTPolygon() looking something like this:
    252252
    253253 CREATE TYPE geomval AS (geom geometry, val float8);
    254254 CREATE TYPE wktgeomval AS (wktgeom text, val float8);
    255255
    256  CREATE OR REPLACE FUNCTION ST_AsPolygon(rast) RETURNS SETOF geomval AS
    257  $BODY$
    258  DECLARE
    259      pl geomval%rowtype;
    260  BEGIN
    261      FOR pl IN SELECT ST_GeomFromText(wktgeomval.wktgeom), wktgeomval.val FROM ST_Dump(ST_GeomFromText(txtgeom)) AS wktgeomval
    262      LOOP
    263         RETURN NEXT pl;
    264      END LOOP;
    265      RETURN;
    266  END
    267  $BODY$
    268  LANGUAGE 'plpgsql';
     256 CREATE OR REPLACE FUNCTION ST_AsPolygon(rast raster) RETURNS SETOF geomval AS $$
     257     SELECT ST_GeomFromText(wktgeomval.wktgeom), wktgeomval.val FROM ST_AsWKTPolygon(%1) AS wktgeomval;
     258 $$ LANGUAGE SQL;
    269259
    270260 So it can then be used like this:
    271261
    272262 SELECT (ST_AsPolygon(rast)).val, (ST_AsPolygon(rast)).geom FROM sometable
     263
     264 or like this (maybe faster, to verify):
     265
     266 SELECT (gv).val, (gv).geom FROM (SELECT ST_AsPolygon(rast) gv FROM sometable) foo
     267
    273268
    274269'''ST_AsWKTPolygon(raster) -> text set''' - Returns a set of text representation of geometry, one for each group of pixel having the same value.