[geos-devel] Buffer on GEOMCOLLECTION and slight variations

Alex Trofast alex.trofast at actian.com
Wed Feb 1 17:30:18 EST 2012


Greetings all,

The program pasted below will produce slightly different results on 
different machines. It's calling BUFFER on a GEOMCOLLECTION.
On ArchLinux 64 bit with GCC 4.6.2 I get:
Buffer: POLYGON ((0.000 1.000, 0.000 1.000, 0.011 1.113, 0.019 1.195, 
0.019 1.195, 0.019 1.195, 0.043 1.275, 0.076 1.383, 0.076 1.383, 0.076 
1.383, 0.113 1.451, 0.169 1.556, 0.169 1.556, 0.169 1.556, 0.184 1.574, 
0.293 1.707, 0.293 1.707, 0.293 1.707, 4.293 5.707, 4.444 5.831, 4.617 
5.924, 4.805 5.981, 5.000 6.000, 5.195 5.981, 5.383 5.924, 5.556 5.831, 
5.707 5.707, 5.831 5.556, 5.924 5.383, 5.981 5.195, 6.000 5.000, 5.981 
4.805, 5.924 4.617, 5.831 4.444, 5.707 4.293, 1.707 0.293, 1.707 0.293, 
1.707 0.293, 1.707 0.293, 1.700 0.287, 1.556 0.169, 1.556 0.169, 1.556 
0.169, 1.474 0.125, 1.383 0.076, 1.383 0.076, 1.383 0.076, 1.293 0.049, 
1.195 0.019, 1.195 0.019, 1.195 0.019, 1.094 0.009, 1.000 0.000, 1.000 
0.000, 1.000 0.000, 0.874 0.012, 0.805 0.019, 0.805 0.019, 0.805 0.019, 
0.680 0.057, 0.617 0.076, 0.617 0.076, 0.617 0.076, 0.494 0.142, 0.444 
0.169, 0.444 0.169, 0.444 0.169, 0.366 0.233, 0.293 0.293, 0.293 0.293, 
0.293 0.293, 0.218 0.384, 0.169 0.444, 0.169 0.444, 0.169 0.444, 0.128 
0.521, 0.076 0.617, 0.076 0.617, 0.076 0.617, 0.048 0.710, 0.019 0.805, 
0.019 0.805, 0.019 0.805, 0.011 0.890, 0.000 1.000, 0.000 1.000))
On OpenSUSE 10 64 bit, GCC 4.1.2
Buffer: POLYGON ((0.000 1.000, 0.000 1.000, 0.011 1.113, 0.019 1.195, 
0.019 1.195, 0.019 1.195, 0.043 1.275, 0.076 1.383, 0.076 1.383, 0.076 
1.383, 0.113 1.451, 0.169 1.556, 0.169 1.556, 0.169 1.556, 0.184 1.574, 
0.293 1.707, 0.293 1.707, 0.293 1.707, 4.293 5.707, 4.444 5.831, 4.617 
5.924, 4.805 5.981, 5.000 6.000, 5.195 5.981, 5.383 5.924, 5.556 5.831, 
5.707 5.707, 5.831 5.556, 5.924 5.383, 5.981 5.195, 6.000 5.000, 5.981 
4.805, 5.924 4.617, 5.831 4.444, 5.707 4.293, 1.707 0.293, 1.707 0.293, 
1.707 0.293, 1.707 0.293, 1.700 0.287, 1.556 0.169, 1.556 0.169, 1.556 
0.169, 1.474 0.125, 1.383 0.076, 1.383 0.076, 1.383 0.076, 1.293 0.049, 
1.195 0.019, 1.195 0.019, 1.195 0.019, 1.094 0.009, 1.000 0.000, 1.000 
0.000, 1.000 0.000, 0.874 0.012, 0.805 0.019, 0.805 0.019, 0.805 0.019, 
0.680 0.057, 0.617 0.076, 0.617 0.076, 0.617 0.076, 0.520 0.128, 0.444 
0.169, 0.444 0.169, 0.444 0.169, 0.384 0.218, 0.293 0.293, 0.293 0.293, 
0.293 0.293, 0.218 0.384, 0.169 0.444, 0.169 0.444, 0.169 0.444, 0.128 
0.521, 0.076 0.617, 0.076 0.617, 0.076 0.617, 0.048 0.710, 0.019 0.805, 
0.019 0.805, 0.019 0.805, 0.011 0.890, 0.000 1.000, 0.000 1.000))

The difference is in one coordinate pair:
0.494 0.142
vs
0.520 0.128

Is Buffer supposed to work on geomcollections such as the one below and 
why would there be a slight discrepancy between results?

Thanks!


#include <geos_c.h>
#include <stdio.h>
#include <stdlib.h>

#define FALSE 0
#define TRUE 1

int main(int argc, char *argv[])
{
     GEOSGeometry *geom, *buffer;
     GEOSContextHandle_t handle;
     GEOSWKTReader *reader;
     GEOSWKTWriter *writer;
     char *wkt;

     handle = initGEOS_r(NULL, NULL);

     reader = GEOSWKTReader_create_r(handle);
     writer = GEOSWKTWriter_create_r(handle);

     geom = GEOSWKTReader_read_r(handle, reader, 
"GEOMETRYCOLLECTION(POINT(1 1), LINESTRING(1 1, 2 2, 4 4, 5 5))");

     GEOSWKTWriter_setRoundingPrecision_r(handle, writer, 3);
     GEOSWKTWriter_setTrim_r(handle, writer, FALSE);
     buffer = GEOSBuffer_r(handle, geom, 1, 8);
         wkt = GEOSWKTWriter_write_r(handle, writer, buffer);
         printf("Buffer: %s\n", wkt);

     return 0;
}

-- 
Alex
http://bit.ly/geodb

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/geos-devel/attachments/20120201/fe8533c0/attachment.html


More information about the geos-devel mailing list