polyskel
polyskel copied to clipboard
Incorrect skeleton output of running Demo.py on geographical coordinates
I'm trying to run the demo script on some own testfiles in which the polygon is represented by geographical coordinates (float values with 7 decimal places). Do geographical coordinates in this format work for the algorithm or do I need to consider something special here? Thanks in advance!
What is the wrong output you're getting? Could you share them?
I haven't worked on this project since ages, but iirc there is an issue with the numeric calculations for too small floating point numbers (intersections and such don't happen due to the computation errors inherent to floating point arithmetic and precision).
@Botffy the test polygon I'm trying to generate a skeleton for is representing the nodes of a rectangular building footprint in latitude, longitude coorinates (coming from OpenStreetMap). Therefore the input polygon is in counterclockwise order and of the following format:
7.1489466,50.9653194 7.1489765,50.9652408 7.1491593,50.9652698 7.1491291,50.9653486
When running the demo script, the generated skeleton looks like this:
The output (on DEBUG level) looks like the following: `new line inn polygon: 7.1489466,50.9653194
new line inn polygon: 7.1489765,50.9652408
new line inn polygon: 7.1491593,50.9652698
new line inn polygon: 7.1491291,50.9653486
DEBUG:name:Created LAV LAV 4378335216 INFO:name:Created vertex Vertex (reflex) (7.15;50.97), bisector Ray2(<7.15, 50.97> + u<-1.34, 0.78>), edges LineSegment2(<7.15, 50.97> to <7.15, 50.97>) LineSegment2(<7.15, 50.97> to <7.15, 50.97>) INFO:name:Created vertex Vertex (reflex) (7.15;50.97), bisector Ray2(<7.15, 50.97> + u<-0.63, -1.09>), edges LineSegment2(<7.15, 50.97> to <7.15, 50.97>) LineSegment2(<7.15, 50.97> to <7.15, 50.97>) INFO:name:Created vertex Vertex (reflex) (7.15;50.97), bisector Ray2(<7.15, 50.97> + u<1.35, -0.78>), edges LineSegment2(<7.15, 50.97> to <7.15, 50.97>) LineSegment2(<7.15, 50.97> to <7.15, 50.97>) INFO:name:Created vertex Vertex (reflex) (7.15;50.97), bisector Ray2(<7.15, 50.97> + u<0.63, 1.09>), edges LineSegment2(<7.15, 50.97> to <7.15, 50.97>) LineSegment2(<7.15, 50.97> to <7.15, 50.97>) DEBUG:name:looking for split candidates for vertex Vertex (7.15;50.97) DEBUG:name: considering EDGE _OriginalEdge(edge=LineSegment2(<7.15, 50.97> to <7.15, 50.97>), bisector_left=Ray2(<7.15, 50.97> + u<0.63, 1.09>), bisector_right=Ray2(<7.15, 50.97> + u<-1.34, 0.78>)) DEBUG:name: considering EDGE _OriginalEdge(edge=LineSegment2(<7.15, 50.97> to <7.15, 50.97>), bisector_left=Ray2(<7.15, 50.97> + u<-1.34, 0.78>), bisector_right=Ray2(<7.15, 50.97> + u<-0.63, -1.09>)) DEBUG:name: considering EDGE _OriginalEdge(edge=LineSegment2(<7.15, 50.97> to <7.15, 50.97>), bisector_left=Ray2(<7.15, 50.97> + u<-0.63, -1.09>), bisector_right=Ray2(<7.15, 50.97> + u<1.35, -0.78>)) DEBUG:name: considering EDGE _OriginalEdge(edge=LineSegment2(<7.15, 50.97> to <7.15, 50.97>), bisector_left=Ray2(<7.15, 50.97> + u<1.35, -0.78>), bisector_right=Ray2(<7.15, 50.97> + u<0.63, 1.09>)) DEBUG:name:looking for split candidates for vertex Vertex (7.15;50.97) DEBUG:name: considering EDGE _OriginalEdge(edge=LineSegment2(<7.15, 50.97> to <7.15, 50.97>), bisector_left=Ray2(<7.15, 50.97> + u<0.63, 1.09>), bisector_right=Ray2(<7.15, 50.97> + u<-1.34, 0.78>)) DEBUG:name: considering EDGE _OriginalEdge(edge=LineSegment2(<7.15, 50.97> to <7.15, 50.97>), bisector_left=Ray2(<7.15, 50.97> + u<-1.34, 0.78>), bisector_right=Ray2(<7.15, 50.97> + u<-0.63, -1.09>)) DEBUG:name: considering EDGE _OriginalEdge(edge=LineSegment2(<7.15, 50.97> to <7.15, 50.97>), bisector_left=Ray2(<7.15, 50.97> + u<-0.63, -1.09>), bisector_right=Ray2(<7.15, 50.97> + u<1.35, -0.78>)) DEBUG:name: considering EDGE _OriginalEdge(edge=LineSegment2(<7.15, 50.97> to <7.15, 50.97>), bisector_left=Ray2(<7.15, 50.97> + u<1.35, -0.78>), bisector_right=Ray2(<7.15, 50.97> + u<0.63, 1.09>)) DEBUG:name:looking for split candidates for vertex Vertex (7.15;50.97) DEBUG:name: considering EDGE _OriginalEdge(edge=LineSegment2(<7.15, 50.97> to <7.15, 50.97>), bisector_left=Ray2(<7.15, 50.97> + u<0.63, 1.09>), bisector_right=Ray2(<7.15, 50.97> + u<-1.34, 0.78>)) DEBUG:name: considering EDGE _OriginalEdge(edge=LineSegment2(<7.15, 50.97> to <7.15, 50.97>), bisector_left=Ray2(<7.15, 50.97> + u<-1.34, 0.78>), bisector_right=Ray2(<7.15, 50.97> + u<-0.63, -1.09>)) DEBUG:name: considering EDGE _OriginalEdge(edge=LineSegment2(<7.15, 50.97> to <7.15, 50.97>), bisector_left=Ray2(<7.15, 50.97> + u<-0.63, -1.09>), bisector_right=Ray2(<7.15, 50.97> + u<1.35, -0.78>)) DEBUG:name: considering EDGE _OriginalEdge(edge=LineSegment2(<7.15, 50.97> to <7.15, 50.97>), bisector_left=Ray2(<7.15, 50.97> + u<1.35, -0.78>), bisector_right=Ray2(<7.15, 50.97> + u<0.63, 1.09>)) DEBUG:name:looking for split candidates for vertex Vertex (7.15;50.97) DEBUG:name: considering EDGE _OriginalEdge(edge=LineSegment2(<7.15, 50.97> to <7.15, 50.97>), bisector_left=Ray2(<7.15, 50.97> + u<0.63, 1.09>), bisector_right=Ray2(<7.15, 50.97> + u<-1.34, 0.78>)) DEBUG:name: considering EDGE _OriginalEdge(edge=LineSegment2(<7.15, 50.97> to <7.15, 50.97>), bisector_left=Ray2(<7.15, 50.97> + u<-1.34, 0.78>), bisector_right=Ray2(<7.15, 50.97> + u<-0.63, -1.09>)) DEBUG:name: considering EDGE _OriginalEdge(edge=LineSegment2(<7.15, 50.97> to <7.15, 50.97>), bisector_left=Ray2(<7.15, 50.97> + u<-0.63, -1.09>), bisector_right=Ray2(<7.15, 50.97> + u<1.35, -0.78>)) DEBUG:name: considering EDGE _OriginalEdge(edge=LineSegment2(<7.15, 50.97> to <7.15, 50.97>), bisector_left=Ray2(<7.15, 50.97> + u<1.35, -0.78>), bisector_right=Ray2(<7.15, 50.97> + u<0.63, 1.09>)) skeleton generated: []`
Do I have to transform the polygon points from geographic coordinates (latitude, longitude) into another representation first in order to make the algorithm work properly? If so, what kind of coordinate system do I need to convert to?
I have fixed my problem above by converting my input polygon from geographic coordinates into a UTM coordinate system and then into a relative cartesian system, where the coordinates represent the distances to a reference point (x,y).
The results don't look very satisfying, especially for L-shaped input polygons, maybe due to the algorithm having problems with too small distances. Minor lack of accuracy when transforming into cartesian coordinate system might also be a factor here:
This converted one looks correct to me! It's a good roof. If you multiplied the input by a factor of ten or so, it would look less pixelated.
I'm sorry I cannot be of more help at the moment. I've been planning to revisit this project since ages :$