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 returns a point that is not found by pointOnLine #691

Closed
grundid opened this issue Apr 25, 2017 · 4 comments
Closed

along returns a point that is not found by pointOnLine #691

grundid opened this issue Apr 25, 2017 · 4 comments
Assignees
Labels
Milestone

Comments

@grundid
Copy link
Contributor

grundid commented Apr 25, 2017

When I generate a point using the along function the pointOnLine function does not see this point as on line. It also returns a NaN value for location.
Example:

const line1 = turf.lineString([[7, 50], [8, 50], [9, 50]]);
const pointAlong = turf.along(line1, 10);
const pointOnLine = turf.pointOnLine(line1, pointAlong);

The resulting pointOnLine value looks like this:

{ type: 'Feature',
  properties: { dist: 0.057664328657654904, location: NaN, index: 0 },
  geometry: { type: 'Point', coordinates: [ 7.139803396792796, 50 ] } }

It is not documented that location can become NaN.

I would assume that the pointOnLine should match the pointAlong. This is the case if I pass for example the point [8, 50]. The result is:

{ type: 'Feature',
  properties: { dist: 0, index: 1, location: 71.49662609671813 },
  geometry: { type: 'Point', coordinates: [ 8, 50 ] } }
@DenisCarriere
Copy link
Member

Nice to do: Can you use ```javascript to style your Markdown codeblocks (my eyes are bad at differentiating comments vs. code blocks).

I also noticed location = NaN while updating the test cases today.

location: distance along the line between start and the closest point.

I would assume if the start point & closest point are the same, then the "distance along the line" would be 0 instead of NaN.

@dpmcmlxxvi
Copy link
Collaborator

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

@grundid
Copy link
Contributor Author

grundid commented May 24, 2017

I'm sorry, but I don't have a test setup for this repo. I'll try after the release and reopen if this is still an issue.

DenisCarriere added a commit that referenced this issue May 24, 2017
@DenisCarriere
Copy link
Member

Added tests for this issue, location does not return NaN anymore.

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