From: Bborie Park Date: Thu, 21 Jul 2011 16:20:36 +0000 (+0000) Subject: Fixed floating point issue with the remainder returned from the function modf in... X-Git-Tag: 2.0.0alpha1~1189 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=29686bbbfa44f4d9840100ff50c3cebc7dc3eb10;p=postgis Fixed floating point issue with the remainder returned from the function modf in rt_api.c. Updated messages in rt_pg.c. Corrected expected regression results in rt_resample_expected. Associated ticket is #1114 git-svn-id: http://svn.osgeo.org/postgis/trunk@7657 b70326c6-7e19-0410-871a-916f4a2858ee --- diff --git a/raster/rt_core/rt_api.c b/raster/rt_core/rt_api.c index c47bcc7e9..7889a5015 100644 --- a/raster/rt_core/rt_api.c +++ b/raster/rt_core/rt_api.c @@ -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); diff --git a/raster/rt_pg/rt_pg.c b/raster/rt_pg/rt_pg.c index 585ef2adb..b39015d94 100644 --- a/raster/rt_pg/rt_pg.c +++ b/raster/rt_pg/rt_pg.c @@ -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); } diff --git a/raster/test/regress/rt_resample_expected b/raster/test/regress/rt_resample_expected index edc1b1d4b..6744635c0 100644 --- a/raster/test/regress/rt_resample_expected +++ b/raster/test/regress/rt_resample_expected @@ -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