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

New module @turf/boolean-parallel #941

Merged
merged 5 commits into from
Sep 16, 2017
Merged

New module @turf/boolean-parallel #941

merged 5 commits into from
Sep 16, 2017

Conversation

stebogit
Copy link
Collaborator

Ref. #735

/**
 * Boolean-Parallel returns True if each segment of `line1` is parallel to the correspondent
 * segment of `line2`
 *
 * @name booleanParallel
 * @param {Geometry|Feature<LineString>} line1 GeoJSON Feature or Geometry
 * @param {Geometry|Feature<LineString>} line2 GeoJSON Feature or Geometry
 * @returns {Boolean} true/false if the lines are parallel
 * @example
 * var line1 = turf.lineString([[0, 0], [0, 1]]);
 * var line2 = turf.lineString([[1, 0], [1, 1]]);
 *
 * turf.booleanParallel(line1, line2);
 * //=true
 */
module.exports = function (line1, line2) {

The module supports only LineStrings (feature or geometry), leaving the user to decide how to apply the comparison among multi lines.

Note: the definition of comparison is based on segment having the same slope on the map plain, i.e. equal rhumb-bearing.
I don't know which definition has, if existing, parallelism on a sphere, but I feel it would be beyond Turf applications.

@stebogit stebogit added this to the 4.8.0 milestone Sep 14, 2017
@stebogit stebogit self-assigned this Sep 14, 2017
* @param {string} name of the variable
* @returns {string} Feature's type
*/
function getType(geojson, name) {
Copy link
Member

Choose a reason for hiding this comment

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

@stebogit This private looks great, we should add this to @turf/invariant.

Similar to getGeomType

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yeah, I always wondered why we didn't have that there 😄

Copy link
Member

Choose a reason for hiding this comment

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

👍 I'll add it

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.

👍 Looks great!

@@ -13,7 +13,6 @@ test('turf-boolean-parallel', t => {
const [line1, line2] = geojson.features;
const result = booleanParallel(line1, line2);

if (process.env.SHAPELY) shapely.contains(line1, line2).then(result => t.true(result, '[true] shapely - ' + name));
Copy link
Collaborator Author

@stebogit stebogit Sep 17, 2017

Choose a reason for hiding this comment

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

@DenisCarriere out of curiosity why did you remove this?
Many other boolean modules have that, some of them also have

if (process.env.JSTS) t.false(booleanJSTS('within', feature1, feature2), '[false] JSTS - ' + name);

What's their use exactly?

@stebogit
Copy link
Collaborator Author

Woo-hoo!! 😄:+1:

@DenisCarriere DenisCarriere modified the milestones: 4.8.0, 5.0.0 Sep 29, 2017
@DenisCarriere DenisCarriere mentioned this pull request Nov 9, 2017
14 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 this pull request may close these issues.

2 participants