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);
375 in =
lwgeom_from_text(
"COMPOUNDCURVE(CIRCULARSTRING(-1 0,0 1,0 -1),(0 -1,-1 -1))");
382 ASSERT_STRING_EQUAL(str,
"COMPOUNDCURVE(CIRCULARSTRING(-1 0,0.70710678 0.70710678,0 -1),(0 -1,-1 -1))");
387 in =
lwgeom_from_text(
"COMPOUNDCURVE((-3 -3,-1 0),CIRCULARSTRING(-1 0,0 1,0 -1),(0 -1,0 -1.5,0 -2),CIRCULARSTRING(0 -2,-1 -3,1 -3),(1 -3,5 5))");
394 ASSERT_STRING_EQUAL(str,
"COMPOUNDCURVE((-3 -3,-1 0),CIRCULARSTRING(-1 0,0.70710678 0.70710678,0 -1),(0 -1,0 -1.5,0 -2),CIRCULARSTRING(0 -2,-0.70710678 -3.7071068,1 -3),(1 -3,5 5))");
399 in =
lwgeom_from_text(
"COMPOUNDCURVE(CIRCULARSTRING(-1 0,0 1,0 -1),CIRCULARSTRING(0 -1,-1 -2,1 -2))");
406 ASSERT_STRING_EQUAL(str,
"COMPOUNDCURVE(CIRCULARSTRING(-1 0,0.70710678 0.70710678,0 -1),CIRCULARSTRING(0 -1,-0.70710678 -2.7071068,1 -2))");
411 in =
lwgeom_from_text(
"COMPOUNDCURVE((0 0, 1 1), CIRCULARSTRING(1 1, 2 2, 3 1), (3 1, 4 4))");
417 ASSERT_STRING_EQUAL(str,
"COMPOUNDCURVE((0 0,1 1),CIRCULARSTRING(1 1,2 2,3 1),(3 1,4 4))");
698 wkt =
"LINESTRING ZM (0 1 2 3,1 2 3 0,-2 -3 0 -1,-3 0 -1 -2)";
702 factor.
x = factor.
y = factor.
z = factor.
m = 1;
709 wkt =
"LINESTRING ZM (0 1 2 3,2 2 3 0,-4 -3 0 -1,-6 0 -1 -2)";
715 factor.
x = 1; factor.
y = 3;
716 wkt =
"LINESTRING ZM (0 3 2 3,2 6 3 0,-4 -9 0 -1,-6 0 -1 -2)";
722 factor.
x = 1; factor.
y = 1; factor.
z = -2;
723 wkt =
"LINESTRING ZM (0 3 -4 3,2 6 -6 0,-4 -9 -0 -1,-6 0 2 -2)";
729 factor.
x = 1; factor.
y = 1; factor.
z = 1; factor.
m = 2;
730 wkt =
"LINESTRING ZM (0 3 -4 6,2 6 -6 0,-4 -9 -0 -2,-6 0 2 -4)";
746 CU_pSuite suite = CU_add_suite(
"ptarray", NULL, NULL);
LWGEOM * lwgeom_stroke(const LWGEOM *geom, uint32_t perQuad)
char * lwgeom_to_wkt(const LWGEOM *geom, uint8_t variant, int precision, size_t *size_out)
WKT emitter function.
static void test_ptarray_scale()
void ptarray_scale(POINTARRAY *pa, const POINT4D *factor)
Scale a pointarray.
#define ASSERT_STRING_EQUAL(o, e)
Datum area(PG_FUNCTION_ARGS)
void lwgeom_free(LWGEOM *geom)
int ptarrayarc_contains_point(const POINTARRAY *pa, const POINT2D *pt)
For POINTARRAYs representing CIRCULARSTRINGS.
void lwline_free(LWLINE *line)
static void test_ptarray_isccw(void)
LWPOLY * lwgeom_as_lwpoly(const LWGEOM *lwgeom)
static void test_ptarray_append_ptarray(void)
void ptarray_suite_setup(void)
double ptarray_signed_area(const POINTARRAY *pa)
Returns the area in cartesian units.
static void test_ptarray_insert_point(void)
#define LW_PARSER_CHECK_NONE
double ptarray_locate_point(const POINTARRAY *pa, const POINT4D *pt, double *dist, POINT4D *p_located)
static LWGEOM * lwgeom_from_text(const char *str)
POINT4D getPoint4d(const POINTARRAY *pa, int n)
int ptarray_isccw(const POINTARRAY *pa)
LWGEOM * lwline_as_lwgeom(const LWLINE *obj)
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, then a duplicate point will not be added.
int lwgeom_parse_wkt(LWGEOM_PARSER_RESULT *parser_result, char *wktstr, int parse_flags)
Parse a WKT geometry string into an LWGEOM structure.
void lwpoly_free(LWPOLY *poly)
void cu_error_msg_reset()
static char * lwgeom_to_text(const LWGEOM *geom)
#define LW_TRUE
Return types for functions with status returns.
Parser result structure: returns the result of attempting to convert (E)WKT/(E)WKB to LWGEOM...
#define PG_ADD_TEST(suite, testfunc)
int ptarray_append_ptarray(POINTARRAY *pa1, POINTARRAY *pa2, double gap_tolerance)
Append a POINTARRAY, pa2 to the end of an existing POINTARRAY, pa1.
#define LW_INSIDE
Constants for point-in-polygon return values.
static void test_ptarray_unstroke()
int ptarray_insert_point(POINTARRAY *pa, const POINT4D *p, int where)
Insert a point into an existing POINTARRAY.
static void test_ptarray_locate_point(void)
LWLINE * lwgeom_as_lwline(const LWGEOM *lwgeom)
LWGEOM * lwgeom_from_hexwkb(const char *hexwkb, const char check)
static void test_ptarrayarc_contains_point()
static void test_ptarray_contains_point()
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...
LWGEOM * lwgeom_unstroke(const LWGEOM *geom)
char cu_error_msg[MAX_CUNIT_ERROR_LENGTH+1]
static void test_ptarray_append_point(void)
static void test_ptarray_signed_area()
#define FLAGS_SET_READONLY(flags, value)