[geos-devel] lbgeos intersect skips first coordinates
Martin Davis
mtnclimb at gmail.com
Wed Jul 14 08:55:13 PDT 2021
The overlay operations do not necessarily preserve the exact sequence of
input vertices. This is the case for both GEOS and JTS. If you are seeing
a different, preferred order in JTS it's just by chance.
On Wed, Jul 14, 2021 at 7:46 AM Hector Nunez <hndiaz at yahoo.com> wrote:
> 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
>
> _______________________________________________
> geos-devel mailing list
> geos-devel at lists.osgeo.org
> https://lists.osgeo.org/mailman/listinfo/geos-devel
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/geos-devel/attachments/20210714/0efa3401/attachment-0001.html>
More information about the geos-devel
mailing list