Changes between Version 80 and Version 81 of WKTRaster/SpecificationWorking01

Show
Ignore:
Timestamp:
12/18/09 13:21:16 (3 years ago)
Author:
pracine
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • WKTRaster/SpecificationWorking01

    v80 v81  
    251251 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: 
    252252 
    253  CREATE TYPE raster_geom AS (value integer[], geom geometry); 
    254   
    255  
    256  FOR poly IN SELECT ST_GeomFromText(r.geom),  FROM ST_AsWKTPolygon(rast) AS r LOOP 
    257   RETURN NEXT poly; 
    258  END LOOP; 
     253 CREATE TYPE geomval AS (geom geometry, val float8); 
     254 CREATE TYPE wktgeomval AS (wktgeom text, val float8); 
     255 
     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'; 
     269 
     270 So it can then be used like this: 
     271 
     272 SELECT (ST_AsPolygon(rast)).val, (ST_AsPolygon(rast)).geom FROM sometable 
    259273 
    260274'''ST_AsWKTPolygon(raster) -> text set''' - Returns a set of text representation of geometry, one for each group of pixel having the same value.