[geos-devel] GEOSGeomFromWKT returning null

Gabriel Furstenheim Milerud furstenheim at gmail.com
Thu Feb 8 07:13:56 PST 2018


Ok, I found the error. I wasn't doing initGEOS

On 8 February 2018 at 15:50, Gabriel Furstenheim Milerud <
furstenheim at gmail.com> wrote:

> 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/d93e13c9/attachment.html>


More information about the geos-devel mailing list