[geos-devel] GEOSGeomFromWKT returning null

Gabriel Furstenheim Milerud furstenheim at gmail.com
Thu Feb 8 06:50:46 PST 2018


Hello,
I'm trying to use geos_c but I'm getting null geometry.

I installed the dependency from libgeos-dev.

I've been following
https://github.com/OSGeo/geos/blob/master/tests/geostest/geostest.c

>
> #include <stdio.h>
> #include <stdlib.h>
> #include "geos_c.h"
> #define MAXWKTLEN 1047551
>



> static char wkt[MAXWKTLEN];

  // In a.wkt the same example as the test

> input = fopen("./a.wkt", "r");
> if ( ! input ) { perror("fopen"); exit(1); }
> size = fread(wkt, 1, MAXWKTLEN-1, input);
> fclose(input);
> if ( ! size ) { perror("fread"); exit(1); }
> if ( size == MAXWKTLEN-1 ) { perror("WKT input too big!"); exit(1); }
> wkt[size] = '\0'; /* ensure it is null terminated */
> g1 = GEOSGeomFromWKT(wkt);
> printf("g1 generated\n");
> ptr = GEOSGeomToWKT(g1);
> printf("Origin (WKT): %s.\n", wkt2);
> if (!g1) printf("Pointer is null\n");
> printf("Input (WKT): %s.\n", ptr);


Both g1 and ptr are null.What might I be doing incorrectly?


Thanks a lot.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/geos-devel/attachments/20180208/dece081a/attachment.html>


More information about the geos-devel mailing list