Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect skeleton output of running Demo.py on geographical coordinates #27

Open
nikprt opened this issue Nov 10, 2023 · 4 comments
Open

Comments

@nikprt
Copy link

nikprt commented Nov 10, 2023

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!

@Botffy
Copy link
Owner

Botffy commented Nov 10, 2023

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).

@nikprt
Copy link
Author

nikprt commented Nov 14, 2023

@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:
Bildschirmfoto 2023-11-14 um 10 19 05

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?

@nikprt
Copy link
Author

nikprt commented Nov 14, 2023

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:
Bildschirmfoto 2023-11-14 um 16 43 41

@Botffy
Copy link
Owner

Botffy commented Nov 14, 2023

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 :$

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants