PostGIS  2.4.9dev-r@@SVN_REVISION@@

◆ test_raster_clone()

static void test_raster_clone ( )
static

Definition at line 99 of file cu_raster_basics.c.

References ovdump::band, cu_add_band(), cu_free_raster(), window::gt, PT_32BUI, rt_raster_clone(), rt_raster_get_geotransform_matrix(), rt_raster_get_num_bands(), rt_raster_get_srid(), rt_raster_new(), rt_raster_set_offsets(), rt_raster_set_scale(), and rt_raster_set_srid().

Referenced by raster_basics_suite_setup().

99  {
100  rt_raster rast1;
101  rt_raster rast2;
102  rt_band band;
103 
104  int maxX = 5;
105  int maxY = 5;
106  double gt[6];
107 
108  rast1 = rt_raster_new(maxX, maxY);
109  CU_ASSERT(rast1 != NULL);
110 
111  rt_raster_set_offsets(rast1, 0, 0);
112  rt_raster_set_scale(rast1, 1, -1);
113  rt_raster_set_srid(rast1, 4326);
114 
115  band = cu_add_band(rast1, PT_32BUI, 1, 6);
116  CU_ASSERT(band != NULL);
117 
118  /* clone without bands */
119  rast2 = rt_raster_clone(rast1, 0);
120  CU_ASSERT(rast2 != NULL);
121  CU_ASSERT_EQUAL(rt_raster_get_num_bands(rast2), 0);
122 
124  CU_ASSERT_EQUAL(rt_raster_get_srid(rast2), 4326);
125  CU_ASSERT_DOUBLE_EQUAL(gt[0], 0, DBL_EPSILON);
126  CU_ASSERT_DOUBLE_EQUAL(gt[1], 1, DBL_EPSILON);
127  CU_ASSERT_DOUBLE_EQUAL(gt[2], 0, DBL_EPSILON);
128  CU_ASSERT_DOUBLE_EQUAL(gt[3], 0, DBL_EPSILON);
129  CU_ASSERT_DOUBLE_EQUAL(gt[4], 0, DBL_EPSILON);
130  CU_ASSERT_DOUBLE_EQUAL(gt[5], -1, DBL_EPSILON);
131 
132  cu_free_raster(rast2);
133 
134  /* clone with bands */
135  rast2 = rt_raster_clone(rast1, 1);
136  CU_ASSERT(rast2 != NULL);
137  CU_ASSERT_EQUAL(rt_raster_get_num_bands(rast2), 1);
138 
139  cu_free_raster(rast2);
140  cu_free_raster(rast1);
141 }
int rt_raster_get_num_bands(rt_raster raster)
Definition: rt_raster.c:372
void rt_raster_get_geotransform_matrix(rt_raster raster, double *gt)
Get 6-element array of raster geotransform matrix.
Definition: rt_raster.c:706
band
Definition: ovdump.py:57
gt
Definition: window.py:77
void cu_free_raster(rt_raster raster)
rt_band cu_add_band(rt_raster raster, rt_pixtype pixtype, int hasnodata, double nodataval)
void rt_raster_set_scale(rt_raster raster, double scaleX, double scaleY)
Set scale in projection units.
Definition: rt_raster.c:137
rt_raster rt_raster_clone(rt_raster raster, uint8_t deep)
Clone an existing raster.
Definition: rt_raster.c:1544
void rt_raster_set_offsets(rt_raster raster, double x, double y)
Set insertion points in projection units.
Definition: rt_raster.c:199
void rt_raster_set_srid(rt_raster raster, int32_t srid)
Set raster's SRID.
Definition: rt_raster.c:363
int32_t rt_raster_get_srid(rt_raster raster)
Get raster's SRID.
Definition: rt_raster.c:356
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: