13 #include "CUnit/Basic.h"
15 #include "../lwgeom_log.h"
16 #include "../lwgeom_geos.h"
24 for (i = 0; i < num_outputs; i++)
26 for (j = 0; j < num_expected_outputs; j++)
35 CU_ASSERT_TRUE(found_equal);
42 GEOSGeometry** geos_geoms =
lwalloc(num_geoms *
sizeof(GEOSGeometry*));
44 for (i = 0; i < num_geoms; i++)
57 for (i = 0; i < num_geoms; i++)
71 for (i = 0; i < num_geoms; i++)
81 GEOSGeometry** geos_results;
90 CU_ASSERT_EQUAL(num_outputs, num_clusters);
98 for(i = 0; i < num_clusters; i++)
100 GEOSGeom_destroy(geos_results[i]);
105 for(i = 0; i < num_outputs; i++)
113 for(i = 0; i < num_inputs; i++)
130 CU_ASSERT_EQUAL(num_outputs, num_clusters);
136 for(i = 0; i < num_outputs; i++)
160 char* a =
"LINESTRING (0 0, 1 1)";
161 char* b =
"LINESTRING (1 1, 2 2)";
162 char* c =
"LINESTRING (5 5, 6 6)";
164 char* wkt_inputs_a[] = {a, b, c};
165 char* wkt_inputs_b[] = {b, c, a};
166 char* wkt_inputs_c[] = {c, a, b};
168 char* expected_outputs_a[] = {
"GEOMETRYCOLLECTION(LINESTRING (0 0, 1 1), LINESTRING (1 1, 2 2))",
169 "GEOMETRYCOLLECTION(LINESTRING (5 5, 6 6))"
172 char* expected_outputs_b[] = {
"GEOMETRYCOLLECTION(LINESTRING (1 1, 2 2), LINESTRING (0 0, 1 1))",
173 "GEOMETRYCOLLECTION(LINESTRING (5 5, 6 6))"
176 char* expected_outputs_c[] = {
"GEOMETRYCOLLECTION(LINESTRING (0 0, 1 1), LINESTRING (1 1, 2 2))",
177 "GEOMETRYCOLLECTION(LINESTRING (5 5, 6 6))"
191 char* a =
"LINESTRING (0 0, 1 1)";
192 char* b =
"LINESTRING (1 1, 2 2)";
193 char* c =
"LINESTRING (5 5, 6 6)";
195 char* wkt_inputs[] = {a, b, c};
197 char* expected_outputs_all[] = {
"GEOMETRYCOLLECTION(LINESTRING(0 0, 1 1), LINESTRING(1 1, 2 2), LINESTRING(5 5, 6 6))"};
198 char* expected_outputs_partial[] = {
"GEOMETRYCOLLECTION(LINESTRING(0 0, 1 1), LINESTRING(1 1, 2 2))",
199 "GEOMETRYCOLLECTION(LINESTRING(5 5, 6 6))"
209 char* wkt_inputs[] = {
"LINESTRING (0 0, 1 1)",
210 "LINESTRING (1 1, 2 2)",
211 "LINESTRING (5 5, 6 6)",
212 "LINESTRING (5 5, 4 4)",
213 "LINESTRING (3 3, 2 2)",
214 "LINESTRING (3 3, 4 4)"
217 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))" };
225 char* wkt_inputs[] = {
"POINT (0 0)" };
226 char* expected_outputs[] = {
"GEOMETRYCOLLECTION (POINT (0 0))" };
234 char* wkt_inputs[] = {
"POLYGON EMPTY",
"LINESTRING EMPTY"};
235 char* expected_outputs[] = {
"GEOMETRYCOLLECTION( LINESTRING EMPTY )",
"GEOMETRYCOLLECTION( POLYGON EMPTY )" };
244 char* wkt_inputs_mp[] = {
"MULTIPOINT ((0 0), (0 1))",
"POINT (0 0)"};
245 char* expected_outputs_mp[] = {
"GEOMETRYCOLLECTION(MULTIPOINT ((0 0), (0 1)), POINT (0 0))"};
247 char* wkt_inputs_gc[] = {
"GEOMETRYCOLLECTION (POINT (0 0), POINT (0 1))",
"POINT (0 0)"};
248 char* expected_outputs_gc[] = {
"GEOMETRYCOLLECTION(GEOMETRYCOLLECTION (POINT (0 0), POINT (0 1)), POINT (0 0))"};
250 char* wkt_inputs_pt[] = {
"POINT (3 3)",
"POINT (3 3)"};
251 char* expected_outputs_pt[] = {
"GEOMETRYCOLLECTION(POINT (3 3), POINT (3 3))"};
298 char*
wkt_inputs[] = {
"POINT (0 0)",
"POINT (-1 0)",
"POINT (-1 -0.1)",
"POINT (-1 0.1)",
300 "POINT (2 0)",
"POINT (3 0)",
"POINT ( 3 -0.1)",
"POINT ( 3 0.1)" };
354 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))",
355 "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