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);
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)";
628 wkt =
"LINESTRING ZM (1 1 1 1,2 2 2 2,3 3 3 3,4 4 4 4,1 1 1 1)";
632 scroll.
x = scroll.
y = scroll.
z = scroll.
m = 2;
636 wkt =
"LINESTRING ZM (2 2 2 2,3 3 3 3,4 4 4 4,1 1 1 1,2 2 2 2)";
640 scroll.
x = scroll.
y = scroll.
z = scroll.
m = 1;
644 wkt =
"LINESTRING ZM (1 1 1 1,2 2 2 2,3 3 3 3,4 4 4 4,1 1 1 1)";
648 scroll.
x = scroll.
y = scroll.
z = scroll.
m = 9;
665 wkt =
"LINESTRING (0 0 0, 1 0 0, 2 0 0, 3 0 10)";
697 wkt =
"LINESTRING (0 0 0, 1 0 0, 2 0 0, 3 0 10)";
726 wkt =
"LINESTRING(4 31,7 31,7 34,4 34,4 31)";
729 qp.
x = 7.1; qp.
y = 31.1;
739 s0.
x = s0.
y = 0; s0.
z = 10; s0.
m = 20;
740 s1.
x = 0; s1.
y = 10; s1.
z = 0; s1.
m = 10;
744 qp.
x = -0.1; qp.
y = 0;
751 qp.
x = 0.1; qp.
y = 0;
758 qp.
x = 0; qp.
y = -0.1;
767 qp.
x = 0; qp.
y = 10.1;
774 qp.
x = 0.1; qp.
y = 10;
781 qp.
x = -0.1; qp.
y = 10;
790 qp.
x = 0.1; qp.
y = 5;
797 qp.
x = -0.1; qp.
y = 5;
804 qp.
x = 0.1; qp.
y = 2;
811 qp.
x = -0.1; qp.
y = 2;
818 qp.
x = 0.1; qp.
y = 8;
825 qp.
x = -0.1; qp.
y = 8;
842 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_closest_point_on_segment(void)
static void test_ptarray_signed_area()
static void test_ptarray_closest_segment_2d()
static void test_ptarray_scroll()
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_closest_vertex_2d()
static void test_ptarray_isccw(void)
void cu_error_msg_reset()
char cu_error_msg[MAX_CUNIT_ERROR_LENGTH+1]
#define ASSERT_DOUBLE_EQUAL_TOLERANCE(o, e, t)
#define ASSERT_DOUBLE_EQUAL(o, e)
#define ASSERT_INT_EQUAL(o, e)
#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_closest_segment_2d(const POINTARRAY *pa, const POINT2D *qp, double *dist)
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)
int ptarray_closest_vertex_2d(const POINTARRAY *pa, const POINT2D *qp, double *dist)
#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.
int ptarray_scroll_in_place(POINTARRAY *pa, const POINT4D *newbase)
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)
void closest_point_on_segment(const POINT4D *R, const POINT4D *A, const POINT4D *B, POINT4D *ret)
Parser result structure: returns the result of attempting to convert (E)WKT/(E)WKB to LWGEOM.