]> granicus.if.org Git - postgis/commitdiff
Added numerical parameters version of ST_SetGeoReference(raster).
authorBborie Park <bkpark at ucdavis.edu>
Tue, 16 Apr 2013 18:23:36 +0000 (18:23 +0000)
committerBborie Park <bkpark at ucdavis.edu>
Tue, 16 Apr 2013 18:23:36 +0000 (18:23 +0000)
Ticket #613

git-svn-id: http://svn.osgeo.org/postgis/trunk@11304 b70326c6-7e19-0410-871a-916f4a2858ee

NEWS
doc/reference_raster.xml
raster/rt_pg/rtpostgis.sql.in
raster/test/regress/rt_georeference.sql
raster/test/regress/rt_georeference_expected

diff --git a/NEWS b/NEWS
index ea97b2e8b0bd49639ff0afdb38845961f0c3b027..0a0e3ccd518ae7b164f55a22334d0e637e1e4257 100644 (file)
--- 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 *
 
index 33d9536fbf55c434a2ed6f3ebaa9d141c7fefaee..b837bd1e6edfc7f2e5876713e7af6caa3ee485d8 100644 (file)
@@ -5194,12 +5194,25 @@ FROM (
                
                        <refsynopsisdiv>
                                <funcsynopsis>
+
                                  <funcprototype>
-                                       <funcdef>raster <function>ST_SetGeoReference</function></funcdef>
-                                       <paramdef><type>raster </type> <parameter>rast</parameter></paramdef>
-                                       <paramdef><type>text </type> <parameter>georefcoords</parameter></paramdef>
-                                       <paramdef choice="opt"><type>text </type> <parameter>format=GDAL</parameter></paramdef>
+                                               <funcdef>raster <function>ST_SetGeoReference</function></funcdef>
+                                               <paramdef><type>raster </type> <parameter>rast</parameter></paramdef>
+                                               <paramdef><type>text </type> <parameter>georefcoords</parameter></paramdef>
+                                               <paramdef choice="opt"><type>text </type> <parameter>format=GDAL</parameter></paramdef>
+                                 </funcprototype>
+
+                                 <funcprototype>
+                                               <funcdef>raster <function>ST_SetGeoReference</function></funcdef>
+                                               <paramdef><type>raster </type> <parameter>rast</parameter></paramdef>
+                                               <paramdef><type>double precision </type> <parameter>upperleftx</parameter></paramdef>
+                                               <paramdef><type>double precision </type> <parameter>upperlefty</parameter></paramdef>
+                                               <paramdef><type>double precision </type> <parameter>scalex</parameter></paramdef>
+                                               <paramdef><type>double precision </type> <parameter>scaley</parameter></paramdef>
+                                               <paramdef><type>double precision </type> <parameter>skewx</parameter></paramdef>
+                                               <paramdef><type>double precision </type> <parameter>skewy</parameter></paramdef>
                                  </funcprototype>
+
                                </funcsynopsis>
                        </refsynopsisdiv>
                
@@ -5213,24 +5226,45 @@ FROM (
                                <para><varname>ESRI</varname>: 
 <programlisting>scalex skewy skewx scaley upperleftx + scalex*0.5 upperlefty + scaley*0.5</programlisting></para>
 
-
                                <note>
                                        <para>
                                                If the raster has out-db bands, changing the georeference may result in incorrect access of the band's externally stored data.
                                        </para>
                                </note>
 
+                               <para>Enhanced: 2.1.0 Addition of ST_SetGeoReference(raster, double precision, ...) variant</para>
+
                        </refsection>
                                
                        <refsection>
                                <title>Examples</title>
                        
-                               <programlisting>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;
+                               <programlisting>
+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
                                </programlisting>       
                        </refsection>
 
index 4e6ed4024d28446abcda9d2799e4a675a0a0b95d..fd6e8bd849b870bb92d43876109b525ce154065f 100644 (file)
@@ -9,7 +9,7 @@
 -- Copyright (c) 2009-2010 Jorge Arevalo <jorge.arevalo@deimos-space.com>
 -- Copyright (c) 2009-2010 Mateusz Loskot <mateusz@loskot.net>
 -- Copyright (c) 2010 David Zwarg <dzwarg@azavea.com>
--- Copyright (C) 2011-2012 Regents of the University of California
+-- Copyright (C) 2011-2013 Regents of the University of California
 --   <bkpark@ucdavis.edu>
 --
 -- 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)
 -----------------------------------------------------------------------
index 98b18297f4fd2a3e2b03e1a4f2226e01d8040563..ff9edb44e98f6d552abfb3a5c32689de1be8cfba 100644 (file)
@@ -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;
index d5ed517e3c55a842fc905561a8efc1cd5aebb3d6..8c03f46a6ba053adabb6ae9f66dd8541c19bb77e 100644 (file)
@@ -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.5,10,20,2,3,0,0,10,0)|(1,1,10,20,0.1,-0.1,0,0,10,0)
+1|(2.5,2.5,1,1,5,5,0,0,12,0)|(1,1,1,1,0.1,-0.1,0,0,12,0)
+2|(7.5,2.5,1,1,5,5,0,0,0,0)|(1,1,1,1,0.1,-0.1,0,0,0,0)
+3|(7.5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