-
Notifications
You must be signed in to change notification settings - Fork 1
/
geos_perf_test_union.c
60 lines (51 loc) · 1.58 KB
/
geos_perf_test_union.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#include <stdio.h>
#include "geos_perf.h"
/*************************************************************************
* PERFORMANCE TEST
*/
/* Variables where data lives between the setup/run/cleanup stages */
static GEOSGeometryList watersheds;
static GEOSGeometry *collection;
/* Read any data we need, and create any structures */
static void setup(void)
{
geomlist_init(&watersheds);
read_data_file("watersheds.wkt.gz", &watersheds);
/* collection takes ownership of all geometries */
collection = GEOSGeom_createCollection(
GEOS_GEOMETRYCOLLECTION,
watersheds.geoms,
watersheds.ngeoms);
/* gently free just the containing geomlist */
geomlist_release(&watersheds);
}
/* For each run, union all the geometries in the collection */
static void run(void)
{
GEOSGeometry* geom = GEOSUnaryUnion(collection);
GEOSGeom_destroy(geom);
}
/* Clean up any remaining memory */
static void cleanup(void)
{
/* geomlist is already cleaned, just need to get rid of collection */
GEOSGeom_destroy(collection);
}
/*************************************************************************
* CONFIGURATION CALLBACK FUNCTION
*/
gp_test config_union_watersheds(void)
{
gp_test test;
test.name = "Watershed unary union";
test.description =
"Load a collection of watershed boundaries"
"and use unary union to merge them into a"
"single final multi-polygon. Exercises"
"cascaded union and overlay.";
test.func_setup = setup;
test.func_run = run;
test.func_cleanup = cleanup;
test.count = 2;
return test;
}