-
Notifications
You must be signed in to change notification settings - Fork 943
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
Conversation
added multiLineString test; updated relevant files;
There was a problem hiding this 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!
packages/turf-point-on-line/index.js
Outdated
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') { |
There was a problem hiding this comment.
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');
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤦♂️ of course! Dumb me 😅
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
exactly!
simpler => better!! 😃
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed! 😄
packages/turf-point-on-line/index.js
Outdated
* | ||
* @name pointOnLine | ||
* @param {Feature<LineString>} line line to snap to | ||
* @param {Feature<LineString>|Feature<MultiLineString>} lines lines to snap to |
There was a problem hiding this comment.
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
There was a problem hiding this 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.
@stebogit Awesome! 🎉 |
Fixes #835
Still the module returns a single
point
, the closest of all thelines
of theMultiLineString
.Is it correct?
CC: @jbccollins @DenisCarriere