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

Added MultiLineString support for @turf/point-on-line #838

Merged
merged 5 commits into from
Jul 13, 2017

Conversation

stebogit
Copy link
Collaborator

Fixes #835

Still the module returns a single point, the closest of all the lines of the MultiLineString.
Is it correct?

CC: @jbccollins @DenisCarriere

added multiLineString test;
updated relevant files;
Copy link

@jbccollins jbccollins left a comment

Choose a reason for hiding this comment

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

This looks great! Thank you for the quick fix!

throw new Error('input must be a LineString Feature or Geometry');
module.exports = function (lines, pt, units) {
// validation
if (lines.type !== 'Feature' && lines.type !== 'LineString' && lines.type !== 'MultiLineString' && lines.geometry.type !== 'LineString' && lines.geometry.type !== 'MultiLineString') {
Copy link
Member

Choose a reason for hiding this comment

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

Condensed this validation step to this:

var type = (lines.geometry) ? lines.geometry.type : lines.type;
if (type !== 'LineString' && type !== 'MultiLineString') {
    throw new Error('lines must be LineString or MultiLineString');
}

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

🤦‍♂️ of course! Dumb me 😅

Copy link
Member

Choose a reason for hiding this comment

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

No no... it's just simpler to read this way.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

exactly!
simpler => better!! 😃

Copy link
Member

Choose a reason for hiding this comment

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

Agreed! 😄

*
* @name pointOnLine
* @param {Feature<LineString>} line line to snap to
* @param {Feature<LineString>|Feature<MultiLineString>} lines lines to snap to
Copy link
Member

Choose a reason for hiding this comment

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

To support both Feature & Geometry, so far the JSDocs have been declared like this:

/**
 * @param {Geometry|Feature<LineString|MultiLineString>} lines lines to snap to
 * @param {Geometry|Feature<Point>|number[]} pt point to snap from

- Improved Typescript Definition with additional properties
- Added Typescript tets
- Added Geometry tests
Copy link
Member

@DenisCarriere DenisCarriere left a comment

Choose a reason for hiding this comment

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

Doesn't look like the MultiString handling is correct.

Using coordAll isn't the right approach for this.

@DenisCarriere
Copy link
Member

Using happening when the point is between the MultiLineString.
image

@stebogit
Copy link
Collaborator Author

Fixed with flattenEach.

screen shot 2017-07-12 at 11 52 17 pm

Added also a more complex test:
screen shot 2017-07-12 at 11 58 07 pm

@DenisCarriere
Copy link
Member

DenisCarriere commented Jul 13, 2017

@stebogit Awesome! 🎉

@DenisCarriere DenisCarriere merged commit 906ce11 into master Jul 13, 2017
@DenisCarriere DenisCarriere deleted the point-on-line-fix branch July 13, 2017 19:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

MultiLineString support for point-on-line
3 participants