Comments (3)
I did some debugging for the researcher who reported this problem, and came up with this patch that fixes the problem. However, I can't be sure that this is the right fix, since I had to make certain assumptions about the design.
What I found while debugging with the above dataset was that 15 polygon objects were created within the program (though the running commentary generated by the program says 13 polygons). What is then done in the exportPolygons() method (which writes out the results) is to loop through all the vertices for each polygon to add a point to the output data for each one; and having done so, one last point is added, which appears to be referencing the first vertex again. Perhaps this is to close the polygon.
In any event, of the 15 polygons, the first had no vertices after cleanup. So when the code tried to reference the first vertex of the polygon (in the last step above), it crashed with a segfault since no vertices existed for that polygon. Apparently the code was not designed for a polygon object with no vertices. Perhaps the vertices were all removed during cleanup.
My change was simply to skip the last step if there were no vertices in the polygon. Hopefully that was the right fix. The researcher now reports that the results using the above dataset look good.
Here is the patch for my fix. I had to inline it since GitHub issues don't support attachments:
--- pprepair.orig/IOWorker.cpp 2013-01-31 17:12:27.935176416 -0500
+++ pprepair/IOWorker.cpp 2013-01-31 17:17:42.605176467 -0500
@@ -1261,11 +1261,16 @@
for (std::vector<std::pair<PolygonHandle *, Polygon> >::iterator currentPolygon = outputPolygons.begin(); currentPolygon != outputPolygons.end(); ++currentPolygon) {
OGRPolygon polygon;
OGRLinearRing outerRing;
+ bool vertexPresent = false;
for (Ring::Vertex_iterator currentVertex = currentPolygon->second.outer_boundary().vertices_begin();
currentVertex != currentPolygon->second.outer_boundary().vertices_end();
++currentVertex) {
+ vertexPresent = true;
outerRing.addPoint(CGAL::to_double(currentVertex->x()), CGAL::to_double(currentVertex->y()));
- } outerRing.addPoint(CGAL::to_double(currentPolygon->second.outer_boundary().vertex(0).x()), CGAL::to_double(currentPolygon->second.outer_boundary().vertex(0).y()));
+ }
+ if (vertexPresent) {
+ outerRing.addPoint(CGAL::to_double(currentPolygon->second.outer_boundary().vertex(0).x()), CGAL::to_double(currentPolygon->second.outer_boundary().vertex(0).y()));
+ }
polygon.addRing(&outerRing);
for (Polygon::Hole_const_iterator currentRing = currentPolygon->second.holes_begin(); currentRing != currentPolygon->second.holes_end(); ++currentRing) {
OGRLinearRing innerRing;
Dennis
from pprepair.
Thanks for the report and the bug fix!
I've been quite busy lately, so I haven't been able to spend time on this project, but I'll take a look at this by the end of the week.
All the best,
Ken
from pprepair.
Ok, this has been solved in the newest version. Thanks again!
from pprepair.
Related Issues (20)
- Fails to build with GDAL 2.0
- --outerrors option doesn't work HOT 2
- pprepair for self-intersection increases the number of features HOT 1
- pprepair triangulation (--outtr option) contains invalid polygons HOT 2
- in the triangulation output, record an array with the original polygon IDs
- (p)prepair fails on it`s own output polygons (.shp) HOT 6
- pprepair generates lots of spikes (dangling edges) HOT 12
- In case of ties in the "r -LB" , RN choice should only be between the LB neighbors, not all neighbors
- Segmentation fault: 11 when working with empty properties in a geojson input file HOT 3
- segfault when reading features with no geometry HOT 4
- pprepair hangs HOT 3
- Tagging error with triangles? HOT 5
- Forced region splitting HOT 1
- Specifying SHP-file output doesn't work as advertised HOT 1
- Crash on first run HOT 1
- pprepair creates duplicate vertex
- pprepair hangs on this geometry HOT 2
- CGAL 5.0 support HOT 1
- [has fix] error: 'std::filesystem' has not been declared
- pprepair does not exit IOWorker::tagStack while loop
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pprepair.