Changes between Version 81 and Version 82 of WKTRaster/SpecificationWorking01
- Timestamp:
- 12/18/09 13:45:39 (15 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
WKTRaster/SpecificationWorking01
v81 v82 235 235 '''Implementation details''' 236 236 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. 238 238 239 239 '''ST_AsPolygon(raster) -> polygon geometry set''' - Returns a set of geometry, one for each group of pixel having the same value. … … 249 249 This function is at the base of the first version of ST_Intersection which compute the intersection between a raster and a geometry. 250 250 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: 252 252 253 253 CREATE TYPE geomval AS (geom geometry, val float8); 254 254 CREATE TYPE wktgeomval AS (wktgeom text, val float8); 255 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'; 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; 269 259 270 260 So it can then be used like this: 271 261 272 262 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 273 268 274 269 '''ST_AsWKTPolygon(raster) -> text set''' - Returns a set of text representation of geometry, one for each group of pixel having the same value.