[geos-devel] lbgeos intersect skips first coordinates
Hector Nunez
hndiaz at yahoo.com
Wed Jul 14 07:45:58 PDT 2021
Hi,
I found that the I use intersects the result shows that the first coordinates is not used.Here is a sample that I did using two same geometries that shows the issue.I tested similar code in Java using JTS and I don't have this issue.
// SIMPLE SIMULATION OF THE PROBLEM USING INTERSECTION using GEOS 3.9.1 geos::geom::GeometryFactory::Ptr Factory= geos::geom::GeometryFactory::create(); geos::geom::CoordinateSequence::Ptr coord_seq = Factory->getCoordinateSequenceFactory()->create((size_t)5, (size_t)0);
coord_seq->setAt(geos::geom::Coordinate(-180, 85.0), 0); coord_seq->setAt(geos::geom::Coordinate(180, 85.0), 1); coord_seq->setAt(geos::geom::Coordinate(180, -85.0), 2); coord_seq->setAt(geos::geom::Coordinate(-180, -85.0), 3); coord_seq->setAt(geos::geom::Coordinate(-180, 85.0), 4);
geos::geom::LinearRing * shell_test = Factory->createLinearRing(coord_seq.release()); geos::geom::Geometry::Ptr geom = std::unique_ptr<geos::geom::Geometry>(Factory->createPolygon(shell_test, NULL));
const geos::geom::Geometry::Ptr other = geom->clone();
for (size_t i = 0; i<geom->getNumPoints(); i++) printf( "geom %d [x=%f,y=%f]\n", i+1, geom->getCoordinates()->getX(i), geom->getCoordinates()->getY(i));
if (geom->intersects(other.get())) { std::cout << "GEOMETRIES INTERSECTS !!!!!"<< std::endl;
const geos::geom::Geometry::Ptr geom_intersected = geom->intersection(other.get());
for (size_t i = 0; i<geom_intersected->getNumPoints(); i++) printf( "geom_intersected %d [x=%f,y=%f]\n", i+1, geom_intersected->getCoordinates()->getX(i), geom_intersected->getCoordinates()->getY(i));
if (geom->compareTo(geom_intersected.get())) std::cout << "GEOMETRIES AFTER INTERSECTION ARE NOT THE SAME !!!!!"<< std::endl; } /* geom 1 [x=-150.000000,y=22.000000] geom 2 [x=150.000000,y=22.000000] geom 3 [x=150.000000,y=-22.000000] geom 4 [x=-150.000000,y=-22.000000] geom 5 [x=-150.000000,y=22.000000] // it should start with -150 geom_intersected 1 [x=150.000000,y=22.000000] geom_intersected 2 [x=150.000000,y=-22.000000] geom_intersected 3 [x=-150.000000,y=-22.000000] geom_intersected 4 [x=-150.000000,y=22.000000] geom_intersected 5 [x=150.000000,y=22.000000] */
Thanks
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/geos-devel/attachments/20210714/745fdbcc/attachment.html>
More information about the geos-devel
mailing list