]> granicus.if.org Git - postgis/commitdiff
Fixed floating point issue with the remainder returned from the function modf in...
authorBborie Park <bkpark at ucdavis.edu>
Thu, 21 Jul 2011 16:20:36 +0000 (16:20 +0000)
committerBborie Park <bkpark at ucdavis.edu>
Thu, 21 Jul 2011 16:20:36 +0000 (16:20 +0000)
Associated ticket is #1114

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

raster/rt_core/rt_api.c
raster/rt_pg/rt_pg.c
raster/test/regress/rt_resample_expected

index c47bcc7e90b0f95125f265775cbff7129246ed7d..7889a50154ff741d233884c88596a365ca2fe99a 100644 (file)
@@ -6192,7 +6192,7 @@ rt_raster rt_raster_gdal_warp(
                if (FLT_NEQ(grid_shift_xw, 0.)) {
                        min_x = dst_gt[0] + grid_shift_xw;
                        min_x = modf(fabs(*grid_xw - min_x) / grid_pix_x, &djunk);
-                       if (FLT_NEQ(min_x, 0.)) grid_shift_xw *= -1;
+                       if (FLT_NEQ(min_x, 0.) && FLT_NEQ(min_x, 1.)) grid_shift_xw *= -1;
                        min_x = dst_gt[0] + grid_shift_xw;
                        if (min_x > dst_gt[0]) {
                                grid_shift_xw = grid_pix_x - fabs(grid_shift_xw);
@@ -6208,7 +6208,7 @@ rt_raster rt_raster_gdal_warp(
                if (FLT_NEQ(grid_shift_yw, 0.)) {
                        max_y = dst_gt[3] + grid_shift_yw;
                        max_y = modf(fabs(*grid_yw - max_y) / grid_pix_y, &djunk);
-                       if (FLT_NEQ(max_y, 0.)) grid_shift_yw *= -1;
+                       if (FLT_NEQ(max_y, 0.) && FLT_NEQ(max_y, 1.)) grid_shift_yw *= -1;
                        max_y = dst_gt[3] + grid_shift_yw;
                        if (max_y < dst_gt[3]) {
                                grid_shift_yw = grid_pix_y - fabs(grid_shift_yw);
index 585ef2adb5abf175edcb4fba8abcd52c56837533..b39015d941e86a3509388222ebea54e62543a4cc 100644 (file)
@@ -4653,10 +4653,10 @@ Datum RASTER_getGDALDrivers(PG_FUNCTION_ARGS)
                values[2] = CStringGetTextDatum(drv_set2[call_cntr].long_name);
                values[3] = CStringGetTextDatum(drv_set2[call_cntr].create_options);
 
-               POSTGIS_RT_DEBUGF(4, "Result %d, Index %s", call_cntr, values[0]);
-               POSTGIS_RT_DEBUGF(4, "Result %d, Short Name %s", call_cntr, values[1]);
-               POSTGIS_RT_DEBUGF(4, "Result %d, Full Name %s", call_cntr, values[2]);
-               POSTGIS_RT_DEBUGF(5, "Result %d, Create Options %s", call_cntr, values[3]);
+               POSTGIS_RT_DEBUGF(4, "Result %d, Index %d", call_cntr, drv_set2[call_cntr].idx);
+               POSTGIS_RT_DEBUGF(4, "Result %d, Short Name %s", call_cntr, drv_set2[call_cntr].short_name);
+               POSTGIS_RT_DEBUGF(4, "Result %d, Full Name %s", call_cntr, drv_set2[call_cntr].long_name);
+               POSTGIS_RT_DEBUGF(5, "Result %d, Create Options %s", call_cntr, drv_set2[call_cntr].create_options);
 
                /* build a tuple */
                tuple = heap_form_tuple(tupdesc, values, nulls);
@@ -4814,7 +4814,7 @@ Datum RASTER_resample(PG_FUNCTION_ARGS)
                (grid_xw != NULL && grid_yw == NULL) ||
                (grid_xw == NULL && grid_yw != NULL)
        ) {
-               elog(NOTICE, "Values must be provided for both X and Y coordinates when specifying the alignment.  Returning original raster");
+               elog(NOTICE, "Values must be provided for both X and Y when specifying the alignment.  Returning original raster");
                rt_raster_destroy(raster);
                PG_RETURN_POINTER(pgraster);
        }
@@ -4823,7 +4823,7 @@ Datum RASTER_resample(PG_FUNCTION_ARGS)
                (scale_x != NULL && scale_y == NULL) ||
                (scale_x == NULL && scale_y != NULL)
        ) {
-               elog(NOTICE, "Values must be provided for both X and Y axis when specifying the scale.  Returning original raster");
+               elog(NOTICE, "Values must be provided for both X and Y when specifying the scale.  Returning original raster");
                rt_raster_destroy(raster);
                PG_RETURN_POINTER(pgraster);
        }
@@ -4874,6 +4874,8 @@ Datum RASTER_resample(PG_FUNCTION_ARGS)
 
        if (NULL == pgrast) PG_RETURN_NULL();
 
+       POSTGIS_RT_DEBUG(3, "RASTER_resample: done");
+
        SET_VARSIZE(pgrast, pgrast->size);
        PG_RETURN_POINTER(pgrast);
 }
index edc1b1d4bf68bfd483533726e8b940881a54bf71..6744635c071bd8d951d39c0176f72cf51c604521 100644 (file)
@@ -1,14 +1,14 @@
 NOTICE:  table "raster_resample_src" does not exist, skipping
 NOTICE:  table "raster_resample_dst" does not exist, skipping
-NOTICE:  Values must be provided for both X and Y axis when specifying the scale.  Returning original raster
-NOTICE:  Values must be provided for both X and Y axis when specifying the scale.  Returning original raster
+NOTICE:  Values must be provided for both X and Y when specifying the scale.  Returning original raster
+NOTICE:  Values must be provided for both X and Y when specifying the scale.  Returning original raster
 1.1|992163|10|10|1|1000.000|-1000.000|0.000|0.000|-500000.000|600000.000|t|t|t
 1.10|992163|40|40|1|250.000|-250.000|0.000|0.000|-500000.000|600000.000|t|t|t
 1.11|992163|10|10|1|1000.000|-1000.000|0.000|0.000|-500000.000|600000.000|t|t|t
 1.12|992163|10|10|1|1000.000|-1000.000|0.000|0.000|-500001.000|600000.000|t|t|t
 1.13|992163|10|10|1|1000.000|-1000.000|0.000|0.000|-500000.000|600009.000|t|t|t
 1.14|992163|10|11|1|1000.000|-1000.000|0.000|0.000|-500100.000|600950.000|t|t|t
-1.15|992163|200|200|1|50.000|-50.000|0.000|0.000|-500010.000|600007.000|t|t|t
+1.15|992163|201|200|1|50.000|-50.000|0.000|0.000|-500040.000|600007.000|t|t|t
 1.16|992163|83|83|1|121.000|-121.000|0.000|0.000|-500093.000|600039.000|t|t|t
 1.17|993310|243|243|1|50.000|-50.000|0.000|0.000|950710.000|1409307.000|t|t|t
 1.18|993309|242|243|1|50.000|-50.000|0.000|0.000|950760.000|1409107.000|t|t|t
@@ -72,7 +72,7 @@ NOTICE:  Values must be provided for both X and Y axis when specifying the scale
 5.24|992163|83|83|1|121.000|-121.000|0.000|0.000|-500000.000|600040.000|t|t|t
 5.25|992163|83|83|1|121.000|-121.000|0.000|0.000|-500000.000|600048.000|t|t|t
 5.26|992163|83|83|1|121.000|-121.000|0.000|0.000|-500098.000|600040.000|t|t|t
-5.27|992163|83|83|1|121.000|-121.000|0.000|0.000|-500037.000|600030.000|t|t|t
+5.27|992163|83|83|1|121.000|-121.000|0.000|0.000|-500084.000|600030.000|t|t|t
 5.3|992163|10|10|1|1000.000|-1000.000|0.000|0.000|-500001.000|600000.000|t|t|t
 5.4|992163|10|10|1|1000.000|-1000.000|0.000|0.000|-500001.000|600000.000|t|t|t
 5.5|992163|11|10|1|1000.000|-1000.000|0.000|0.000|-500999.000|600000.000|t|t|t