Opened 2 years ago
Closed 2 years ago
#1018 closed defect (fixed)
Geometry->difference() crashes
Reported by: | pramsey | Owned by: | |
---|---|---|---|
Priority: | major | Milestone: | 3.8.1 |
Component: | Default | Version: | 3.8.0 |
Severity: | Unassigned | Keywords: | |
Cc: |
Description
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; }
Note:
See TracTickets
for help on using tickets.
Fixed in 3.8 and master