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

along with negative distance #2567

Open
leiflinse-trivector opened this issue Jan 11, 2024 · 4 comments · May be fixed by #2573
Open

along with negative distance #2567

leiflinse-trivector opened this issue Jan 11, 2024 · 4 comments · May be fixed by #2573

Comments

@leiflinse-trivector
Copy link

While porting the along method to dart_turf, I noticed that if you pass a negative distance to it, it will not return the first point in a line.

It is possible to solve this by a special condition at the start of the method, just after coords has been obtained. If distance is negative, then return the first coordinate.

Dart port: dartclub/turf_dart#153

@smallsaucepan
Copy link
Member

Hi @leiflinse-trivector. Thanks for raising this. Could you please read #2148 and let us know how that compares to your request? It sounds like we have two requests for different behaviour from a negative offset.

@leiflinse-trivector
Copy link
Author

I think either clamping or a documented "from end" behavior is fine. But as it is now, it doesn't neither forbid negative input nor define what happens.

My reasoning is that when you input a distance that is longer then the total length of the line string, then it currently returns the last point, so in analogy of that was that if you "undershoot" the start by giving a negative value, it would clamp to the start.

But I also can see that the count from end behavior can be useful in some cases.

@smallsaucepan
Copy link
Member

My take on it would be, if the user passes an along value longer than the length of the line, it's probably accidental, and returning the farthest point on the line seems reasonable. If the user passes a negative value it's probably intentional and they are signalling they're specifically expecting different behaviour.

My gut feel is we would fix this according to #2148, so the behaviour is defined and no error is thrown. Is that a behaviour you'd be happy to align dart_turf with?

@leiflinse-trivector
Copy link
Author

I am not the maintainer of dart_turf, but if turf.js does go with #2148, I am in favor for dart_turf to use the same behavior to make transition between the two libraries easy for developers. Depending on the time frame, if it makes sense for my project, I may help on updating dart_turf.

@Leffe108 Leffe108 linked a pull request Jan 20, 2024 that will close this issue
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants