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

pointOnLine.location does not return correct distance #722

Closed
Andi-Lo opened this issue May 8, 2017 · 10 comments
Closed

pointOnLine.location does not return correct distance #722

Andi-Lo opened this issue May 8, 2017 · 10 comments
Labels

Comments

@Andi-Lo
Copy link

Andi-Lo commented May 8, 2017

I currently wonder if the @turf/pointOnLine package does return a wrong location value.
Here is a short fiddle of the problem:

http://jsfiddle.net/andi_lo/95q4Lgqc/

I would like to set a point (which is a train station in my project) onto the polyline (representing the routes shape) via turf.pointOnLine and use the returning location property as of how far the train traveled. However if I use turf.along with the distance provided by turf.pointOnLine(...).properties.location I will get a point that does not match my expectations. I would expect to get a point that lays onto the station but I get a point that is positioned falsely.

turf_pointonline

The used geojson is inside the fiddle. Feel free to ask for clarification if needed.

@DenisCarriere
Copy link
Member

@Andi-Lo Thanks for reporting this issue. I've managed to get the result closer to the station point by applying reverse() to the LineString's coordinates, however it's still a bit off, one would assume that doing pointOnLine+ along would result in nearly the same location.

We should try to replicate this behavior in the TurfJS tests.

Example - reverse()

lineString.features[0].geometry.coordinates.reverse();

image

@DenisCarriere
Copy link
Member

Related To-Do on @turf/along: #691

@Andi-Lo
Copy link
Author

Andi-Lo commented May 10, 2017

Thanks for reply,

until it is fixed I will use a workaround (measuring all sub-segments with turfs lineDistance module)

@DenisCarriere
Copy link
Member

@Andi-Lo Feel free to send a PR if you do find a solution for the @turf/point-on-line issue you mentioned.

@dpmcmlxxvi
Copy link
Collaborator

@Andi-Lo Can you double check that this is resolved with PR #750 so the issue can be closed?

@Andi-Lo
Copy link
Author

Andi-Lo commented May 23, 2017

@dpmcmlxxvi not sure how to validate.

I would need to checkout the turf master branch and get myself a bundled turf.min.js file and include that in my project to see if results are not as expected or is there a faster way?

@dpmcmlxxvi
Copy link
Collaborator

@Andi-Lo That's what I do. Check out, install, and build. Then you can use packages/turf/turf.min.js. Not sure if there is a nightly build of the master branch built somewhere online. Maybe @DenisCarriere would know.

@DenisCarriere
Copy link
Member

There isn't any nightly builds, however it might be a good idea. The process would need to be automated and be based on the master branch.

@Andi-Lo
Copy link
Author

Andi-Lo commented Jun 7, 2017

With the latest release I updated the version of my fiddle:

https://jsfiddle.net/andi_lo/95q4Lgqc/

As you can see the result seems now correct to me. Nice work @dpmcmlxxvi !

@DenisCarriere
Copy link
Member

DenisCarriere commented Jun 7, 2017

👍 Glad it works, definitely nice work from @dpmcmlxxvi

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants