Fix output georeference on warping rasters with default georeference
authorSandro Santilli <strk@keybit.net>
Thu, 28 Aug 2014 15:15:43 +0000 (15:15 +0000)
committerSandro Santilli <strk@keybit.net>
Thu, 28 Aug 2014 15:15:43 +0000 (15:15 +0000)
Closes #2911 and re-closes #2251

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

raster/rt_core/rt_warp.c
raster/test/regress/rt_gdalwarp.sql
raster/test/regress/rt_gdalwarp_expected
raster/test/regress/tickets.sql
raster/test/regress/tickets_expected

index 03a9ef1ec30b79cd3f5f76c25f5905274787bcf4..10964c4ffa6fbbd8f93b724150ea33a10fd51f7a 100644 (file)
@@ -29,6 +29,9 @@
  *
  */
 
+#include "../../postgis_config.h"
+//#define POSTGIS_DEBUG_LEVEL 4
+
 #include "librtcore.h"
 #include "librtcore_internal.h"
 
@@ -990,6 +993,12 @@ rt_raster rt_raster_gdal_warp(
        /* substitute spatial, reset back to default */
        if (subspatial) {
                double gt[6] = {0, 1, 0, 0, 0, -1};
+               /* See http://trac.osgeo.org/postgis/ticket/2911 */
+               /* We should proably also tweak rotation here */
+               /* NOTE: the times 10 is because it was divided by 10 in a section above,
+                *       I'm not sure the above division was needed */
+               gt[1] = _scale[0] * 10;
+               gt[5] = -1 * _scale[1] * 10;
 
                rt_raster_set_geotransform_matrix(rast, gt);
                rt_raster_set_srid(rast, SRID_UNKNOWN);
index bb20eb6d4a24303582dece200026d0bbd7951f1b..14b7a2f4afdc060b946206ee1d97f0276fcd3d6e 100644 (file)
@@ -835,14 +835,14 @@ SELECT
                        ST_MakeEmptyRaster(1000, 1000, 0, 0, 1, -1, 0, 0, 0)
                        , 1, '8BUI', 255, 0
                )
-               , 0.25, 0.9
+               , 0.25, 0.8
        ) AS rast
 UNION ALL
 SELECT -- ticket #2188
        4 AS rid, 
        ST_Resize(
                ST_AddBand(
-                       ST_MakeEmptyRaster(1024, 768, 0, 0, 1, -1, 0, 0, 0)
+                       ST_MakeEmptyRaster(1000, 1000, 0, 0, 1, -1, 0, 0, 0)
                        , 1, '8BUI', 255, 0
                )
                , 0.5, 0.5
index 8056e3bffe5d16258fdfcb1f80a048ddf9155e17..df0da040a6c2d5fed4560c9b3b2f4dc9015e6047 100644 (file)
@@ -25,9 +25,9 @@ NOTICE:  Values must be provided for both X and Y when specifying the scale.  Re
 0.22|993310|26|26|1|500.000|500.000|0.000|6.000|950452.000|1396632.000|t|t|t
 0.23|984269|12|8|1|0.012|-0.012|0.000|0.000|-107.029|50.206|t|t|t
 0.24|974269|12|8|1|0.012|-0.012|0.000|0.000|-107.029|50.206|t|t|t
-0.25|0|5|5|1|1.000|-1.000|0.000|0.000|0.000|0.000|t|t|t
-0.26|0|2|2|1|1.000|-1.000|0.000|0.000|0.000|0.000|t|t|t
-0.27|0|100|100|1|1.000|-1.000|0.000|0.000|0.000|0.000|t|t|t
+0.25|0|5|5|1|2.000|-2.000|0.000|0.000|0.000|0.000|t|t|t
+0.26|0|2|2|1|5.000|-5.000|0.000|0.000|0.000|0.000|t|t|t
+0.27|0|100|100|1|0.100|-0.100|0.000|0.000|0.000|0.000|t|t|t
 0.3|994269|12|8|1|0.012|-0.012|0.000|0.000|-107.029|50.206|t|t|t
 0.4|993310|24|24|1|500.000|500.000|0.000|0.000|950732.188|1397281.783|t|t|t
 0.5|992163|10|10|1|1000.000|-1000.000|0.000|0.000|-500000.000|600000.000|t|t|t
@@ -121,10 +121,10 @@ NOTICE:  Raster has default geotransform. Adjusting metadata for use of GDAL War
 NOTICE:  Raster has default geotransform. Adjusting metadata for use of GDAL Warp API
 NOTICE:  Raster has default geotransform. Adjusting metadata for use of GDAL Warp API
 NOTICE:  Raster has default geotransform. Adjusting metadata for use of GDAL Warp API
-1|0|0|500|500|1|-1|0|0|0|1|250000|63750000|255|0|255|255
-2|0|0|500|100|1|-1|0|0|0|1|50000|12750000|255|0|255|255
-3|0|0|250|900|1|-1|0|0|0|1|225000|57375000|255|0|255|255
-4|0|0|512|384|1|-1|0|0|0|1|196608|50135040|255|0|255|255
+1|0|0|500|500|2|-2|0|0|0|1|250000|63750000|255|0|255|255
+2|0|0|500|100|2|-10|0|0|0|1|50000|12750000|255|0|255|255
+3|0|0|250|800|4|-1.25|0|0|0|1|200000|51000000|255|0|255|255
+4|0|0|500|500|2|-2|0|0|0|1|250000|63750000|255|0|255|255
 NOTICE:  Raster has default geotransform. Adjusting metadata for use of GDAL Warp API
 NOTICE:  Raster has default geotransform. Adjusting metadata for use of GDAL Warp API
-(0,0,5,5,1,-1,0,0,0,1)|(0,0,5,5,1,-1,0,0,0,1)
+(0,0,5,5,2,-2,0,0,0,1)|(0,0,5,5,2,-2,0,0,0,1)
index 7ce9c247448b777ec7413694eeb8b55760d8a65f..398c61ce0569e76ba5d55671c2247f3b4ef6d491 100644 (file)
@@ -3,5 +3,16 @@ SELECT '#1485', count(*) FROM geometry_columns
 WHERE f_table_name = 'raster_columns';
 
 -- #2532
-SELECT NULL::raster @ null::geometry;
-SELECT NULL::geometry @ null::raster;
+SELECT '#2532.1', NULL::raster @ null::geometry;
+SELECT '#2532.2', NULL::geometry @ null::raster;
+
+-- #2911
+WITH data AS ( SELECT '#2911' l, ST_Metadata(ST_Rescale(
+ ST_AddBand(
+  ST_MakeEmptyRaster(10, 10, 0, 0, 1, -1, 0, 0, 0),
+  1, '8BUI', 0, 0
+ ),
+ 2.0,
+ -2.0
+ )) m
+) SELECT l, (m).* FROM data;
index 1c1b1e09e82f90c34320f05c8332f9c6d194e246..e00841ebf12f3961a470a225ddd863d76d54e3be 100644 (file)
@@ -1 +1,5 @@
 #1485|0
+#2532.1|
+#2532.2|
+NOTICE:  Raster has default geotransform. Adjusting metadata for use of GDAL Warp API
+#2911|0|0|5|5|2|-2|0|0|0|1