From: Bborie Park Date: Tue, 16 Apr 2013 18:23:36 +0000 (+0000) Subject: Added numerical parameters version of ST_SetGeoReference(raster). X-Git-Tag: 2.1.0beta2~95 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=1059e4808b893f98ab123600f7554060c047ebae;p=postgis Added numerical parameters version of ST_SetGeoReference(raster). Ticket #613 git-svn-id: http://svn.osgeo.org/postgis/trunk@11304 b70326c6-7e19-0410-871a-916f4a2858ee --- diff --git a/NEWS b/NEWS index ea97b2e8b..0a0e3ccd5 100644 --- a/NEWS +++ b/NEWS @@ -78,6 +78,7 @@ PostGIS 2.1.0 - #1687, ST_Simplify for TopoGeometry (Sandro Santilli / Vizzuality) - #2228, TopoJSON output for TopoGeometry (Sandro Santilli / Vizzuality) - #2123, ST_FromGDALRaster + - #613, ST_SetGeoReference with numerical parameters instead of text * Enhancements * diff --git a/doc/reference_raster.xml b/doc/reference_raster.xml index 33d9536fb..b837bd1e6 100644 --- a/doc/reference_raster.xml +++ b/doc/reference_raster.xml @@ -5194,12 +5194,25 @@ FROM ( + - raster ST_SetGeoReference - raster rast - text georefcoords - text format=GDAL + raster ST_SetGeoReference + raster rast + text georefcoords + text format=GDAL + + + + raster ST_SetGeoReference + raster rast + double precision upperleftx + double precision upperlefty + double precision scalex + double precision scaley + double precision skewx + double precision skewy + @@ -5213,24 +5226,45 @@ FROM ( ESRI: scalex skewy skewx scaley upperleftx + scalex*0.5 upperlefty + scaley*0.5 - If the raster has out-db bands, changing the georeference may result in incorrect access of the band's externally stored data. + Enhanced: 2.1.0 Addition of ST_SetGeoReference(raster, double precision, ...) variant + Examples - UPDATE dummy_rast SET rast = ST_SetGeoReference(rast, '2 0 0 3 0.5 0.5','GDAL') - WHERE rid=1; - --- same coordinates set in 'ESRI' format -UPDATE dummy_rast SET rast = ST_SetGeoReference(rast, '2 0 0 3 1.5 2','ESRI') - WHERE rid=1; + +WITH foo AS ( + SELECT ST_MakeEmptyRaster(5, 5, 0, 0, 1, -1, 0, 0, 0) AS rast +) +SELECT + 0 AS rid, (ST_Metadata(rast)).* +FROM foo +UNION ALL +SELECT + 1, (ST_Metadata(ST_SetGeoReference(rast, '10 0 0 -10 0.1 0.1', 'GDAL'))).* +FROM foo +UNION ALL +SELECT + 2, (ST_Metadata(ST_SetGeoReference(rast, '10 0 0 -10 5.1 -4.9', 'ESRI'))).* +FROM foo +UNION ALL +SELECT + 3, (ST_Metadata(ST_SetGeoReference(rast, 1, 1, 10, -10, 0.001, 0.001))).* +FROM foo + + rid | upperleftx | upperlefty | width | height | scalex | scaley | skewx | skewy | srid | numbands +-----+--------------------+--------------------+-------+--------+--------+--------+-------+-------+------+---------- + 0 | 0 | 0 | 5 | 5 | 1 | -1 | 0 | 0 | 0 | 0 + 1 | 0.1 | 0.1 | 5 | 5 | 10 | -10 | 0 | 0 | 0 | 0 + 2 | 0.0999999999999996 | 0.0999999999999996 | 5 | 5 | 10 | -10 | 0 | 0 | 0 | 0 + 3 | 1 | 1 | 5 | 5 | 10 | -10 | 0.001 | 0.001 | 0 | 0 diff --git a/raster/rt_pg/rtpostgis.sql.in b/raster/rt_pg/rtpostgis.sql.in index 4e6ed4024..fd6e8bd84 100644 --- a/raster/rt_pg/rtpostgis.sql.in +++ b/raster/rt_pg/rtpostgis.sql.in @@ -9,7 +9,7 @@ -- Copyright (c) 2009-2010 Jorge Arevalo -- Copyright (c) 2009-2010 Mateusz Loskot -- Copyright (c) 2010 David Zwarg --- Copyright (C) 2011-2012 Regents of the University of California +-- Copyright (C) 2011-2013 Regents of the University of California -- -- -- This is free software; you can redistribute and/or modify it under @@ -4213,6 +4213,16 @@ CREATE OR REPLACE FUNCTION st_setgeoreference(rast raster, georef text, format t $$ LANGUAGE 'plpgsql' IMMUTABLE STRICT; -- WITH (isstrict); +CREATE OR REPLACE FUNCTION st_setgeoreference( + rast raster, + upperleftx double precision, upperlefty double precision, + scalex double precision, scaley double precision, + skewx double precision, skewy double precision +) + RETURNS raster + AS $$ SELECT st_setgeoreference($1, array_to_string(ARRAY[$4, $7, $6, $5, $2, $3], ' ')) $$ + LANGUAGE 'sql' IMMUTABLE STRICT; + ----------------------------------------------------------------------- -- ST_Tile(raster) ----------------------------------------------------------------------- diff --git a/raster/test/regress/rt_georeference.sql b/raster/test/regress/rt_georeference.sql index 98b18297f..ff9edb44e 100644 --- a/raster/test/regress/rt_georeference.sql +++ b/raster/test/regress/rt_georeference.sql @@ -464,4 +464,12 @@ SELECT FROM rt_properties_test WHERE id = 2; +----------------------------------------------------------------------- +-- ST_SetGeoReference(raster, double precision, ...) +----------------------------------------------------------------------- + +SELECT id, ST_Metadata(rast), ST_Metadata(ST_SetGeoReference(rast, 0, 0, 1, -1, 0, 0)) FROM rt_properties_test ORDER BY id; +SELECT id, ST_Metadata(rast), ST_Metadata(ST_SetGeoReference(rast, 1, 1, 0.1, -0.1, 0, 0)) FROM rt_properties_test ORDER BY id; +SELECT id, ST_Metadata(rast), ST_Metadata(ST_SetGeoReference(rast, 0, 0.1, 1, 1, 0, 0)) FROM rt_properties_test ORDER BY id; + DROP TABLE rt_properties_test; diff --git a/raster/test/regress/rt_georeference_expected b/raster/test/regress/rt_georeference_expected index d5ed517e3..8c03f46a6 100644 --- a/raster/test/regress/rt_georeference_expected +++ b/raster/test/regress/rt_georeference_expected @@ -29,3 +29,21 @@ t|t|t|t t|t|t|t t|t|t|t t|t|t|t +0|(0.5,0.5,10,20,2,3,0,0,10,0)|(0,0,10,20,1,-1,0,0,10,0) +1|(2.5,2.5,1,1,5,5,0,0,12,0)|(0,0,1,1,1,-1,0,0,12,0) +2|(7.5,2.5,1,1,5,5,0,0,0,0)|(0,0,1,1,1,-1,0,0,0,0) +3|(7.5,2.5,1,1,5,5,0,0,0,0)|(0,0,1,1,1,-1,0,0,0,0) +4|(7.5,2.5,1,1,5,5,1,1,0,0)|(0,0,1,1,1,-1,0,0,0,0) +5|(7.5,2.5,1,1,5,5,3,7,0,0)|(0,0,1,1,1,-1,0,0,0,0) +0|(0.5,0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