Last active
January 2, 2017 23:15
-
-
Save TimSC/eded1a36335cdb97f64729bb5c5f9db0 to your computer and use it in GitHub Desktop.
Test geos_c library
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //Compile with: g++ test.cpp -lgeos_c -o test | |
| #include <geos_c.h> | |
| #include <stdio.h> | |
| void noticeFunc(const char *message, ...) | |
| { | |
| printf("notice: %s\n", message); | |
| } | |
| void errorFunc(const char *message, ...) | |
| { | |
| printf("error: %s\n", message); | |
| } | |
| int main(){ | |
| GEOSContextHandle_t cx = GEOS_init_r(); | |
| GEOSContext_setNoticeHandler_r(cx, ¬iceFunc); | |
| GEOSContext_setErrorHandler_r(cx, &errorFunc); | |
| GEOSWKTReader *r = GEOSWKTReader_create_r(cx); | |
| GEOSGeometry *geom = GEOSWKTReader_read_r(cx, r, "POINT(0.000001 51.0)"); | |
| GEOSWKTWriter *w = GEOSWKTWriter_create_r(cx); | |
| GEOSWKTWriter_setTrim_r(cx, w, true); | |
| char *wkt = GEOSWKTWriter_write_r(cx, w, geom); | |
| printf("%s\n", wkt); | |
| GEOSWKTReader_destroy_r(cx, r); | |
| GEOSWKTWriter_destroy_r(cx, w); | |
| GEOS_finish_r(cx); | |
| } | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment