pantry/projects/libgeos.org/package.yml
Jacob Heider 5c666195c6
fix(libgeos)
closes #4038
closes #4039
2023-11-13 09:55:42 -05:00

52 lines
1.5 KiB
YAML

distributable:
url: https://github.com/libgeos/geos/releases/download/{{version}}/geos-{{version}}.tar.bz2
strip-components: 1
versions:
github: libgeos/geos/releases/tags
build:
dependencies:
cmake.org: '*'
working-directory: build
script: |
cmake .. $ARGS
make --jobs {{ hw.concurrency }}
make install
env:
ARGS:
- -DCMAKE_BUILD_TYPE=Release
- -DCMAKE_INSTALL_PREFIX={{prefix}}
provides:
- bin/geos-config
test:
fixture: |
#include <stdio.h>
#include <stdarg.h>
#include <geos_c.h>
static void geos_message_handler(const char* fmt, ...) {
va_list ap;
va_start(ap, fmt);
vprintf (fmt, ap);
va_end(ap);
}
int main() {
initGEOS(geos_message_handler, geos_message_handler);
const char* wkt_a = "POLYGON((0 0, 10 0, 10 10, 0 10, 0 0))";
const char* wkt_b = "POLYGON((5 5, 15 5, 15 15, 5 15, 5 5))";
GEOSWKTReader* reader = GEOSWKTReader_create();
GEOSGeometry* geom_a = GEOSWKTReader_read(reader, wkt_a);
GEOSGeometry* geom_b = GEOSWKTReader_read(reader, wkt_b);
GEOSGeometry* inter = GEOSIntersection(geom_a, geom_b);
GEOSWKTWriter* writer = GEOSWKTWriter_create();
GEOSWKTWriter_setTrim(writer, 1);
char* wkt_inter = GEOSWKTWriter_write(writer, inter);
printf("Intersection(A, B): %s\\n", wkt_inter);
return 0;
}
script: |
mv $FIXTURE test.c
cc test.c -lgeos_c
./a.out