24 #include "CUnit/Basic.h"
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);
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);
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);
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);
263 LWGEOM *gexpected, *gobserved;
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);
295 CU_ASSERT(mpoly != NULL);
307 CU_ASSERT(mpoly != NULL);
309 gexpected =
lwgeom_from_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)))",
320 CU_ASSERT(mpoly != NULL);
323 "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)))",
334 CU_ASSERT(mpoly != NULL);
337 "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)))",
348 CU_ASSERT(mpoly != NULL);
351 "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)))",
365 CU_ASSERT(mpoly != NULL);
368 "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)))",
388 CU_ASSERT(
rast != NULL);
394 CU_ASSERT(
band != NULL);
396 for (
y = 0;
y < maxY;
y++) {
397 for (
x = 0;
x < maxX;
x++) {
404 CU_ASSERT(geom != NULL);
406 CU_ASSERT_STRING_EQUAL(wkt,
"POLYGON((0 0,5 0,5 -5,0 -5,0 0))");
420 CU_ASSERT(geom != NULL);
422 CU_ASSERT_STRING_EQUAL(wkt,
"POLYGON((0 -1,5 -1,5 -5,0 -5,0 -1))");
436 CU_ASSERT(geom != NULL);
438 CU_ASSERT_STRING_EQUAL(wkt,
"POLYGON((0 -1,4 -1,4 -5,0 -5,0 -1))");
452 CU_ASSERT(geom != NULL);
454 CU_ASSERT_STRING_EQUAL(wkt,
"POLYGON((0 -1,4 -1,4 -4,0 -4,0 -1))");
468 CU_ASSERT(geom != NULL);
470 CU_ASSERT_STRING_EQUAL(wkt,
"POLYGON((1 -1,4 -1,4 -4,1 -4,1 -1))");
489 CU_ASSERT(geom != NULL);
491 CU_ASSERT_STRING_EQUAL(wkt,
"POLYGON((2 -1,3 -1,3 -4,2 -4,2 -1))");
502 CU_ASSERT(geom != NULL);
504 CU_ASSERT_STRING_EQUAL(wkt,
"POLYGON((2 -2,3 -2,3 -3,2 -3,2 -2))");
511 CU_ASSERT(
band != NULL);
513 for (
y = 0;
y < maxY;
y++) {
514 for (
x = 0;
x < maxX;
x++) {
521 CU_ASSERT(geom != NULL);
523 CU_ASSERT_STRING_EQUAL(wkt,
"POLYGON((0 0,5 0,5 -5,0 -5,0 0))");
540 CU_ASSERT(
rast != NULL);
543 CU_ASSERT(
band != NULL);
545 for (
x = 0;
x < maxX;
x++) {
546 for (
y = 0;
y < maxY;
y++) {
570 CU_ASSERT(poly != NULL);
580 CU_pSuite suite = CU_add_suite(
"raster_geometry", NULL, NULL);
static void test_raster_surface()
static void test_raster_envelope()
static void test_raster_convex_hull()
static void test_raster_envelope_geom()
static void test_raster_pixel_as_polygon()
static void test_raster_perimeter()
static char * lwgeom_to_text(const LWGEOM *lwgeom)
void raster_geometry_suite_setup(void)
#define PG_ADD_TEST(suite, testfunc)
void lwgeom_free(LWGEOM *geom)
#define LW_PARSER_CHECK_NONE
void lwmpoly_free(LWMPOLY *mpoly)
LWGEOM * lwmpoly_as_lwgeom(const LWMPOLY *obj)
#define POINTTYPE
LWTYPE numbers, used internally by PostGIS.
double lwgeom_area(const LWGEOM *geom)
int getPoint4d_p(const POINTARRAY *pa, uint32_t n, POINT4D *point)
char * lwgeom_to_wkt(const LWGEOM *geom, uint8_t variant, int precision, size_t *size_out)
WKT emitter function.
LWGEOM * lwgeom_from_wkt(const char *wkt, const char check)
void lwpoly_free(LWPOLY *poly)
LWPOLY * lwgeom_as_lwpoly(const LWGEOM *lwgeom)
int32_t rt_raster_get_srid(rt_raster raster)
Get raster's SRID.
void rt_raster_set_scale(rt_raster raster, double scaleX, double scaleY)
Set scale in projection units.
LWPOLY * rt_raster_pixel_as_polygon(rt_raster raster, int x, int y)
Get a raster pixel as a polygon.
void rt_raster_set_skews(rt_raster raster, double skewX, double skewY)
Set skews about the X and Y axis.
rt_errorstate rt_raster_surface(rt_raster raster, int nband, LWMPOLY **surface)
Get a raster as a surface (multipolygon).
rt_raster rt_raster_new(uint32_t width, uint32_t height)
Construct a raster with given dimensions.
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_convex_hull(rt_raster raster, LWGEOM **hull)
Get raster's convex hull.
void rtdealloc(void *mem)
rt_errorstate rt_raster_get_envelope_geom(rt_raster raster, LWGEOM **env)
Get raster's envelope as a geometry.
rt_errorstate rt_raster_get_perimeter(rt_raster raster, int nband, LWGEOM **perimeter)
Get raster perimeter.
rt_errorstate rt_raster_get_envelope(rt_raster raster, rt_envelope *env)
Get raster's envelope.
void rt_raster_set_offsets(rt_raster raster, double x, double y)
Set insertion points in projection units.
raster
Be careful!! Zeros function's input parameter can be a (height x width) array, not (width x height): ...
rt_band cu_add_band(rt_raster raster, rt_pixtype pixtype, int hasnodata, double nodataval)
void cu_free_raster(rt_raster raster)