-
Notifications
You must be signed in to change notification settings - Fork 31
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
Implement nearestPointOn(Multi)Line
and internal intersects
helper
#56
Conversation
Thank you for you PR – really great work so far! 😃
I could see a use case where you would get data dynamically and don't know which of the two types it is. In this case I think, it would make sense to create a version with
This is a major design decision of this lib you are pointing out. It is also – again 😢 – because Dart does not have union types.
I think it's fine if it is in the same PR, but we could maybe point it out in the title. |
nearestPointOn(Multi)Line
nearestPointOn(Multi)Line
and internal lineIntersect
helper
I'll open a discussion topic on this shortly - let's see if we can figure something out. Edit: Opened as #58.
I've updated the title and I'll see about those unit tests today. |
2e5561c
to
14a9ce6
Compare
I have found that the In the original Turf.js implementation, this is solved differently; it just counts all lines in the I couldn't implement unit tests for |
nearestPointOn(Multi)Line
and internal lineIntersect
helpernearestPointOn(Multi)Line
and internal intersect
helper
nearestPointOn(Multi)Line
and internal intersect
helpernearestPointOn(Multi)Line
and internal intersects
helper
Am I understanding it right, that we basically have a superset oft the functionality of the original implementation, “index” is the same? This line property is an excellent new idea btw 👍👍👍👍👍🔥
But the test folder is in the same package. I think it should be possible to include the implementation file like this: |
Not exactly.
You're right, that's my mistake - you indeed can import it from the same package. I'll get on those tests. |
What about keeping |
Seems reasonable, I'll look into it! |
Any update on the Is this PR ready for review anyways? |
I think it's an excellent idea, I just haven't had the time to implement it yet - apologies for that. It needs this modification, unit test for the helper function, and a rebase. I'll get to it as soon as I can. |
If you‘re okay with it, I will continue your efforts @skreborn in branch |
Of course, and thank you! I really am finding it hard at the moment to work on it myself. |
closed in favor of #87 |
The original implementation in Turf.js handles both
LineString
andMultiLineString
objects with a union type. However, since Dart has no support for such, I've opted for creating two separate methods instead of resorting to runtime type checking. This means that there is both anearestPointOnLine
and anearestPointOnMultiLine
. If you'd rather go a different route with this, I'm happy to make the changes.I haven't implemented
Raw
versions of these functions as I didn't particularly see the point - I hope that's okay. There are, however, some internal functions and data structures private tonearest_point_on_line.dart
, as it makes the implementations cleaner and parts of it reusable within the same file - specifically,nearestPointOnMultiLine
uses the implementation ofnearestPointOnLine
internally.I've also written tests based on the input and expected output values in the original Turf.js implementation. They all pass.
There is an extra file included within this PR that doesn't strictly belong;
intersection.dart
contains code that finds the geometrical intersection between two lines. This function has not been exported from the library, but it can be used in the future to implementlineIntersect
(and consequently numerous other methods that depend on it). If you'd like, I can submit it as a separate PR.