17 #include "CUnit/Basic.h"
18 #include "CUnit/CUnit.h"
227 CU_ASSERT_EQUAL(loc, 0);
228 CU_ASSERT_EQUAL(dist, 0.0);
232 CU_ASSERT_EQUAL(loc, 1);
233 CU_ASSERT_EQUAL(dist, 0.0);
237 CU_ASSERT_EQUAL(loc, 1);
238 CU_ASSERT_EQUAL(dist, 1.0);
242 CU_ASSERT_EQUAL(loc, 0);
243 CU_ASSERT_EQUAL(dist, 1.0);
250 CU_ASSERT_EQUAL(loc, 0.5);
251 CU_ASSERT_EQUAL(dist, 0.0);
258 CU_ASSERT_EQUAL(loc, 0.75);
259 CU_ASSERT_EQUAL(dist, 0.0);
266 CU_ASSERT_EQUAL(loc, 0.5);
267 CU_ASSERT_EQUAL(dist, 0.0);
268 CU_ASSERT_EQUAL(l.
m, 10.0);
283 CU_ASSERT_EQUAL(ccw, 0);
289 CU_ASSERT_EQUAL(ccw, 0);
295 CU_ASSERT_EQUAL(ccw, 1);
301 CU_ASSERT_EQUAL(ccw, 1);
307 CU_ASSERT_EQUAL(ccw, 0);
313 CU_ASSERT_EQUAL(ccw, 0);
325 CU_ASSERT_DOUBLE_EQUAL(
area, 1.0, 0.0000001);
331 CU_ASSERT_DOUBLE_EQUAL(
area, 4.0, 0.0000001);
338 CU_ASSERT_DOUBLE_EQUAL(
area, -4.0, 0.0000001);
578 wkt =
"LINESTRING ZM (0 1 2 3,1 2 3 0,-2 -3 0 -1,-3 0 -1 -2)";
582 factor.
x = factor.
y = factor.
z = factor.
m = 1;
589 wkt =
"LINESTRING ZM (0 1 2 3,2 2 3 0,-4 -3 0 -1,-6 0 -1 -2)";
595 factor.
x = 1; factor.
y = 3;
596 wkt =
"LINESTRING ZM (0 3 2 3,2 6 3 0,-4 -9 0 -1,-6 0 -1 -2)";
602 factor.
x = 1; factor.
y = 1; factor.
z = -2;
603 wkt =
"LINESTRING ZM (0 3 -4 3,2 6 -6 0,-4 -9 0 -1,-6 0 2 -2)";
609 factor.
x = 1; factor.
y = 1; factor.
z = 1; factor.
m = 2;
610 wkt =
"LINESTRING ZM (0 3 -4 6,2 6 -6 0,-4 -9 0 -2,-6 0 2 -4)";
626 CU_pSuite suite = CU_add_suite(
"ptarray", NULL, NULL);
static void test_ptarrayarc_contains_point()
static void test_ptarray_contains_point()
static void test_ptarray_append_point(void)
static void test_ptarray_locate_point(void)
static char * lwgeom_to_text(const LWGEOM *geom)
static void test_ptarray_signed_area()
static void test_ptarray_scale()
static void test_ptarray_insert_point(void)
static LWGEOM * lwgeom_from_text(const char *str)
void ptarray_suite_setup(void)
static void test_ptarray_append_ptarray(void)
static void test_ptarray_isccw(void)
void cu_error_msg_reset()
char cu_error_msg[MAX_CUNIT_ERROR_LENGTH+1]
#define PG_ADD_TEST(suite, testfunc)
#define ASSERT_STRING_EQUAL(o, e)
LWLINE * lwgeom_as_lwline(const LWGEOM *lwgeom)
POINT4D getPoint4d(const POINTARRAY *pa, uint32_t n)
LWGEOM * lwline_as_lwgeom(const LWLINE *obj)
int ptarray_append_ptarray(POINTARRAY *pa1, POINTARRAY *pa2, double gap_tolerance)
Append a POINTARRAY, pa2 to the end of an existing POINTARRAY, pa1.
LWGEOM * lwgeom_from_hexwkb(const char *hexwkb, const char check)
#define LW_PARSER_CHECK_NONE
int lwgeom_parse_wkt(LWGEOM_PARSER_RESULT *parser_result, char *wktstr, int parse_flags)
Parse a WKT geometry string into an LWGEOM structure.
double ptarray_locate_point(const POINTARRAY *pa, const POINT4D *pt, double *dist, POINT4D *p_located)
int ptarray_insert_point(POINTARRAY *pa, const POINT4D *p, uint32_t where)
Insert a point into an existing POINTARRAY.
char * lwgeom_to_wkt(const LWGEOM *geom, uint8_t variant, int precision, size_t *size_out)
WKT emitter function.
int ptarray_append_point(POINTARRAY *pa, const POINT4D *pt, int allow_duplicates)
Append a point to the end of an existing POINTARRAY If allow_duplicate is LW_FALSE,...
#define FLAGS_SET_READONLY(flags, value)
void lwpoly_free(LWPOLY *poly)
#define LW_TRUE
Return types for functions with status returns.
LWPOLY * lwgeom_as_lwpoly(const LWGEOM *lwgeom)
void lwline_free(LWLINE *line)
#define LW_INSIDE
Constants for point-in-polygon return values.
int ptarrayarc_contains_point(const POINTARRAY *pa, const POINT2D *pt)
For POINTARRAYs representing CIRCULARSTRINGS.
double ptarray_signed_area(const POINTARRAY *pa)
Returns the area in cartesian units.
void ptarray_scale(POINTARRAY *pa, const POINT4D *factor)
WARNING, make sure you send in only 16-member double arrays or obviously things will go pear-shaped f...
int ptarray_contains_point(const POINTARRAY *pa, const POINT2D *pt)
Return 1 if the point is inside the POINTARRAY, -1 if it is outside, and 0 if it is on the boundary.
int ptarray_isccw(const POINTARRAY *pa)
Datum area(PG_FUNCTION_ARGS)
Parser result structure: returns the result of attempting to convert (E)WKT/(E)WKB to LWGEOM.