15 #include "CUnit/Basic.h"
17 #include "../lwgeom_log.h"
18 #include "../lwgeom_geos.h"
26 for (i = 0; i < num_outputs; i++)
28 for (j = 0; j < num_expected_outputs; j++)
37 CU_ASSERT_TRUE(found_equal);
44 GEOSGeometry** geos_geoms =
lwalloc(num_geoms *
sizeof(GEOSGeometry*));
46 for (i = 0; i < num_geoms; i++)
59 for (i = 0; i < num_geoms; i++)
73 for (i = 0; i < num_geoms; i++)
83 GEOSGeometry** geos_results;
85 uint32_t num_clusters;
92 CU_ASSERT_EQUAL(num_outputs, num_clusters);
100 for(i = 0; i < num_clusters; i++)
102 GEOSGeom_destroy(geos_results[i]);
107 for(i = 0; i < num_outputs; i++)
115 for(i = 0; i < num_inputs; i++)
125 uint32_t num_clusters;
132 CU_ASSERT_EQUAL(num_outputs, num_clusters);
138 for(i = 0; i < num_outputs; i++)
162 char* a =
"LINESTRING (0 0, 1 1)";
163 char* b =
"LINESTRING (1 1, 2 2)";
164 char* c =
"LINESTRING (5 5, 6 6)";
166 char* wkt_inputs_a[] = {a, b, c};
167 char* wkt_inputs_b[] = {b, c, a};
168 char* wkt_inputs_c[] = {c, a, b};
170 char* expected_outputs_a[] = {
"GEOMETRYCOLLECTION(LINESTRING (0 0, 1 1), LINESTRING (1 1, 2 2))",
171 "GEOMETRYCOLLECTION(LINESTRING (5 5, 6 6))"
174 char* expected_outputs_b[] = {
"GEOMETRYCOLLECTION(LINESTRING (1 1, 2 2), LINESTRING (0 0, 1 1))",
175 "GEOMETRYCOLLECTION(LINESTRING (5 5, 6 6))"
178 char* expected_outputs_c[] = {
"GEOMETRYCOLLECTION(LINESTRING (0 0, 1 1), LINESTRING (1 1, 2 2))",
179 "GEOMETRYCOLLECTION(LINESTRING (5 5, 6 6))"
193 char* a =
"LINESTRING (0 0, 1 1)";
194 char* b =
"LINESTRING (1 1, 2 2)";
195 char* c =
"LINESTRING (5 5, 6 6)";
197 char* wkt_inputs[] = {a, b, c};
199 char* expected_outputs_all[] = {
"GEOMETRYCOLLECTION(LINESTRING(0 0, 1 1), LINESTRING(1 1, 2 2), LINESTRING(5 5, 6 6))"};
200 char* expected_outputs_partial[] = {
"GEOMETRYCOLLECTION(LINESTRING(0 0, 1 1), LINESTRING(1 1, 2 2))",
201 "GEOMETRYCOLLECTION(LINESTRING(5 5, 6 6))"
211 char* wkt_inputs[] = {
"LINESTRING (0 0, 1 1)",
212 "LINESTRING (1 1, 2 2)",
213 "LINESTRING (5 5, 6 6)",
214 "LINESTRING (5 5, 4 4)",
215 "LINESTRING (3 3, 2 2)",
216 "LINESTRING (3 3, 4 4)"
219 char* expected_outputs[] = {
"GEOMETRYCOLLECTION (LINESTRING (0 0, 1 1), LINESTRING (1 1, 2 2), LINESTRING (5 5, 6 6), LINESTRING (5 5, 4 4), LINESTRING (3 3, 2 2), LINESTRING (3 3, 4 4))" };
227 char* wkt_inputs[] = {
"POINT (0 0)" };
228 char* expected_outputs[] = {
"GEOMETRYCOLLECTION (POINT (0 0))" };
236 char* wkt_inputs[] = {
"POLYGON EMPTY",
"LINESTRING EMPTY"};
237 char* expected_outputs[] = {
"GEOMETRYCOLLECTION( LINESTRING EMPTY )",
"GEOMETRYCOLLECTION( POLYGON EMPTY )" };
246 char* wkt_inputs_mp[] = {
"MULTIPOINT ((0 0), (0 1))",
"POINT (0 0)"};
247 char* expected_outputs_mp[] = {
"GEOMETRYCOLLECTION(MULTIPOINT ((0 0), (0 1)), POINT (0 0))"};
249 char* wkt_inputs_gc[] = {
"GEOMETRYCOLLECTION (POINT (0 0), POINT (0 1))",
"POINT (0 0)"};
250 char* expected_outputs_gc[] = {
"GEOMETRYCOLLECTION(GEOMETRYCOLLECTION (POINT (0 0), POINT (0 1)), POINT (0 0))"};
252 char* wkt_inputs_pt[] = {
"POINT (3 3)",
"POINT (3 3)"};
253 char* expected_outputs_pt[] = {
"GEOMETRYCOLLECTION(POINT (3 3), POINT (3 3))"};
300 char*
wkt_inputs[] = {
"POINT (0 0)",
"POINT (-1 0)",
"POINT (-1 -0.1)",
"POINT (-1 0.1)",
302 "POINT (2 0)",
"POINT (3 0)",
"POINT ( 3 -0.1)",
"POINT ( 3 0.1)" };
309 uint32_t
expected_ids[] = { 0, 0, 0, 0, 0, 1, 1, 1, 1, 1 };
356 char*
wkt_inputs[] = {
"POLYGONM((-71.1319 42.2503 1,-71.132 42.2502 3,-71.1323 42.2504 -2,-71.1322 42.2505 1,-71.1319 42.2503 0))",
357 "POLYGONM((-71.1319 42.2512 0,-71.1318 42.2511 20,-71.1317 42.2511 -20,-71.1317 42.251 5,-71.1317 42.2509 4,-71.132 42.2511 6,-71.1319 42.2512 30))" };
static void basic_distance_test(void)
static GEOSGeometry ** LWGEOMARRAY2GEOS(LWGEOM **lw_array, size_t num_geoms)
static void multipoint_test(void)
void geos_cluster_suite_setup(void)
static void dbscan_test_3612c(void)
static void perform_cluster_within_distance_test(double tolerance, char **wkt_inputs, uint32_t num_inputs, char **wkt_outputs, uint32_t num_outputs)
static void single_input_test(void)
static void empty_inputs_test(void)
static int clean_geos_cluster_suite(void)
static void dbscan_test_3612b(void)
static void nonsequential_test(void)
static int init_geos_cluster_suite(void)
static void dbscan_test(void)
static void assert_all_results_found(LWGEOM **results, size_t num_outputs, LWGEOM **expected, size_t num_expected_outputs)
static void do_dbscan_test(struct dbscan_test_info test)
static LWGEOM ** GEOSARRAY2LWGEOM(GEOSGeometry **geos_array, size_t num_geoms)
static LWGEOM ** WKTARRAY2LWGEOM(char **wkt_array, size_t num_geoms)
static void dbscan_test_3612a(void)
static void perform_cluster_intersecting_test(char **wkt_inputs, uint32_t num_inputs, char **wkt_outputs, uint32_t num_outputs)
static void basic_test(void)
#define ASSERT_INT_EQUAL(o, e)
#define PG_ADD_TEST(suite, testfunc)
GEOSGeometry * LWGEOM2GEOS(const LWGEOM *lwgeom, uint8_t autofix)
LWGEOM * GEOS2LWGEOM(const GEOSGeometry *geom, uint8_t want3d)
void lwgeom_geos_error(const char *fmt,...)
int cluster_within_distance(LWGEOM **geoms, uint32_t num_geoms, double tolerance, LWGEOM ***clusterGeoms, uint32_t *num_clusters)
Takes an array of LWGEOM* and constructs an array of LWGEOM*, where each element in the constructed a...
int cluster_intersecting(GEOSGeometry **geoms, uint32_t num_geoms, GEOSGeometry ***clusterGeoms, uint32_t *num_clusters)
Takes an array of GEOSGeometry* and constructs an array of GEOSGeometry*, where each element in the c...
int union_dbscan(LWGEOM **geoms, uint32_t num_geoms, UNIONFIND *uf, double eps, uint32_t min_points, char **is_in_cluster_ret)
char lwgeom_same(const LWGEOM *lwgeom1, const LWGEOM *lwgeom2)
geom1 same as geom2 iff
void lwgeom_free(LWGEOM *geom)
#define LW_PARSER_CHECK_NONE
LWGEOM * lwgeom_from_wkt(const char *wkt, const char check)
void * lwalloc(size_t size)
void lwnotice(const char *fmt,...)
Write a notice out to the notice handler.
uint32_t * UF_get_collapsed_cluster_ids(UNIONFIND *uf, const char *is_in_cluster)
void UF_destroy(UNIONFIND *uf)
UNIONFIND * UF_create(uint32_t N)
int * expected_in_cluster