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

Fix lineIntersects to align with Turf.js implementation #1350

Closed
wants to merge 1 commit into from

Conversation

OttyLab
Copy link
Contributor

@OttyLab OttyLab commented Jan 18, 2022

Summary

lineIntersects excludes line segment endpoints which is not consistent with Turf.js / Turf-Swift.

Detail

This and this if conditions causes the difference. Turf.js implementation is here.

Reference

@@ -346,11 +346,11 @@ private static LineIntersectsResult lineIntersects(double line1StartX, double li
+ (varA * (line1EndY - line1StartY))).build();

// if line1 is a segment and line2 is infinite, they intersect if:
if (varA > 0 && varA < 1) {
if (varA >= 0 && varA <= 1) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could we add tests for the changes?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pengdev Thanks, I added the test.

@LukasPaczos
Copy link
Contributor

I'd be in favor of merging this PR with #1348 and using the public API to test the boundaries, instead of using reflection.

public void testLineIntersects() throws
NoSuchMethodException, SecurityException,
IllegalAccessException, IllegalArgumentException, InvocationTargetException {
Method method = TurfMisc.class.getDeclaredMethod("lineIntersects",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd like to suggest testing against the public API instead of using reflections.

@OttyLab
Copy link
Contributor Author

OttyLab commented Jan 27, 2022

I close this PR because the fix is merged into #1348 as I mentioned here.

@OttyLab OttyLab closed this Jan 27, 2022
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

Successfully merging this pull request may close these issues.

3 participants