PostGIS  2.4.9dev-r@@SVN_REVISION@@

◆ test_raster_envelope()

static void test_raster_envelope ( )
static

Definition at line 27 of file cu_raster_geometry.c.

References cu_free_raster(), ES_NONE, rt_envelope::MaxX, rt_envelope::MaxY, rt_envelope::MinX, rt_envelope::MinY, rtrowdump::raster, rt_raster_get_envelope(), rt_raster_new(), rt_raster_set_offsets(), and rt_raster_set_scale().

Referenced by raster_geometry_suite_setup().

27  {
28  rt_raster raster = NULL;
29  rt_envelope rtenv;
30 
31  /* width = 0, height = 0 */
32  raster = rt_raster_new(0, 0);
33  CU_ASSERT(raster != NULL);
34 
35  rt_raster_set_offsets(raster, 0.5, 0.5);
36  rt_raster_set_scale(raster, 1, -1);
37 
38  CU_ASSERT_EQUAL(rt_raster_get_envelope(raster, &rtenv), ES_NONE);
39  CU_ASSERT_DOUBLE_EQUAL(rtenv.MinX, 0.5, DBL_EPSILON);
40  CU_ASSERT_DOUBLE_EQUAL(rtenv.MaxX, 0.5, DBL_EPSILON);
41  CU_ASSERT_DOUBLE_EQUAL(rtenv.MinY, 0.5, DBL_EPSILON);
42  CU_ASSERT_DOUBLE_EQUAL(rtenv.MaxY, 0.5, DBL_EPSILON);
43  cu_free_raster(raster);
44 
45  /* width = 0 */
46  raster = rt_raster_new(0, 5);
47  CU_ASSERT(raster != NULL);
48 
49  rt_raster_set_offsets(raster, 0.5, 0.5);
50  rt_raster_set_scale(raster, 1, -1);
51 
52  CU_ASSERT_EQUAL(rt_raster_get_envelope(raster, &rtenv), ES_NONE);
53  CU_ASSERT_DOUBLE_EQUAL(rtenv.MinX, 0.5, DBL_EPSILON);
54  CU_ASSERT_DOUBLE_EQUAL(rtenv.MaxX, 0.5, DBL_EPSILON);
55  CU_ASSERT_DOUBLE_EQUAL(rtenv.MinY, -4.5, DBL_EPSILON);
56  CU_ASSERT_DOUBLE_EQUAL(rtenv.MaxY, 0.5, DBL_EPSILON);
57  cu_free_raster(raster);
58 
59  /* height = 0 */
60  raster = rt_raster_new(5, 0);
61  CU_ASSERT(raster != NULL);
62 
63  rt_raster_set_offsets(raster, 0.5, 0.5);
64  rt_raster_set_scale(raster, 1, -1);
65 
66  CU_ASSERT_EQUAL(rt_raster_get_envelope(raster, &rtenv), ES_NONE);
67  CU_ASSERT_DOUBLE_EQUAL(rtenv.MinX, 0.5, DBL_EPSILON);
68  CU_ASSERT_DOUBLE_EQUAL(rtenv.MaxX, 5.5, DBL_EPSILON);
69  CU_ASSERT_DOUBLE_EQUAL(rtenv.MinY, 0.5, DBL_EPSILON);
70  CU_ASSERT_DOUBLE_EQUAL(rtenv.MaxY, 0.5, DBL_EPSILON);
71  cu_free_raster(raster);
72 
73  /* normal raster */
74  raster = rt_raster_new(5, 5);
75  CU_ASSERT(raster != NULL);
76 
77  rt_raster_set_offsets(raster, 0.5, 0.5);
78  rt_raster_set_scale(raster, 1, -1);
79 
80  CU_ASSERT_EQUAL(rt_raster_get_envelope(raster, &rtenv), ES_NONE);
81  CU_ASSERT_DOUBLE_EQUAL(rtenv.MinX, 0.5, DBL_EPSILON);
82  CU_ASSERT_DOUBLE_EQUAL(rtenv.MaxX, 5.5, DBL_EPSILON);
83  CU_ASSERT_DOUBLE_EQUAL(rtenv.MinY, -4.5, DBL_EPSILON);
84  CU_ASSERT_DOUBLE_EQUAL(rtenv.MaxY, 0.5, DBL_EPSILON);
85  cu_free_raster(raster);
86 }
double MinY
Definition: librtcore.h:167
raster
Be careful!! Zeros function's input parameter can be a (height x width) array, not (width x height): ...
Definition: rtrowdump.py:121
double MaxY
Definition: librtcore.h:168
double MaxX
Definition: librtcore.h:166
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
double MinX
Definition: librtcore.h:165
rt_errorstate rt_raster_get_envelope(rt_raster raster, rt_envelope *env)
Get raster's envelope.
Definition: rt_raster.c:873
Here is the call graph for this function:
Here is the caller graph for this function: