Closed fnattino closed 5 months ago
Hey, we've actually noticed the same last week and @anastassiavybornova might be looking into that as well. If you have a fix, PR would be very welcome!
yes, looking into it as we speak, i also suspect there is a bug in the internal _points_set_angle
function, happy to look further into what you have to share @fnattino on this, too! (in particular, i think the cases D and E from Table 1 here: http://journals.sagepub.com/doi/10.1177/2399808320967680 are not correctly identified by the mentioned func)
...and in fact yes, the case you're describing (both lines in the same quadrant) is not even accounted for as far as i can tell
Hi @anastassiavybornova @martinfleis, great to hear you also noticed this! This crude fix here seems to solve the problem: https://github.com/pysal/momepy/compare/main...fnattino:momepy:fix-angle-between-lines?expand=1
However, I wonder whether one could do this more cleanly by getting _points_set_angle
to work for all cases..
Maybe tangential but we also have a function to measure angles here https://github.com/pysal/momepy/blob/main/momepy/functional/_dimension.py
Maybe tangential but we also have a function to measure angles here https://github.com/pysal/momepy/blob/main/momepy/functional/_dimension.py
@martinfleis just to be sure, you mean _get_angle_njit()
here?
Yes. I was on the phone so just wanted to drop that in without having time to look at it. It seems to be the same formula used in existing coins and in #630 as well, so it was a pointless suggestion :).
Describe the problem
Hi there, thanks a lot for this fantastic library!
I am playing with momepy's COINS implementation and I have identified some strange behaviour when creating strokes over edges that connect with some sharp angles. I have narrowed down the issue to what I believe being wrong angles being calculated for segments lying in the same quadrant of the Cartesian plane (see examples below).
If I understand
_angle_between_two_lines
correctly, one checks whether two segments lie on the same side of the horizontal plane (e.g. here). If this is found to be the case, the result seems to assume that the two segments lie on opposite sides of the vertical plane (angle = 180 - (abs(l1orien) + abs(l2orien))
). The case with the segments lying on the same side of the vertical plane (angle = abs(l1orien - l2orien)
) seems not to be covered. Or am I missing something here?Happy to contribute with a PR if you confirm this is unwanted behaviour!
Steps to reproduce
For the following pair of segments, I get these angles:
while I would have expect instead something like:
Visualization of the segments:
Versions of your packages
momepy=0.6.0
Your operating system
macOS - x86-64
Additional context
No response