-
Notifications
You must be signed in to change notification settings - Fork 1
/
geos_perf_test_buffer1.c
61 lines (52 loc) · 1.57 KB
/
geos_perf_test_buffer1.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
60
#include <stdio.h>
#include "geos_perf.h"
/*************************************************************************
* PERFORMANCE TEST
*/
/* Variables where data lives between the setup/run/cleanup stages */
static GEOSGeometryList watersheds;
/* Read any data we need, and create any structures */
static void setup(void)
{
/* Geometry list always must be initialized before use */
/* so the internal array is prepared, and counters zero'ed out */
geomlist_init(&watersheds);
/* Use utility function to read data file into geometry list */
read_data_file("watersheds.wkt.gz", &watersheds);
}
/* For each run, buffer each geometry in the collection */
static void run(void)
{
size_t i;
for (i = 0; i < geomlist_size(&watersheds); i++)
{
const GEOSGeometry* g = geomlist_get(&watersheds, i);
GEOSGeometry* buffer = GEOSBuffer(
g, /* input geometry */
100.0, /* buffer size */
24 /* quadsegs */
);
GEOSGeom_destroy(buffer);
}
}
/* Clean up any remaining memory */
static void cleanup(void)
{
geomlist_free(&watersheds);
}
/*************************************************************************
* CONFIGURATION CALLBACK FUNCTION
*/
gp_test config_buffer_watersheds(void)
{
gp_test test;
test.name = "Watershed buffer";
test.description =
"Generate buffers for complex watershed polygons."
"Exercises the buffer function.";
test.func_setup = setup;
test.func_run = run;
test.func_cleanup = cleanup;
test.count = 5;
return test;
}