[geos-devel] Wrong values in GEOSCoordSeq

Giacomo Piva piva at meeo.it
Fri Aug 7 05:50:13 EDT 2009


Hi All,

I'm using for the first time GEOS library in a (ANSI) C application.
I need to get the intersection of two polygons.
Looking at the geos.h file (for C reference) I'm trying to get the 
intersection in this way:

    GEOSCoordSeq coordseq = NULL;
    GEOSGeom area1 = NULL, shell = NULL, intersection = NULL;
    GEOSGeom holes_ptr[1];

    coordseq = (GEOSCoordSeq) GEOSCoordSeq_create(5, 2);    // 5 points 
2 dimensions

    GEOSCoordSeq_setX(coordseq, 0, Lon_UL);    //Coord upper left
    GEOSCoordSeq_setY(coordseq, 0, Lat_UL);
    GEOSCoordSeq_setX(coordseq, 1, Lon_LR);    //Coord upper right
    GEOSCoordSeq_setY(coordseq, 1, Lat_UL);
    GEOSCoordSeq_setX(coordseq, 2, Lon_LR);    //Coord lower right
    GEOSCoordSeq_setY(coordseq, 2, Lat_LR);
    GEOSCoordSeq_setX(coordseq, 3, Lon_UL);    //Coord lower left
    GEOSCoordSeq_setY(coordseq, 3, Lat_LR);
    GEOSCoordSeq_setX(coordseq, 4, Lon_UL);    //Coord upper left (again)
    GEOSCoordSeq_setY(coordseq, 4, Lat_UL);

where Lon_* and Lat_* are float values.

First of all, I'm trying to see if the value in the coordseq are stored 
properly so...

I print the inserted value:  

printf("%f \n", Lon_UL);
...

And the stored values:

for(...
    GEOSCoordSeq_getX(coordseq, i, &pippo);
    printf("[%d] %f ", i, pippo);


Finally, I get different values:
At runtime:

-131.799500

[0] -0.000000 -0.000000
[1] -0.000000 -0.000000
[2] -0.000000 -0.000000
[3] -0.000000 -0.000000
[4] -0.000000 -0.000000


I'm sorry for this stupid question but... what it's wrong?
Thanks to all.



More information about the geos-devel mailing list