PostGIS  2.4.9dev-r@@SVN_REVISION@@

◆ test_raster_same_alignment()

static void test_raster_same_alignment ( )
static

Definition at line 4728 of file cu_spatial_relationship.c.

References cu_free_raster(), ES_NONE, rt_raster_new(), rt_raster_same_alignment(), rt_raster_set_offsets(), rt_raster_set_scale(), rt_raster_set_skews(), and spatial_relationship_suite_setup().

Referenced by spatial_relationship_suite_setup().

4728  {
4729  rt_raster rast1;
4730  rt_raster rast2;
4731  int rtn;
4732  int aligned;
4733  char *reason;
4734 
4735  rast1 = rt_raster_new(2, 2);
4736  CU_ASSERT(rast1 != NULL);
4737  rt_raster_set_scale(rast1, 1, 1);
4738 
4739  rast2 = rt_raster_new(10, 10);
4740  CU_ASSERT(rast2 != NULL);
4741  rt_raster_set_scale(rast2, 1, 1);
4742 
4743  rtn = rt_raster_same_alignment(rast1, rast2, &aligned, NULL);
4744  CU_ASSERT_EQUAL(rtn, ES_NONE);
4745  CU_ASSERT_NOT_EQUAL(aligned, 0);
4746 
4747  rt_raster_set_scale(rast2, 0.1, 0.1);
4748  rtn = rt_raster_same_alignment(rast1, rast2, &aligned, &reason);
4749  CU_ASSERT_EQUAL(rtn, ES_NONE);
4750  CU_ASSERT_EQUAL(aligned, 0);
4751  CU_ASSERT_STRING_EQUAL(reason, "The rasters have different scales on the X axis");
4752  rt_raster_set_scale(rast2, 1, 1);
4753 
4754  rt_raster_set_skews(rast2, -0.5, 0.5);
4755  rtn = rt_raster_same_alignment(rast1, rast2, &aligned, &reason);
4756  CU_ASSERT_EQUAL(rtn, ES_NONE);
4757  CU_ASSERT_EQUAL(aligned, 0);
4758  CU_ASSERT_STRING_EQUAL(reason, "The rasters have different skews on the X axis");
4759  rt_raster_set_skews(rast2, 0, 0);
4760 
4761  rt_raster_set_offsets(rast2, 1, 1);
4762  rtn = rt_raster_same_alignment(rast1, rast2, &aligned, NULL);
4763  CU_ASSERT_EQUAL(rtn, ES_NONE);
4764  CU_ASSERT_NOT_EQUAL(aligned, 0);
4765 
4766  rt_raster_set_offsets(rast2, 2, 3);
4767  rtn = rt_raster_same_alignment(rast1, rast2, &aligned, NULL);
4768  CU_ASSERT_EQUAL(rtn, ES_NONE);
4769  CU_ASSERT_NOT_EQUAL(aligned, 0);
4770 
4771  rt_raster_set_offsets(rast2, 0.1, 0.1);
4772  rtn = rt_raster_same_alignment(rast1, rast2, &aligned, &reason);
4773  CU_ASSERT_EQUAL(rtn, ES_NONE);
4774  CU_ASSERT_EQUAL(aligned, 0);
4775  CU_ASSERT_STRING_EQUAL(reason, "The rasters (pixel corner coordinates) are not aligned");
4776 
4777  cu_free_raster(rast2);
4778  cu_free_raster(rast1);
4779 }
rt_errorstate rt_raster_same_alignment(rt_raster rast1, rt_raster rast2, int *aligned, char **reason)
void rt_raster_set_skews(rt_raster raster, double skewX, double skewY)
Set skews about the X and Y axis.
Definition: rt_raster.c:168
void cu_free_raster(rt_raster raster)
void rt_raster_set_scale(rt_raster raster, double scaleX, double scaleY)
Set scale in projection units.
Definition: rt_raster.c:137
void rt_raster_set_offsets(rt_raster raster, double x, double y)
Set insertion points in projection units.
Definition: rt_raster.c:199
rt_raster rt_raster_new(uint32_t width, uint32_t height)
Construct a raster with given dimensions.
Definition: rt_raster.c:48
Here is the call graph for this function:
Here is the caller graph for this function: