mirror of
https://git.osgeo.org/gitea/postgis/postgis
synced 2024-10-24 00:52:40 +00:00
Corrected rt_raster_same_alignment() and RASTER_sameAlignment() to behave as an end-user would expect it to. So intead of errors when parameters don't match, return false.
git-svn-id: http://svn.osgeo.org/postgis/trunk@7999 b70326c6-7e19-0410-871a-916f4a2858ee
This commit is contained in:
parent
8864196bef
commit
4c7dbc99ce
|
@ -38,8 +38,14 @@
|
|||
#include <time.h> /* for time */
|
||||
#include "rt_api.h"
|
||||
|
||||
#define POSTGIS_RASTER_WARN_ON_TRUNCATION
|
||||
/******************************************************************************
|
||||
* Some rules for *.(c|h) files in rt_core
|
||||
*
|
||||
* All functions in rt_core that receive a band index parameter
|
||||
* must be 0-based
|
||||
*****************************************************************************/
|
||||
|
||||
#define POSTGIS_RASTER_WARN_ON_TRUNCATION
|
||||
|
||||
/*--- Utilities -------------------------------------------------*/
|
||||
|
||||
|
@ -8727,34 +8733,36 @@ rt_raster_same_alignment(
|
|||
double yr;
|
||||
double xw;
|
||||
double yw;
|
||||
int err = 0;
|
||||
|
||||
err = 0;
|
||||
/* same srid */
|
||||
if (rast1->srid != rast2->srid) {
|
||||
rterror("rt_raster_same_alignment: The two rasters provided have different SRIDs");
|
||||
*aligned = 0;
|
||||
return 0;
|
||||
RASTER_DEBUG(3, "The two rasters provided have different SRIDs");
|
||||
err = 1;
|
||||
}
|
||||
/* scales must match */
|
||||
else if (FLT_NEQ(rast1->scaleX, rast2->scaleX)) {
|
||||
rterror("rt_raster_same_alignment: The two raster provided have different scales on the X axis");
|
||||
*aligned = 0;
|
||||
return 0;
|
||||
RASTER_DEBUG(3, "The two raster provided have different scales on the X axis");
|
||||
err = 1;
|
||||
}
|
||||
else if (FLT_NEQ(rast1->scaleY, rast2->scaleY)) {
|
||||
rterror("rt_raster_same_alignment: The two raster provided have different scales on the Y axis");
|
||||
*aligned = 0;
|
||||
return 0;
|
||||
RASTER_DEBUG(3, "The two raster provided have different scales on the Y axis");
|
||||
err = 1;
|
||||
}
|
||||
/* skews must match */
|
||||
else if (FLT_NEQ(rast1->skewX, rast2->skewX)) {
|
||||
rterror("rt_raster_same_alignment: The two raster provided have different skews on the X axis");
|
||||
*aligned = 0;
|
||||
return 0;
|
||||
RASTER_DEBUG(3, "The two raster provided have different skews on the X axis");
|
||||
err = 1;
|
||||
}
|
||||
else if (FLT_NEQ(rast1->skewY, rast2->skewY)) {
|
||||
rterror("rt_raster_same_alignment: The two raster provided have different skews on the Y axis");
|
||||
RASTER_DEBUG(3, "The two raster provided have different skews on the Y axis");
|
||||
err = 1;
|
||||
}
|
||||
|
||||
if (err) {
|
||||
*aligned = 0;
|
||||
return 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* raster coordinates in context of second raster of first raster's upper-left corner */
|
||||
|
|
|
@ -7900,7 +7900,7 @@ Datum RASTER_sameAlignment(PG_FUNCTION_ARGS)
|
|||
uint32_t j;
|
||||
uint32_t k;
|
||||
int rtn;
|
||||
int aligned;
|
||||
int aligned = 0;
|
||||
int err = 0;
|
||||
|
||||
for (i = 0, j = 0; i < set_count; i++) {
|
||||
|
@ -7948,7 +7948,7 @@ Datum RASTER_sameAlignment(PG_FUNCTION_ARGS)
|
|||
|
||||
if (err) {
|
||||
for (k = 0; k < set_count; k++) rt_raster_destroy(rast[k]);
|
||||
PG_RETURN_NULL();
|
||||
PG_RETURN_BOOL(0);
|
||||
}
|
||||
|
||||
rtn = rt_raster_same_alignment(
|
||||
|
|
|
@ -2080,13 +2080,13 @@ static void testAlignment() {
|
|||
|
||||
rt_raster_set_scale(rast2, 0.1, 0.1);
|
||||
rtn = rt_raster_same_alignment(rast1, rast2, &aligned);
|
||||
CHECK((rtn == 0));
|
||||
CHECK((rtn != 0));
|
||||
CHECK((aligned == 0));
|
||||
rt_raster_set_scale(rast2, 1, 1);
|
||||
|
||||
rt_raster_set_skews(rast2, -0.5, 0.5);
|
||||
rtn = rt_raster_same_alignment(rast1, rast2, &aligned);
|
||||
CHECK((rtn == 0));
|
||||
CHECK((rtn != 0));
|
||||
CHECK((aligned == 0));
|
||||
rt_raster_set_skews(rast2, 0, 0);
|
||||
|
||||
|
|
|
@ -1,10 +1,16 @@
|
|||
t
|
||||
NOTICE: The two rasters provided have different scales on the X axis
|
||||
f
|
||||
NOTICE: The two rasters provided have different scales on the X axis
|
||||
f
|
||||
NOTICE: The two rasters provided have different skews on the X axis
|
||||
f
|
||||
NOTICE: The two rasters provided have different skews on the Y axis
|
||||
f
|
||||
NOTICE: The two rasters provided have different skews on the X axis
|
||||
f
|
||||
t
|
||||
f
|
||||
t
|
||||
NOTICE: The two rasters provided have different skews on the Y axis
|
||||
f
|
||||
|
|
Loading…
Reference in a new issue