#1018: Geometry->difference() crashes ------------------------+-------------------------- Reporter: pramsey | Owner: geos-devel@… Type: defect | Status: new Priority: major | Milestone: 3.8.1 Component: Default | Version: 3.8.0 Severity: Unassigned | Keywords: ------------------------+-------------------------- https://github.com/libgeos/geos/issues/290
{{{ #include <iostream> #include <memory> #include <geos/geom/GeometryFactory.h> #include <geos/geom/Geometry.h> #include <geos/io/WKTWriter.h> #include <geos/io/WKTReader.h> struct Rectangle { double west = -180.0; double east = 180.0; double south = -90.0; double north = 90.0; }; std::unique_ptr< geos::geom::Geometry > CreateRectangleGeometry(const Rectangle& rect) { auto wkt_reader = geos::io::WKTReader(); std::string wkt = "POLYGON((" + std::to_string(rect.west) + " " + std::to_string(rect.north) + ", " + std::to_string(rect.east) + " " + std::to_string(rect.north) + ", "+ std::to_string(rect.east) + " " + std::to_string(rect.south) + ", " + std::to_string(rect.west) + " " + std::to_string(rect.south) +", " + std::to_string(rect.west) + " " + std::to_string(rect.north) + "))"; auto geom = wkt_reader.read(wkt); return geom; } int main(int argc, char* argv[]){ Rectangle rect; rect.west = 0.0; rect.east = 2.0; rect.south = 0.0; rect.north = 2.0; Rectangle rect2; rect2.west = 0.1; rect2.east = 4.0; rect2.south = 0.1; rect2.north = 1.9; auto geom1 = CreateRectangleGeometry(rect); auto geom2 = CreateRectangleGeometry(rect2); auto geom3 = geom2->difference(geom1.get()); geos::io::WKTWriter writer; std::cout << writer.write(geom3.get()); return 0; } }}} -- Ticket URL: <https://trac.osgeo.org/geos/ticket/1018> GEOS <http://trac.osgeo.org/geos> GEOS (Geometry Engine - Open Source) is a C++ port of the Java Topology Suite (JTS).
_______________________________________________ geos-devel mailing list geos-devel@lists.osgeo.org https://lists.osgeo.org/mailman/listinfo/geos-devel