16 #include "CUnit/Basic.h"
90 CU_ASSERT_EQUAL(rv, 0);
110 CU_ASSERT_DOUBLE_EQUAL(d1, 0.0046097720751, 0.0001);
111 CU_ASSERT_DOUBLE_EQUAL(c1.
x, 2047538.599, 0.001);
112 CU_ASSERT_DOUBLE_EQUAL(c1.
y, 7268770.4395, 0.001);
123 #define setpoint(p, x1, y1) {(p).x = (x1); (p).y = (y1);}
409 CU_ASSERT_EQUAL( p.
x, 1.5 );
412 CU_ASSERT_EQUAL( p.
m, 2.5 );
415 CU_ASSERT_EQUAL( p.
z, 3.5 );
452 CU_ASSERT_EQUAL(
r.x, 15.0);
456 CU_ASSERT_EQUAL(
r.y, 21.0);
460 CU_ASSERT_EQUAL(
r.y, 30.0);
464 CU_ASSERT_EQUAL(
r.y, 20.0);
567 CU_ASSERT_DOUBLE_EQUAL(point.
x, 0, 0.0001);
568 CU_ASSERT_DOUBLE_EQUAL(point.
y, 0, 0.001);
569 CU_ASSERT_DOUBLE_EQUAL(point.
z, 0, 0.001);
575 CU_ASSERT_DOUBLE_EQUAL(point.
x, 2, 0.0001);
576 CU_ASSERT_DOUBLE_EQUAL(point.
y, 2, 0.001);
577 CU_ASSERT_DOUBLE_EQUAL(point.
z, 2, 0.001);
583 CU_ASSERT_DOUBLE_EQUAL(point.
x, 1, 0.0001);
584 CU_ASSERT_DOUBLE_EQUAL(point.
y, 1, 0.001);
585 CU_ASSERT_DOUBLE_EQUAL(point.
z, 1, 0.001);
591 CU_ASSERT_DOUBLE_EQUAL(point.
x, 1.6, 0.0001);
592 CU_ASSERT_DOUBLE_EQUAL(point.
y, 1.6, 0.001);
593 CU_ASSERT_DOUBLE_EQUAL(point.
z, 1.6, 0.001);
715 "POLYGON ((0.51 -0.25, 1.27 -0.14, 1.27 0.25, 0.6 0.3, 0.7 0.7, 1.2 0.7, 0.8 0.5, 1.3 0.4, 1.2 1.2, 0.5 1.2, 0.5 -0.1, 0.3 -0.1, 0.3 1.3, -0.18 1.25, -0.17 -0.25, 0.51 -0.25))",
723 "MULTIPOLYGON(((0.51 -0.25,1 -0.179078947368,1 0.270149253731,0.6 0.3,0.7 0.7,1 0.7,1 0.6,0.8 0.5,1 0.46,1 1.2,0.5 1.2,0.5 -0.1,0.3 -0.1,0.3 1.3,0 1.26875,0 -0.25,0.51 -0.25)))");
729 "MULTIPOLYGON(((0.51 -0.25,1 -0.179078947368,1 0.270149253731,0.6 0.3,0.7 0.7,1 0.7,1 0.6,0.8 0.5,1 0.46,1 1.2,0.5 1.2,0.5 -0.1,0.3 -0.1,0.3 1.3,0 1.26875,0 -0.25,0.51 -0.25)))",
737 "MULTIPOLYGON(((1 0,1 0.270149253731,0.6 0.3,0.7 0.7,1 0.7,1 0.6,0.8 0.5,1 0.46,1 1,0.5 1,0.5 0,0.3 0,0.3 1,0 1,0 0,1 0)))");
777 "TIN(((1 1 1,2 1.5 2,2 1.333333333333 2,1 1 1)),((1 1 1,2 1.333333333333 2,1 0.666666666667 1,1 1 1)))");
783 "TIN Z (((0 0 2,0 1 2,-1 2 2,0 0 2)),((0 1 2,0 0 2,0 1 4,0 1 2)),((-1 2 2,0 1 2,1 1 2,-1 2 2)),((0 0 2,-1 2 2,-1 -1 2,0 0 2)),((0 1 4,0 0 2,0 0 4,0 1 4)),((0 1 2,0 1 4,1 1 4,0 1 2)),((1 1 2,0 1 2,1 1 4,1 1 2)),((-1 2 2,1 1 2,2 2 2,-1 2 2)),((-1 -1 2,-1 2 2,-1 -1 -1,-1 -1 2)),((0 0 2,-1 -1 2,1 0 2,0 0 2)),((0 0 4,0 0 2,1 0 2,0 0 4)),((0 1 4,0 0 4,1 0 4,0 1 4)),((1 1 4,0 1 4,1 0 4,1 1 4)),((1 1 2,1 1 4,1 0 4,1 1 2)),((2 2 2,1 1 2,2 -1 2,2 2 2)),((-1 2 2,2 2 2,-1 2 -1,-1 2 2)),((-1 -1 -1,-1 2 2,-1 2 -1,-1 -1 -1)),((-1 -1 2,-1 -1 -1,2 -1 -1,-1 -1 2)),((1 0 2,-1 -1 2,2 -1 2,1 0 2)),((0 0 4,1 0 2,1 0 4,0 0 4)),((1 1 2,1 0 4,1 0 2,1 1 2)),((2 -1 2,1 1 2,1 0 2,2 -1 2)),((2 2 2,2 -1 2,2 2 -1,2 2 2)),((-1 2 -1,2 2 2,2 2 -1,-1 2 -1)),((-1 -1 -1,-1 2 -1,2 2 -1,-1 -1 -1)),((2 -1 -1,-1 -1 -1,2 2 -1,2 -1 -1)),((-1 -1 2,2 -1 -1,2 -1 2,-1 -1 2)),((2 2 -1,2 -1 2,2 -1 -1,2 2 -1)))",
791 "TIN(((0 0 2,0 1 2,-1 2 2,0 0 2)),((0 1 2,0 0 2,0 1 4,0 1 2)),((-1 2 2,0 1 2,1 1 2,-1 2 2)),((0 0 2,-1 2 2,-1 -1 2,0 0 2)),((0 1 4,0 0 2,0 0 4,0 1 4)),((0 1 2,0 1 4,1 1 4,0 1 2)),((1 1 2,0 1 2,1 1 4,1 1 2)),((-1 2 2,1 1 2,2 2 2,-1 2 2)),((-1 -1 2,-1 2 2,-1 0 0,-1 -1 2)),((-1 -1 2,-1 0 0,-1 -1 0,-1 -1 2)),((0 0 2,-1 -1 2,1 0 2,0 0 2)),((0 0 4,0 0 2,1 0 2,0 0 4)),((0 1 4,0 0 4,1 0 4,0 1 4)),((1 1 4,0 1 4,1 0 4,1 1 4)),((1 1 2,1 1 4,1 0 4,1 1 2)),((2 2 2,1 1 2,2 -1 2,2 2 2)),((-1 2 2,2 2 2,0 2 0,-1 2 2)),((-1 2 2,0 2 0,-1 2 0,-1 2 2)),((-1 0 0,-1 2 2,-1 2 0,-1 0 0)),((-1 -1 2,-1 -1 0,1 -1 0,-1 -1 2)),((1 0 2,-1 -1 2,2 -1 2,1 0 2)),((0 0 4,1 0 2,1 0 4,0 0 4)),((1 1 2,1 0 4,1 0 2,1 1 2)),((2 -1 2,1 1 2,1 0 2,2 -1 2)),((2 2 2,2 -1 2,2 1 0,2 2 2)),((2 2 2,2 1 0,2 2 0,2 2 2)),((0 2 0,2 2 2,2 2 0,0 2 0)),((-1 -1 2,1 -1 0,2 -1 0,-1 -1 2)),((-1 -1 2,2 -1 0,2 -1 2,-1 -1 2)),((2 1 0,2 -1 2,2 -1 0,2 1 0)))");
821 mline =
lwgeom_from_wkt(
"MULTILINESTRING((1 0,1 1,1 2,1 3,1 4), (0 0,0 1,0 2,0 3,0 4))",
LW_PARSER_CHECK_NONE);
836 lwgeom_from_wkt(
"MULTILINESTRING((1 0,1 -1,1 -2,1 -3,1 -4), (0 0,0 1,0 2,0 3,0 4))",
LW_PARSER_CHECK_NONE);
850 line =
lwgeom_from_wkt(
"LINESTRING(0 0 0 0,1 1 1 1,2 2 2 2,3 3 3 3,4 4 4 4,3 3 3 5,2 2 2 6,1 1 1 7,0 0 0 8)",
856 ASSERT_STRING_EQUAL(ewkt,
"MULTILINESTRING((3 3 3 3,3.5 3.5 3.5 3.5),(3.5 3.5 3.5 4.5,3 3 3 5))");
864 "MULTILINESTRING((2 2 2 2,3 3 3 3,3.5 3.5 3.5 3.5),(3.5 3.5 3.5 4.5,3 3 3 5,2 2 2 6))");
978 char *geohash = NULL;
1125 unsigned long long rs;
1130 CU_ASSERT_EQUAL(gh, rs);
1131 p.
x = 140; p.
y = 45;
1134 CU_ASSERT_EQUAL(gh, rs);
1135 p.
x = 140; p.
y = 55;
1138 CU_ASSERT_EQUAL(gh, rs);
1144 double lat[2], lon[2];
1148 CU_ASSERT_DOUBLE_EQUAL(lat[0], 48, 1e-11);
1149 CU_ASSERT_DOUBLE_EQUAL(lat[1], 48, 1e-11);
1150 CU_ASSERT_DOUBLE_EQUAL(lon[0], -126, 1e-11);
1151 CU_ASSERT_DOUBLE_EQUAL(lon[1], -126, 1e-11);
1164 g =
lwgeom_from_wkt(
"MULTIPOINT(0 0, 10 0, 10 10, 10 10, 0 10, 0 10, 0 10, 0 0, 0 0, 0 0, 5 5, 0 0, 5 5)",
LW_PARSER_CHECK_NONE);
1176 ASSERT_STRING_EQUAL(ewkt,
"LINESTRING(1612830.15445 4841287.12672,1612829.98813 4841274.56198)");
1180 g =
lwgeom_from_wkt(
"MULTIPOINT(0 0,10 0,10 10,10 10,0 10,0 10,0 10,0 0,0 0,0 0,5 5,5 5,5 8,8 8,8 8,8 8,8 5,8 5,5 5,5 5,5 5,5 5,5 5,50 50,50 50,50 50,50 60,50 60,50 60,60 60,60 50,60 50,50 50,55 55,55 58,58 58,58 55,58 55,55 55)",
LW_PARSER_CHECK_NONE);
1185 ewkt,
"MULTIPOINT(0 0,10 0,10 10,0 10,5 5,5 8,8 8,8 5,50 50,50 60,60 60,60 50,55 55,55 58,58 58,58 55)");
1216 g =
lwgeom_from_wkt(
"POLYGON((0 0,0 1,1 1,1 0,0 0), (0.4 0.4, 0.4 0.4, 0.4 0.5, 0.5 0.5, 0.5 0.4, 0.4 0.4))",
1221 ASSERT_STRING_EQUAL(ewkt,
"POLYGON((0 0,0 1,1 1,1 0,0 0),(0.4 0.4,0.5 0.5,0.5 0.4,0.4 0.4))");
1229 ASSERT_STRING_EQUAL(ewkt,
"GEOMETRYCOLLECTION(POINT(2 0),POLYGON((0 0,1 0,1 1,0 1,0 0)))");
1277 CU_ASSERT_EQUAL(l, NULL);
1284 CU_ASSERT_EQUAL(l, NULL);
1309 "(0 0, 100 0, 100 100, 0 100, 0 0),"
1310 "(1 1, 1 5, 5 5, 5 1, 1 1),"
1311 "(20 20, 20 40, 40 40, 40 20, 20 20)"
1316 ASSERT_STRING_EQUAL(ewkt,
"POLYGON((0 0,100 0,100 100,0 100,0 0),(20 20,20 40,40 40,40 20,20 20))");
1324 "(0 0, 100 0, 100 100, 0 100, 0 0),"
1325 "(20 20, 20 40, 40 40, 40 20, 20 20),"
1326 "(1 1, 1 5, 5 5, 5 1, 1 1)"
1331 ASSERT_STRING_EQUAL(ewkt,
"POLYGON((0 0,100 0,100 100,0 100,0 0),(20 20,20 40,40 40,40 20,20 20))");
1338 "(0 0, 100 0, 100 100, 0 100, 0 0),"
1339 "(20 20, 20 40, 40 40, 40 20, 20 20),"
1340 "(1 1, 1 5, 5 5, 5 1, 1 1)"
1344 CU_ASSERT_EQUAL(l, NULL);
1366 do_median_dims_check(
"MULTIPOINT ZM ((1 3 4 5), (4 7 8 6), (2 9 1 7), (0 4 4 8), (2 2 3 9))", 3);
1374 for (i = 0; i < npoints; i++)
1382 static void do_median_test(
char* input,
char* expected,
int fail_if_not_converged,
int iter_count)
1386 LWPOINT* expected_result = NULL;
1394 if (expected != NULL)
1404 if (result != NULL && expected != NULL)
1414 passed &= fabs(actual_pt.
x - expected_pt.
x) < tolerance;
1415 passed &= fabs(actual_pt.
y - expected_pt.
y) < tolerance;
1416 passed &= (!
lwgeom_has_z((
LWGEOM*) expected_result) || fabs(actual_pt.
z - expected_pt.
z) < tolerance);
1417 passed &= (!
lwgeom_has_m((
LWGEOM*) expected_result) || fabs(actual_pt.
m - expected_pt.
m) < tolerance);
1423 uint32_t npoints = 1;
1429 passed = distance_result <= (1.0 + tolerance) * distance_expected;
1432 printf(
"Diff: Got %.10f Expected %.10f\n", distance_result, distance_expected);
1440 printf(
"median_test input %s (parsed %s) expected %s got %s\n",
1447 else if (result == NULL && expected == NULL)
1451 else if (result != NULL && expected == NULL)
1456 else if (result == NULL && expected != NULL)
1463 CU_ASSERT_TRUE(passed);
1487 do_median_test(
"MULTIPOINT ((10 10 10), (10 20 10), (20 10 10), (20 20 10), (10 10 20), (10 20 20), (20 10 20), (20 20 20))",
1488 "POINT (15 15 15)",
LW_TRUE, 1000);
1500 do_median_test(
"MULTIPOINT ZM (1 -1 3 1, 1 0 2 7, 2 1 1 1, EMPTY)",
"POINT (1 0 2)",
LW_TRUE, 1000);
1504 do_median_test(
"MULTIPOINT ZM (-1 1 -3 1, -1 0 -2 7, -2 -1 -1 1)",
"POINT (-1 0 -2)",
LW_TRUE, 1000);
1505 do_median_test(
"MULTIPOINT ZM (-1 1 -3 1, -1 0 -2 7, -2 -1 -1 0.5, -2 -1 -1 0.5)",
"POINT (-1 0 -2)",
LW_TRUE, 1000);
1508 do_median_test(
"MULTIPOINT ZM ((0 -1 0 1), (0 0 0 1), (0 1 0 0.5), (0 1 0 0.5))",
"POINT (0 0 0)",
LW_TRUE, 1000);
1510 do_median_test(
"MULTIPOINT ZM ((1 -1 3 1), (1 0 2 7), (2 1 1 2), (2 1 1 -1))", NULL,
LW_TRUE, 1000);
1530 "(1000 0 -200 100),"
1531 "(1000 0 -590 100),"
1535 "POINT (1025 0 -65)",
LW_TRUE, 10000);
1542 "(0 -3000 -3472.22222222222262644208967685699462890625 1),"
1543 "(0 3000 3472.22222222222262644208967685699462890625 1),"
1544 "(0 0 -1644.736842105263121993630193173885345458984375 1),"
1545 "(0 0 1644.736842105263121993630193173885345458984375 1),"
1546 "(0 48000 -20000 1.3),"
1547 "(0 -48000 -20000 1.3)"
1549 "POINT (0 0 0)",
LW_TRUE, 10000);
1557 "(0 -3000 -3472.22222222222262644208967685699462890625 1),"
1558 "(0 3000 3472.22222222222262644208967685699462890625 1),"
1559 "(0 -0.00000000000028047739569477638384522295466033823196 -1644.736842105263121993630193173885345458984375 1),"
1560 "(0 0.00000000000028047739569477638384522295466033823196 1644.736842105263121993630193173885345458984375 1),"
1561 "(0 48000 -20000 1.3),"
1562 "(0 -48000 -20000 1.3)"
1564 "POINT (0 0 0)",
LW_TRUE, 10000);
1581 CU_ASSERT_EQUAL(mpt->
ngeoms,100);
1586 for (i = 0; i < 100; i++)
1593 CU_ASSERT_EQUAL(eq, 0);
1605 for (i = 0; i < 1000; i++)
1612 CU_ASSERT_EQUAL(eq, 0);
1620 for (i = 0; i < 1000; i++)
1627 CU_ASSERT_EQUAL(eq, 1000);
1639 CU_ASSERT_DOUBLE_EQUAL(
lwpoint_get_x(pt), 0.801167838758, 1e-11);
1640 CU_ASSERT_DOUBLE_EQUAL(
lwpoint_get_y(pt), 0.345281131175, 1e-11);
1645 CU_ASSERT_EQUAL(mpt, NULL);
1651 geom =
lwgeom_from_wkt(
"MULTIPOLYGON(((10 0,0 10,10 20,20 10,10 0)),((0 0,5 0,5 5,0 5,0 0)))",
LW_PARSER_CHECK_NONE);
1654 CU_ASSERT_EQUAL(mpt->
ngeoms,1000);
1658 CU_ASSERT_EQUAL(mpt->
ngeoms,1);
1668 const int32_t srid = 4326;
1669 const uint32_t segments_per_quad = 17;
1681 CU_ASSERT_DOUBLE_EQUAL(g->
xmin,
x-
r, 0.1);
1682 CU_ASSERT_DOUBLE_EQUAL(g->
xmax,
x+
r, 0.1);
1683 CU_ASSERT_DOUBLE_EQUAL(g->
ymin,
y-
r, 0.1);
1684 CU_ASSERT_DOUBLE_EQUAL(g->
ymax,
y+
r, 0.1);
1692 CU_ASSERT_TRUE(p == NULL);
1696 CU_ASSERT_TRUE(p == NULL);
1700 CU_ASSERT_TRUE(p != NULL);
1706 static int cluster_size = 100;
1707 static int num_clusters = 4;
1708 static double spread = 1.5;
1709 int N = cluster_size * num_clusters;
1716 for (j = 0; j < num_clusters; j++) {
1717 for (i = 0; i < cluster_size; i++)
1719 double u1 = 1.0 * rand() / RAND_MAX;
1720 double u2 = 1.0 * rand() / RAND_MAX;
1721 double z1 = spread * j + sqrt(-2*log2(u1))*cos(2*M_PI*u2);
1722 double z2 = spread * j + sqrt(-2*log2(u1))*sin(2*M_PI*u2);
1738 for (i = 0; i < k; i++)
1753 pt.
x = 1.2345678901234;
1754 pt.
y = 2.3456789012345;
1755 pt.
z = 3.4567890123456;
1756 pt.
m = 4.5678901234567;
1779 CU_ASSERT_DOUBLE_EQUAL(pt1.
x, pt2.
x, pow(10, -1*
precision));
1780 CU_ASSERT_DOUBLE_EQUAL(pt1.
y, pt2.
y, pow(10, -1*
precision));
1781 CU_ASSERT_DOUBLE_EQUAL(pt1.
z, pt2.
z, pow(10, -1*
precision));
1782 CU_ASSERT_DOUBLE_EQUAL(pt1.
m, pt2.
m, pow(10, -1*
precision));
static void test_kmeans(void)
static void test_geohash(void)
static void test_geohash_bbox(void)
static void test_lw_segment_intersects(void)
static void test_lwline_clip_big(void)
static void test_point_interpolate(void)
static int init_cg_suite(void)
static void test_lwline_crossing_bugs(void)
static void test_geohash_point(void)
#define setpoint(p, x1, y1)
static void test_isclosed(void)
static void test_lw_arc_center(void)
static void test_lwgeom_remove_repeated_points(void)
static void test_lwpoly_clip(void)
static void test_point_density(void)
static void test_lwpoly_construct_circle(void)
static void test_lwline_interpolate_point_3d(void)
static void test_median_robustness(void)
static double test_weighted_distance(const POINT4D *curr, const POINT4D *points, uint32_t npoints)
static void test_lwgeom_simplify(void)
LWGEOM_PARSER_RESULT parse_result
static int clean_cg_suite(void)
static void test_geohash_precision(void)
static void test_lwline_crossing_short_lines(void)
static void test_lwmline_clip(void)
static void test_trim_bits(void)
static void test_geohash_point_as_int(void)
static void test_median_handles_3d_correctly(void)
static void test_lwline_crossing_long_lines(void)
static void do_median_dims_check(char *wkt, int expected_dims)
void algorithms_suite_setup(void)
static void test_lwtriangle_clip(void)
static void test_lwpoint_get_ordinate(void)
static void test_lwline_interpolate_points(void)
static void do_median_test(char *input, char *expected, int fail_if_not_converged, int iter_count)
static void test_lwpoint_set_ordinate(void)
static void test_lw_segment_side(void)
static void test_lwline_clip(void)
void gbox_init(GBOX *gbox)
Zero out all the entries in the GBOX.
void cu_error_msg_reset()
char cu_error_msg[MAX_CUNIT_ERROR_LENGTH+1]
#define ASSERT_POINT4D_EQUAL(o, e, eps)
#define ASSERT_INT_EQUAL(o, e)
#define PG_ADD_TEST(suite, testfunc)
#define ASSERT_STRING_EQUAL(o, e)
#define ASSERT_POINT2D_EQUAL(o, e, eps)
LWPOLY * lwpoly_construct_circle(int32_t srid, double x, double y, double radius, uint32_t segments_per_quarter, char exterior)
int lwpoint_getPoint4d_p(const LWPOINT *point, POINT4D *out)
LWLINE * lwgeom_as_lwline(const LWGEOM *lwgeom)
LWPOINT * lwline_interpolate_point_3d(const LWLINE *line, double distance)
Interpolate one point along a line in 3D.
POINT4D getPoint4d(const POINTARRAY *pa, uint32_t n)
LWGEOM * lwline_as_lwgeom(const LWLINE *obj)
LWGEOM * lwgeom_simplify(const LWGEOM *igeom, double dist, int preserve_collapsed)
Simplification.
int lwgeom_ndims(const LWGEOM *geom)
Return the number of dimensions (2, 3, 4) in a geometry.
int32_t lwgeom_get_srid(const LWGEOM *geom)
Return SRID number.
LWPOINT * lwpoint_make2d(int32_t srid, double x, double y)
void lwmpoint_free(LWMPOINT *mpt)
LWMPOINT * lwgeom_as_lwmpoint(const LWGEOM *lwgeom)
void lwgeom_trim_bits_in_place(LWGEOM *geom, int32_t prec_x, int32_t prec_y, int32_t prec_z, int32_t prec_m)
Trim the bits of an LWGEOM in place, to optimize it for compression.
void lwpoint_free(LWPOINT *pt)
void lwgeom_free(LWGEOM *geom)
#define LW_PARSER_CHECK_NONE
unsigned int geohash_point_as_int(POINT2D *pt)
LWGEOM * lwpoly_as_lwgeom(const LWPOLY *obj)
int lwline_crossing_direction(const LWLINE *l1, const LWLINE *l2)
Given two lines, characterize how (and if) they cross each other.
double lwpoint_get_x(const LWPOINT *point)
LWGEOM * lwgeom_clone_deep(const LWGEOM *lwgeom)
Deep clone an LWGEOM, everything is copied.
int lwgeom_remove_repeated_points_in_place(LWGEOM *in, double tolerance)
POINTARRAY * ptarray_construct(char hasz, char hasm, uint32_t npoints)
Construct an empty pointarray, allocating storage and setting the npoints, but not filling in any inf...
int lwgeom_has_z(const LWGEOM *geom)
Return LW_TRUE if geometry has Z ordinates.
#define POINTTYPE
LWTYPE numbers, used internally by PostGIS.
char * lwgeom_to_ewkt(const LWGEOM *lwgeom)
Return an alloced string.
LWLINE * lwline_construct(int32_t srid, GBOX *bbox, POINTARRAY *points)
double lwgeom_area(const LWGEOM *geom)
int ptarray_insert_point(POINTARRAY *pa, const POINT4D *p, uint32_t where)
Insert a point into an existing POINTARRAY.
uint32_t lwgeom_count_vertices(const LWGEOM *geom)
Count the total number of vertices in any LWGEOM.
char * lwgeom_geohash(const LWGEOM *lwgeom, int precision)
Calculate the GeoHash (http://geohash.org) string for a geometry.
double distance3d_pt_pt(const POINT3D *p1, const POINT3D *p2)
POINTARRAY * lwline_interpolate_points(const LWLINE *line, double length_fraction, char repeat)
Interpolate one or more points along a line.
LWGEOM * lwpoint_as_lwgeom(const LWPOINT *obj)
LWCOLLECTION * lwgeom_clip_to_ordinate_range(const LWGEOM *lwin, char ordinate, double from, double to, double offset)
Given a geometry clip based on the from/to range of one of its ordinates (x, y, z,...
@ LINE_MULTICROSS_END_RIGHT
@ LINE_MULTICROSS_END_SAME_FIRST_LEFT
@ LINE_MULTICROSS_END_LEFT
POINTARRAY * ptarray_construct_empty(char hasz, char hasm, uint32_t maxpoints)
Create a new POINTARRAY with no points.
void lwcollection_free(LWCOLLECTION *col)
void ptarray_free(POINTARRAY *pa)
const GBOX * lwgeom_get_bbox(const LWGEOM *lwgeom)
Get a non-empty geometry bounding box, computing and caching it if not already there.
LWGEOM * lwgeom_from_wkt(const char *wkt, const char check)
void * lwalloc(size_t size)
void lwpoly_free(LWPOLY *poly)
LWPOINT * lwgeom_median(const LWGEOM *g, double tol, uint32_t maxiter, char fail_if_not_converged)
LWMPOINT * lwgeom_to_points(const LWGEOM *lwgeom, uint32_t npoints, int32_t seed)
void lwmline_free(LWMLINE *mline)
#define LW_TRUE
Return types for functions with status returns.
#define SRID_UNKNOWN
Unknown SRID value.
int lwgeom_has_m(const LWGEOM *geom)
Return LW_TRUE if geometry has M ordinates.
void ptarray_set_point4d(POINTARRAY *pa, uint32_t n, const POINT4D *p4d)
void lwline_free(LWLINE *line)
LWLINE * lwline_construct_empty(int32_t srid, char hasz, char hasm)
double lwpoint_get_y(const LWPOINT *point)
int * lwgeom_cluster_2d_kmeans(const LWGEOM **geoms, uint32_t ngeoms, uint32_t k)
Take a list of LWGEOMs and a number of clusters and return an integer array indicating which cluster ...
void lwpoint_set_ordinate(POINT4D *p, char ordinate, double value)
Given a point, ordinate number and value, set that ordinate on the point.
int lwgeom_geohash_precision(GBOX bbox, GBOX *bounds)
int lwcircstring_is_closed(const LWCIRCSTRING *curve)
double lwpoint_get_ordinate(const POINT4D *p, char ordinate)
Given a POINT4D and an ordinate number, return the value of the ordinate.
int lwline_is_closed(const LWLINE *line)
int lwcompound_is_closed(const LWCOMPOUND *curve)
int lw_segment_intersects(const POINT2D *p1, const POINT2D *p2, const POINT2D *q1, const POINT2D *q2)
returns the kind of CG_SEGMENT_INTERSECTION_TYPE behavior of lineseg 1 (constructed from p1 and p2) a...
POINT4D * lwmpoint_extract_points_4d(const LWMPOINT *g, uint32_t *npoints, int *input_empty)
double lw_arc_center(const POINT2D *p1, const POINT2D *p2, const POINT2D *p3, POINT2D *result)
Determines the center of the circle defined by the three given points.
int lwpoint_is_empty(const LWPOINT *point)
#define FP_TOLERANCE
Floating point comparators.
int ptarray_has_z(const POINTARRAY *pa)
int lw_segment_side(const POINT2D *p1, const POINT2D *p2, const POINT2D *q)
lw_segment_side()
int point_interpolate(const POINT4D *p1, const POINT4D *p2, POINT4D *p, int hasz, int hasm, char ordinate, double interpolation_value)
Given two points, a dimensionality, an ordinate, and an interpolation value generate a new point that...
void decode_geohash_bbox(char *geohash, double *lat, double *lon, int precision)
int ptarray_has_m(const POINTARRAY *pa)
char * geohash_point(double longitude, double latitude, int precision)
static int lwgeom_is_empty(const LWGEOM *geom)
Return true or false depending on whether a geometry is an "empty" geometry (no vertices members)
static LWPOINT * lwgeom_as_lwpoint(const LWGEOM *lwgeom)
static double distance(double x1, double y1, double x2, double y2)
Parser result structure: returns the result of attempting to convert (E)WKT/(E)WKB to LWGEOM.