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 );
453 CU_ASSERT_EQUAL(
r.x, 15.0);
457 CU_ASSERT_EQUAL(
r.y, 21.0);
461 CU_ASSERT_EQUAL(
r.y, 30.0);
465 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)))",
796 "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)))");
826 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);
841 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);
855 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)",
861 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))");
869 "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))");
1129 unsigned long long rs;
1134 CU_ASSERT_EQUAL(gh, rs);
1135 p.
x = 140; p.
y = 45;
1138 CU_ASSERT_EQUAL(gh, rs);
1139 p.
x = 140; p.
y = 55;
1142 CU_ASSERT_EQUAL(gh, rs);
1148 double lat[2], lon[2];
1152 CU_ASSERT_DOUBLE_EQUAL(lat[0], 48, 1e-11);
1153 CU_ASSERT_DOUBLE_EQUAL(lat[1], 48, 1e-11);
1154 CU_ASSERT_DOUBLE_EQUAL(lon[0], -126, 1e-11);
1155 CU_ASSERT_DOUBLE_EQUAL(lon[1], -126, 1e-11);
1177 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);
1191 ASSERT_STRING_EQUAL(ewkt,
"LINESTRING(1612830.15445 4841287.12672,1612829.98813 4841274.56198)");
1196 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);
1204 g =
lwgeom_from_wkt(
"MULTIPOINT(0 0,0 10,5 5,5 8,8 5,8 8,10 0,10 10,50 50,50 60,55 55,55 58,58 55,58 58,60 50,60 60)",
LW_PARSER_CHECK_NONE);
1240 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))",
1245 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))");
1253 ASSERT_STRING_EQUAL(ewkt,
"GEOMETRYCOLLECTION(POINT(2 0),POLYGON((0 0,1 0,1 1,0 1,0 0)))");
1301 CU_ASSERT_EQUAL(l, NULL);
1308 CU_ASSERT_EQUAL(l, NULL);
1333 "(0 0, 100 0, 100 100, 0 100, 0 0),"
1334 "(1 1, 1 5, 5 5, 5 1, 1 1),"
1335 "(20 20, 20 40, 40 40, 40 20, 20 20)"
1340 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))");
1348 "(0 0, 100 0, 100 100, 0 100, 0 0),"
1349 "(20 20, 20 40, 40 40, 40 20, 20 20),"
1350 "(1 1, 1 5, 5 5, 5 1, 1 1)"
1355 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))");
1362 "(0 0, 100 0, 100 100, 0 100, 0 0),"
1363 "(20 20, 20 40, 40 40, 40 20, 20 20),"
1364 "(1 1, 1 5, 5 5, 5 1, 1 1)"
1368 CU_ASSERT_EQUAL(l, NULL);
1390 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);
1398 for (i = 0; i < npoints; i++)
1406 static void do_median_test(
char* input,
char* expected,
int fail_if_not_converged,
int iter_count)
1410 LWPOINT* expected_result = NULL;
1418 if (expected != NULL)
1428 if (
result != NULL && expected != NULL)
1438 passed &= fabs(actual_pt.
x - expected_pt.
x) < tolerance;
1439 passed &= fabs(actual_pt.
y - expected_pt.
y) < tolerance;
1440 passed &= (!
lwgeom_has_z((
LWGEOM*) expected_result) || fabs(actual_pt.
z - expected_pt.
z) < tolerance);
1441 passed &= (!
lwgeom_has_m((
LWGEOM*) expected_result) || fabs(actual_pt.
m - expected_pt.
m) < tolerance);
1447 uint32_t npoints = 1;
1453 passed = distance_result <= (1.0 + tolerance) * distance_expected;
1456 printf(
"Diff: Got %.10f Expected %.10f\n", distance_result, distance_expected);
1464 printf(
"median_test input %s (parsed %s) expected %s got %s\n",
1471 else if (
result == NULL && expected == NULL)
1475 else if (
result != NULL && expected == NULL)
1480 else if (
result == NULL && expected != NULL)
1487 CU_ASSERT_TRUE(passed);
1511 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))",
1512 "POINT (15 15 15)",
LW_TRUE, 1000);
1524 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);
1528 do_median_test(
"MULTIPOINT ZM (-1 1 -3 1, -1 0 -2 7, -2 -1 -1 1)",
"POINT (-1 0 -2)",
LW_TRUE, 1000);
1529 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);
1532 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);
1534 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);
1554 "(1000 0 -200 100),"
1555 "(1000 0 -590 100),"
1559 "POINT (1025 0 -65)",
LW_TRUE, 10000);
1566 "(0 -3000 -3472.22222222222262644208967685699462890625 1),"
1567 "(0 3000 3472.22222222222262644208967685699462890625 1),"
1568 "(0 0 -1644.736842105263121993630193173885345458984375 1),"
1569 "(0 0 1644.736842105263121993630193173885345458984375 1),"
1570 "(0 48000 -20000 1.3),"
1571 "(0 -48000 -20000 1.3)"
1573 "POINT (0 0 0)",
LW_TRUE, 10000);
1581 "(0 -3000 -3472.22222222222262644208967685699462890625 1),"
1582 "(0 3000 3472.22222222222262644208967685699462890625 1),"
1583 "(0 -0.00000000000028047739569477638384522295466033823196 -1644.736842105263121993630193173885345458984375 1),"
1584 "(0 0.00000000000028047739569477638384522295466033823196 1644.736842105263121993630193173885345458984375 1),"
1585 "(0 48000 -20000 1.3),"
1586 "(0 -48000 -20000 1.3)"
1588 "POINT (0 0 0)",
LW_TRUE, 10000);
1605 CU_ASSERT_EQUAL(mpt->
ngeoms,100);
1610 for (i = 0; i < 100; i++)
1617 CU_ASSERT_EQUAL(eq, 0);
1629 for (i = 0; i < 1000; i++)
1636 CU_ASSERT_EQUAL(eq, 0);
1644 for (i = 0; i < 1000; i++)
1651 CU_ASSERT_EQUAL(eq, 1000);
1663 CU_ASSERT_DOUBLE_EQUAL(
lwpoint_get_x(pt), 0.363667838758, 1e-11);
1664 CU_ASSERT_DOUBLE_EQUAL(
lwpoint_get_y(pt), 0.782781131175, 1e-11);
1669 CU_ASSERT_EQUAL(mpt, NULL);
1675 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);
1678 CU_ASSERT_EQUAL(mpt->
ngeoms,1000);
1682 CU_ASSERT_EQUAL(mpt->
ngeoms,1);
1692 const int32_t srid = 4326;
1693 const uint32_t segments_per_quad = 17;
1705 CU_ASSERT_DOUBLE_EQUAL(g->
xmin,
x-
r, 0.1);
1706 CU_ASSERT_DOUBLE_EQUAL(g->
xmax,
x+
r, 0.1);
1707 CU_ASSERT_DOUBLE_EQUAL(g->
ymin,
y-
r, 0.1);
1708 CU_ASSERT_DOUBLE_EQUAL(g->
ymax,
y+
r, 0.1);
1716 CU_ASSERT_TRUE(p == NULL);
1720 CU_ASSERT_TRUE(p == NULL);
1724 CU_ASSERT_TRUE(p != NULL);
1730 static int cluster_size = 100;
1731 static int num_clusters = 4;
1732 static double spread = 1.5;
1733 int N = cluster_size * num_clusters;
1740 for (j = 0; j < num_clusters; j++) {
1741 for (i = 0; i < cluster_size; i++)
1743 double u1 = 1.0 * rand() / RAND_MAX;
1744 double u2 = 1.0 * rand() / RAND_MAX;
1745 double z1 = spread * j + sqrt(-2*log2(u1))*cos(2*M_PI*u2);
1746 double z2 = spread * j + sqrt(-2*log2(u1))*sin(2*M_PI*u2);
1762 for (i = 0; i < k; i++)
1777 pt.
x = 1.2345678901234;
1778 pt.
y = 2.3456789012345;
1779 pt.
z = 3.4567890123456;
1780 pt.
m = 4.5678901234567;
1803 CU_ASSERT_DOUBLE_EQUAL(pt1.
x, pt2.
x, pow(10, -1*
precision));
1804 CU_ASSERT_DOUBLE_EQUAL(pt1.
y, pt2.
y, pow(10, -1*
precision));
1805 CU_ASSERT_DOUBLE_EQUAL(pt1.
z, pt2.
z, pow(10, -1*
precision));
1806 CU_ASSERT_DOUBLE_EQUAL(pt1.
m, pt2.
m, pow(10, -1*
precision));
1820 double tolerance = 0.0;
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_ptarray_simplify(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)
char result[OUT_DOUBLE_BUFFER_SIZE]
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_VARLENA_EQUAL(v, s)
#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_LWGEOM_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
lwvarlena_t * lwgeom_geohash(const LWGEOM *lwgeom, int precision)
Calculate the GeoHash (http://geohash.org) string for a geometry.
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 allocated 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.
int * lwgeom_cluster_kmeans(const LWGEOM **geoms, uint32_t n, uint32_t k, double max_radius)
Take a list of LWGEOMs and a number of clusters and return an integer array indicating which cluster ...
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)
LWGEOM * lwgeom_normalize(const LWGEOM *geom)
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)
void lwgeom_grid_in_place(LWGEOM *lwgeom, gridspec *grid)
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)
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.
lwvarlena_t * geohash_point(double longitude, double latitude, int precision)
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)
void ptarray_simplify_in_place(POINTARRAY *pa, double tolerance, uint32_t minpts)
#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)
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.