24 #include "CUnit/Basic.h" 33 CU_ASSERT(raster != NULL);
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);
47 CU_ASSERT(raster != NULL);
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);
61 CU_ASSERT(raster != NULL);
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);
75 CU_ASSERT(raster != NULL);
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);
97 CU_ASSERT(env == NULL);
101 CU_ASSERT(raster != NULL);
110 CU_ASSERT(raster != NULL);
119 CU_ASSERT(raster != NULL);
128 CU_ASSERT(raster != NULL);
136 CU_ASSERT_EQUAL(poly->
nrings, 1);
138 ring = poly->
rings[0];
139 CU_ASSERT(ring != NULL);
140 CU_ASSERT_EQUAL(ring->
npoints, 5);
143 CU_ASSERT_DOUBLE_EQUAL(pt.
x, 0.5, DBL_EPSILON);
144 CU_ASSERT_DOUBLE_EQUAL(pt.
y, 0.5, DBL_EPSILON);
147 CU_ASSERT_DOUBLE_EQUAL(pt.
x, 5.5, DBL_EPSILON);
148 CU_ASSERT_DOUBLE_EQUAL(pt.
y, 0.5, DBL_EPSILON);
151 CU_ASSERT_DOUBLE_EQUAL(pt.
x, 5.5, DBL_EPSILON);
152 CU_ASSERT_DOUBLE_EQUAL(pt.
y, -4.5, DBL_EPSILON);
155 CU_ASSERT_DOUBLE_EQUAL(pt.
x, 0.5, DBL_EPSILON);
156 CU_ASSERT_DOUBLE_EQUAL(pt.
y, -4.5, DBL_EPSILON);
159 CU_ASSERT_DOUBLE_EQUAL(pt.
x, 0.5, DBL_EPSILON);
160 CU_ASSERT_DOUBLE_EQUAL(pt.
y, 0.5, DBL_EPSILON);
175 CU_ASSERT(hull == NULL);
179 CU_ASSERT(raster != NULL);
188 CU_ASSERT(raster != NULL);
197 CU_ASSERT(raster != NULL);
206 CU_ASSERT(raster != NULL);
215 CU_ASSERT_EQUAL(poly->
nrings, 1);
217 ring = poly->
rings[0];
218 CU_ASSERT(ring != NULL);
219 CU_ASSERT_EQUAL(ring->
npoints, 5);
222 CU_ASSERT_DOUBLE_EQUAL(pt.
x, 0.5, DBL_EPSILON);
223 CU_ASSERT_DOUBLE_EQUAL(pt.
y, 0.5, DBL_EPSILON);
226 CU_ASSERT_DOUBLE_EQUAL(pt.
x, 256.5, DBL_EPSILON);
227 CU_ASSERT_DOUBLE_EQUAL(pt.
y, 1280.5, DBL_EPSILON);
230 CU_ASSERT_DOUBLE_EQUAL(pt.
x, 1280.5, DBL_EPSILON);
231 CU_ASSERT_DOUBLE_EQUAL(pt.
y, 1536.5, DBL_EPSILON);
234 CU_ASSERT_DOUBLE_EQUAL(pt.
x, 1024.5, DBL_EPSILON);
235 CU_ASSERT_DOUBLE_EQUAL(pt.
y, 256.5, DBL_EPSILON);
238 CU_ASSERT_DOUBLE_EQUAL(pt.
x, 0.5, DBL_EPSILON);
239 CU_ASSERT_DOUBLE_EQUAL(pt.
y, 0.5, DBL_EPSILON);
266 CU_ASSERT(rast != NULL);
272 CU_ASSERT(band != NULL);
274 for (y = 0; y < maxY; y++) {
275 for (x = 0; x < maxX; x++) {
282 CU_ASSERT(mpoly != NULL);
284 CU_ASSERT_STRING_EQUAL(wkt,
"MULTIPOLYGON(((0 0,0 -5,5 -5,5 0,0 0)))");
294 CU_ASSERT(mpoly != NULL);
296 CU_ASSERT_STRING_EQUAL(wkt,
"MULTIPOLYGON(((1 0,1 -1,0 -1,0 -5,4 -5,5 -5,5 0,1 0)))");
306 CU_ASSERT(mpoly != NULL);
308 CU_ASSERT_STRING_EQUAL(wkt,
"MULTIPOLYGON(((1 0,1 -1,0 -1,0 -5,4 -5,5 -5,5 0,1 0),(1 -1,1 -2,2 -2,2 -1,1 -1)))");
318 CU_ASSERT(mpoly != NULL);
321 CU_ASSERT_STRING_EQUAL(wkt,
"MULTIPOLYGON(((1 -1,1 0,5 0,5 -5,4 -5,0 -5,0 -1,1 -1),(1 -1,1 -2,2 -2,2 -1,1 -1),(2 -2,2 -3,3 -3,3 -2,2 -2)))");
332 CU_ASSERT(mpoly != NULL);
335 CU_ASSERT_STRING_EQUAL(wkt,
"MULTIPOLYGON(((1 -1,1 0,5 0,5 -5,4 -5,0 -5,0 -1,1 -1),(1 -1,1 -2,2 -2,2 -1,1 -1),(2 -2,2 -3,3 -3,3 -2,2 -2),(3 -3,3 -4,4 -4,4 -3,3 -3)))");
346 CU_ASSERT(mpoly != NULL);
348 CU_ASSERT_STRING_EQUAL(wkt,
"MULTIPOLYGON(((4 -4,4 -5,0 -5,0 -1,1 -1,1 -2,2 -2,2 -3,3 -3,3 -4,4 -4)),((1 -1,1 0,5 0,5 -4,4 -4,4 -3,3 -3,3 -2,2 -2,2 -1,1 -1)))");
361 CU_ASSERT(mpoly != NULL);
363 CU_ASSERT_STRING_EQUAL(wkt,
"MULTIPOLYGON(((1 -4,2 -4,2 -3,3 -3,3 -4,4 -4,4 -5,3 -5,1 -5,1 -4)),((1 -4,0 -4,0 -1,1 -1,1 -2,2 -2,2 -3,1 -3,1 -4)),((3 -2,4 -2,4 -1,5 -1,5 -4,4 -4,4 -3,3 -3,3 -2)),((3 -2,2 -2,2 -1,1 -1,1 0,4 0,4 -1,3 -1,3 -2)))");
382 CU_ASSERT(rast != NULL);
388 CU_ASSERT(band != NULL);
390 for (y = 0; y < maxY; y++) {
391 for (x = 0; x < maxX; x++) {
398 CU_ASSERT(geom != NULL);
400 CU_ASSERT_STRING_EQUAL(wkt,
"POLYGON((0 0,5 0,5 -5,0 -5,0 0))");
414 CU_ASSERT(geom != NULL);
416 CU_ASSERT_STRING_EQUAL(wkt,
"POLYGON((0 -1,5 -1,5 -5,0 -5,0 -1))");
430 CU_ASSERT(geom != NULL);
432 CU_ASSERT_STRING_EQUAL(wkt,
"POLYGON((0 -1,4 -1,4 -5,0 -5,0 -1))");
446 CU_ASSERT(geom != NULL);
448 CU_ASSERT_STRING_EQUAL(wkt,
"POLYGON((0 -1,4 -1,4 -4,0 -4,0 -1))");
462 CU_ASSERT(geom != NULL);
464 CU_ASSERT_STRING_EQUAL(wkt,
"POLYGON((1 -1,4 -1,4 -4,1 -4,1 -1))");
483 CU_ASSERT(geom != NULL);
485 CU_ASSERT_STRING_EQUAL(wkt,
"POLYGON((2 -1,3 -1,3 -4,2 -4,2 -1))");
496 CU_ASSERT(geom != NULL);
498 CU_ASSERT_STRING_EQUAL(wkt,
"POLYGON((2 -2,3 -2,3 -3,2 -3,2 -2))");
505 CU_ASSERT(band != NULL);
507 for (y = 0; y < maxY; y++) {
508 for (x = 0; x < maxX; x++) {
515 CU_ASSERT(geom != NULL);
517 CU_ASSERT_STRING_EQUAL(wkt,
"POLYGON((0 0,5 0,5 -5,0 -5,0 0))");
534 CU_ASSERT(rast != NULL);
537 CU_ASSERT(band != NULL);
539 for (x = 0; x < maxX; x++) {
540 for (y = 0; y < maxY; y++) {
564 CU_ASSERT(poly != NULL);
574 CU_pSuite suite = CU_add_suite(
"raster_geometry", NULL, NULL);
static void test_raster_envelope_geom()
static void test_raster_surface()
char * lwgeom_to_wkt(const LWGEOM *geom, uint8_t variant, int precision, size_t *size_out)
WKT emitter function.
raster
Be careful!! Zeros function's input parameter can be a (height x width) array, not (width x height): ...
void rt_raster_set_skews(rt_raster raster, double skewX, double skewY)
Set skews about the X and Y axis.
void lwgeom_free(LWGEOM *geom)
LWPOLY * lwgeom_as_lwpoly(const LWGEOM *lwgeom)
rt_errorstate rt_raster_get_convex_hull(rt_raster raster, LWGEOM **hull)
Get raster's convex hull.
void cu_free_raster(rt_raster raster)
rt_band cu_add_band(rt_raster raster, rt_pixtype pixtype, int hasnodata, double nodataval)
rt_errorstate rt_raster_surface(rt_raster raster, int nband, LWMPOLY **surface)
Get a raster as a surface (multipolygon).
void lwmpoly_free(LWMPOLY *mpoly)
static void test_raster_convex_hull()
void lwpoly_free(LWPOLY *poly)
void rt_raster_set_scale(rt_raster raster, double scaleX, double scaleY)
Set scale in projection units.
void rt_raster_set_offsets(rt_raster raster, double x, double y)
Set insertion points in projection units.
#define PG_ADD_TEST(suite, testfunc)
static void test_raster_pixel_as_polygon()
static void test_raster_envelope()
static void test_raster_perimeter()
LWPOLY * rt_raster_pixel_as_polygon(rt_raster raster, int x, int y)
Get a raster pixel as a polygon.
rt_errorstate rt_raster_get_envelope_geom(rt_raster raster, LWGEOM **env)
Get raster's envelope as a geometry.
int32_t rt_raster_get_srid(rt_raster raster)
Get raster's SRID.
rt_raster rt_raster_new(uint32_t width, uint32_t height)
Construct a raster with given dimensions.
void rtdealloc(void *mem)
#define POINTTYPE
LWTYPE numbers, used internally by PostGIS.
rt_errorstate rt_band_set_pixel(rt_band band, int x, int y, double val, int *converted)
Set single pixel's value.
rt_errorstate rt_raster_get_perimeter(rt_raster raster, int nband, LWGEOM **perimeter)
Get raster perimeter.
void raster_geometry_suite_setup(void)
static char * lwgeom_to_text(const LWGEOM *lwgeom)
LWGEOM * lwmpoly_as_lwgeom(const LWMPOLY *obj)
rt_errorstate rt_raster_get_envelope(rt_raster raster, rt_envelope *env)
Get raster's envelope.
int getPoint4d_p(const POINTARRAY *pa, int n, POINT4D *point)