-
-
Notifications
You must be signed in to change notification settings - Fork 76
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
Fix compare segments endpoint touching #115
base: master
Are you sure you want to change the base?
Fix compare segments endpoint touching #115
Conversation
WIll try and do a proper review this evening @bluenote10 but it looks relatively straight forward - and bonus marks for including new tests! |
With the revised changes to the demo site in #119 this no longer seems to fix #110 , sorry @bluenote10 :( 97 does seem to work though 👍 |
I've done all debugging on nodejs, and the tests also succeed in nodejs. Do you mean that after we fix #118, it doesn't work in the demo site, and we have effectively reached a point where the browser and the (node based) test suit behave differently? If #97 works, but #110 doesn't I think I know what is happening: This PR fixes the issue that occurs if Maybe it's worth checking if |
Are you able to create a gist or code snippet @bluenote10 which shows the coords you use to generate the 0 score in nodejs? I'll then run some browser comparisons and can see if I can make things a bit more cross-platform compatible. |
The test case for #110 is already part of the PR, see the |
Ah, now I got it! The We should probably follow up on the idea of #67 -- this had already saved me a lot of time, it is very confusing that omitting the last coordinate is allowed sometimes, not other times. |
That was driving me crazy - good find @bluenote10 ! |
Shall I take a look at this one to merge? |
I think it would make more sense to first merge #113 This PR only fixes a small problem of |
I'm not sure whether this can be solved by solely at the segment comparison level. Just to give a simpler example, here's a union failing: with triangles coordinates The logic of I haven't fully cooked up a fix for now. But I think the right way of solving this is to be much more careful in Besides I suspect that if you start mutating |
This fixes a bug in
compare_segments
related to start/left points falling exactly onto the other segment. In this case the proper solution is to use the end/right points for the ordering.In case it helps, here is what I used to debug #110:
When inserting the "highlighted" segment, its neighbors are the ones labeled with "next" and "prev". Normally "next" should always be the one above. If a start/left point falls exactly on top of a segment the existing implementation would always report the segment is "above" even though it can be "below". In the follow-up this leads to wrongly filled
itOut
/otherInOut
/inResult
fields.The behavior can also be verified in test case #110 by multiplying all y values by -1 -- in this case the old logic happened to be right.
I think the right solution is to determine the case when the start/left point falls onto the other segment and use the right point to determine the order in this case. This is also how it is done in polybooljs.
Fixes:
Other tested issues: