PostGIS  2.5.7dev-r@@SVN_REVISION@@

◆ test_raster_from_two_rasters()

static void test_raster_from_two_rasters ( )
static

Definition at line 65 of file cu_raster_misc.c.

65  {
66  rt_raster rast1;
67  rt_raster rast2;
68  rt_raster rast = NULL;
69  int err;
70  double offset[4] = {0.};
71 
72  rast1 = rt_raster_new(4, 4);
73  CU_ASSERT(rast1 != NULL);
74  rt_raster_set_scale(rast1, 1, 1);
75  rt_raster_set_offsets(rast1, -2, -2);
76 
77  rast2 = rt_raster_new(2, 2);
78  CU_ASSERT(rast2 != NULL);
79  rt_raster_set_scale(rast2, 1, 1);
80 
82  rast1, rast2,
83  ET_FIRST,
84  &rast,
85  offset
86  );
87  CU_ASSERT_EQUAL(err, ES_NONE);
88  CU_ASSERT(rast != NULL);
89  CU_ASSERT_EQUAL(rt_raster_get_width(rast), 4);
90  CU_ASSERT_EQUAL(rt_raster_get_height(rast), 4);
91  CU_ASSERT_DOUBLE_EQUAL(offset[0], 0, DBL_EPSILON);
92  CU_ASSERT_DOUBLE_EQUAL(offset[1], 0, DBL_EPSILON);
93  CU_ASSERT_DOUBLE_EQUAL(offset[2], 2, DBL_EPSILON);
94  CU_ASSERT_DOUBLE_EQUAL(offset[3], 2, DBL_EPSILON);
96 
98  rast1, rast2,
99  ET_SECOND,
100  &rast,
101  offset
102  );
103  CU_ASSERT_EQUAL(err, ES_NONE);
104  CU_ASSERT(rast != NULL);
105  CU_ASSERT_EQUAL(rt_raster_get_width(rast), 2);
106  CU_ASSERT_EQUAL(rt_raster_get_height(rast), 2);
107  CU_ASSERT_DOUBLE_EQUAL(offset[0], -2, DBL_EPSILON);
108  CU_ASSERT_DOUBLE_EQUAL(offset[1], -2, DBL_EPSILON);
109  CU_ASSERT_DOUBLE_EQUAL(offset[2], 0, DBL_EPSILON);
110  CU_ASSERT_DOUBLE_EQUAL(offset[3], 0, DBL_EPSILON);
112 
114  rast1, rast2,
116  &rast,
117  offset
118  );
119  CU_ASSERT_EQUAL(err, ES_NONE);
120  CU_ASSERT(rast != NULL);
121  CU_ASSERT_EQUAL(rt_raster_get_width(rast), 2);
122  CU_ASSERT_EQUAL(rt_raster_get_height(rast), 2);
123  CU_ASSERT_DOUBLE_EQUAL(offset[0], -2, DBL_EPSILON);
124  CU_ASSERT_DOUBLE_EQUAL(offset[1], -2, DBL_EPSILON);
125  CU_ASSERT_DOUBLE_EQUAL(offset[2], 0, DBL_EPSILON);
126  CU_ASSERT_DOUBLE_EQUAL(offset[3], 0, DBL_EPSILON);
128 
130  rast1, rast2,
131  ET_UNION,
132  &rast,
133  offset
134  );
135  CU_ASSERT_EQUAL(err, ES_NONE);
136  CU_ASSERT(rast != NULL);
137  CU_ASSERT_EQUAL(rt_raster_get_width(rast), 4);
138  CU_ASSERT_EQUAL(rt_raster_get_height(rast), 4);
139  CU_ASSERT_DOUBLE_EQUAL(offset[0], 0, DBL_EPSILON);
140  CU_ASSERT_DOUBLE_EQUAL(offset[1], 0, DBL_EPSILON);
141  CU_ASSERT_DOUBLE_EQUAL(offset[2], 2, DBL_EPSILON);
142  CU_ASSERT_DOUBLE_EQUAL(offset[3], 2, DBL_EPSILON);
144 
145  rt_raster_set_scale(rast2, 1, 0.1);
147  rast1, rast2,
148  ET_UNION,
149  &rast,
150  offset
151  );
152  CU_ASSERT_NOT_EQUAL(err, ES_NONE);
153  rt_raster_set_scale(rast2, 1, 1);
154 
155  rt_raster_set_srid(rast2, 9999);
157  rast1, rast2,
158  ET_UNION,
159  &rast,
160  offset
161  );
162  CU_ASSERT_NOT_EQUAL(err, ES_NONE);
163  rt_raster_set_srid(rast2, 0);
164 
165  rt_raster_set_skews(rast2, -1, 1);
167  rast1, rast2,
168  ET_UNION,
169  &rast,
170  offset
171  );
172  CU_ASSERT_NOT_EQUAL(err, ES_NONE);
173 
174  cu_free_raster(rast2);
175  cu_free_raster(rast1);
176 }
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_skews(rt_raster raster, double skewX, double skewY)
Set skews about the X and Y axis.
Definition: rt_raster.c:168
rt_raster rt_raster_new(uint32_t width, uint32_t height)
Construct a raster with given dimensions.
Definition: rt_raster.c:48
@ ES_NONE
Definition: librtcore.h:180
uint16_t rt_raster_get_height(rt_raster raster)
Definition: rt_raster.c:129
void rt_raster_set_srid(rt_raster raster, int32_t srid)
Set raster's SRID.
Definition: rt_raster.c:363
@ ET_INTERSECTION
Definition: librtcore.h:201
@ ET_UNION
Definition: librtcore.h:202
@ ET_SECOND
Definition: librtcore.h:204
@ ET_FIRST
Definition: librtcore.h:203
uint16_t rt_raster_get_width(rt_raster raster)
Definition: rt_raster.c:121
rt_errorstate rt_raster_from_two_rasters(rt_raster rast1, rt_raster rast2, rt_extenttype extenttype, rt_raster *rtnraster, double *offset)
Definition: rt_raster.c:3361
void rt_raster_set_offsets(rt_raster raster, double x, double y)
Set insertion points in projection units.
Definition: rt_raster.c:199
void cu_free_raster(rt_raster raster)

References cu_free_raster(), ES_NONE, ET_FIRST, ET_INTERSECTION, ET_SECOND, ET_UNION, rtpixdump::rast, rt_raster_from_two_rasters(), rt_raster_get_height(), rt_raster_get_width(), rt_raster_new(), rt_raster_set_offsets(), rt_raster_set_scale(), rt_raster_set_skews(), and rt_raster_set_srid().

Referenced by raster_misc_suite_setup().

Here is the call graph for this function:
Here is the caller graph for this function: