PostGIS  2.5.7dev-r@@SVN_REVISION@@

◆ test_raster_envelope_geom()

static void test_raster_envelope_geom ( )
static

Definition at line 88 of file cu_raster_geometry.c.

88  {
89  rt_raster raster = NULL;
90  LWGEOM *env = NULL;
91  LWPOLY *poly = NULL;
92  POINTARRAY *ring = NULL;
93  POINT4D pt;
94 
95  /* NULL raster */
96  CU_ASSERT_EQUAL(rt_raster_get_envelope_geom(NULL, &env), ES_NONE);
97  CU_ASSERT(env == NULL);
98 
99  /* width = 0, height = 0 */
100  raster = rt_raster_new(0, 0);
101  CU_ASSERT(raster != NULL);
102 
103  CU_ASSERT_EQUAL(rt_raster_get_envelope_geom(raster, &env), ES_NONE);
104  CU_ASSERT_EQUAL(env->type, POINTTYPE);
105  lwgeom_free(env);
107 
108  /* width = 0 */
109  raster = rt_raster_new(0, 256);
110  CU_ASSERT(raster != NULL);
111 
112  CU_ASSERT_EQUAL(rt_raster_get_envelope_geom(raster, &env), ES_NONE);
113  CU_ASSERT_EQUAL(env->type, LINETYPE);
114  lwgeom_free(env);
116 
117  /* height = 0 */
118  raster = rt_raster_new(256, 0);
119  CU_ASSERT(raster != NULL);
120 
121  CU_ASSERT_EQUAL(rt_raster_get_envelope_geom(raster, &env), ES_NONE);
122  CU_ASSERT_EQUAL(env->type, LINETYPE);
123  lwgeom_free(env);
125 
126  /* normal raster */
127  raster = rt_raster_new(5, 5);
128  CU_ASSERT(raster != NULL);
129 
130  rt_raster_set_offsets(raster, 0.5, 0.5);
131  rt_raster_set_scale(raster, 1, -1);
132 
133  CU_ASSERT_EQUAL(rt_raster_get_envelope_geom(raster, &env), ES_NONE);
134  poly = lwgeom_as_lwpoly(env);
135  CU_ASSERT_EQUAL(poly->srid, rt_raster_get_srid(raster));
136  CU_ASSERT_EQUAL(poly->nrings, 1);
137 
138  ring = poly->rings[0];
139  CU_ASSERT(ring != NULL);
140  CU_ASSERT_EQUAL(ring->npoints, 5);
141 
142  getPoint4d_p(ring, 0, &pt);
143  CU_ASSERT_DOUBLE_EQUAL(pt.x, 0.5, DBL_EPSILON);
144  CU_ASSERT_DOUBLE_EQUAL(pt.y, 0.5, DBL_EPSILON);
145 
146  getPoint4d_p(ring, 1, &pt);
147  CU_ASSERT_DOUBLE_EQUAL(pt.x, 5.5, DBL_EPSILON);
148  CU_ASSERT_DOUBLE_EQUAL(pt.y, 0.5, DBL_EPSILON);
149 
150  getPoint4d_p(ring, 2, &pt);
151  CU_ASSERT_DOUBLE_EQUAL(pt.x, 5.5, DBL_EPSILON);
152  CU_ASSERT_DOUBLE_EQUAL(pt.y, -4.5, DBL_EPSILON);
153 
154  getPoint4d_p(ring, 3, &pt);
155  CU_ASSERT_DOUBLE_EQUAL(pt.x, 0.5, DBL_EPSILON);
156  CU_ASSERT_DOUBLE_EQUAL(pt.y, -4.5, DBL_EPSILON);
157 
158  getPoint4d_p(ring, 4, &pt);
159  CU_ASSERT_DOUBLE_EQUAL(pt.x, 0.5, DBL_EPSILON);
160  CU_ASSERT_DOUBLE_EQUAL(pt.y, 0.5, DBL_EPSILON);
161 
162  lwgeom_free(env);
164 }
void lwgeom_free(LWGEOM *geom)
Definition: lwgeom.c:1144
#define LINETYPE
Definition: liblwgeom.h:86
#define POINTTYPE
LWTYPE numbers, used internally by PostGIS.
Definition: liblwgeom.h:85
int getPoint4d_p(const POINTARRAY *pa, uint32_t n, POINT4D *point)
Definition: lwgeom_api.c:123
LWPOLY * lwgeom_as_lwpoly(const LWGEOM *lwgeom)
Definition: lwgeom.c:206
int32_t rt_raster_get_srid(rt_raster raster)
Get raster's SRID.
Definition: rt_raster.c:356
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_new(uint32_t width, uint32_t height)
Construct a raster with given dimensions.
Definition: rt_raster.c:48
@ ES_NONE
Definition: librtcore.h:180
rt_errorstate rt_raster_get_envelope_geom(rt_raster raster, LWGEOM **env)
Get raster's envelope as a geometry.
Definition: rt_geometry.c:670
void rt_raster_set_offsets(rt_raster raster, double x, double y)
Set insertion points in projection units.
Definition: rt_raster.c:199
raster
Be careful!! Zeros function's input parameter can be a (height x width) array, not (width x height): ...
Definition: rtrowdump.py:121
void cu_free_raster(rt_raster raster)
uint8_t type
Definition: liblwgeom.h:399
POINTARRAY ** rings
Definition: liblwgeom.h:460
uint32_t nrings
Definition: liblwgeom.h:458
int32_t srid
Definition: liblwgeom.h:457
double x
Definition: liblwgeom.h:355
double y
Definition: liblwgeom.h:355
uint32_t npoints
Definition: liblwgeom.h:374

References cu_free_raster(), ES_NONE, getPoint4d_p(), LINETYPE, lwgeom_as_lwpoly(), lwgeom_free(), POINTARRAY::npoints, LWPOLY::nrings, POINTTYPE, rtrowdump::raster, LWPOLY::rings, rt_raster_get_envelope_geom(), rt_raster_get_srid(), rt_raster_new(), rt_raster_set_offsets(), rt_raster_set_scale(), LWPOLY::srid, LWGEOM::type, POINT4D::x, and POINT4D::y.

Referenced by raster_geometry_suite_setup().

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