-
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
Fixes #820 - @turf/intersect
#890
Conversation
packages/turf-intersect/test.js
Outdated
@@ -3,6 +3,7 @@ const fs = require('fs'); | |||
const test = require('tape'); | |||
const load = require('load-json-file'); | |||
const write = require('write-json-file'); | |||
var truncate = require('@turf/truncate'); |
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.
poor lonely var
... 😢 he feels old next to all his younger const
siblings.
packages/turf-intersect/index.js
Outdated
var a = reader.read(JSON.stringify(geom1)); | ||
var b = reader.read(JSON.stringify(geom2)); | ||
var a = reader.read(JSON.stringify(truncate(geom1))); | ||
var b = reader.read(JSON.stringify(truncate(geom2))); |
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.
Since truncate
does the clone
operation, we can drop JSON.stringify
from the mix.
packages/turf-intersect/index.js
Outdated
if (intersection.isEmpty()) { | ||
return undefined; | ||
} | ||
if (intersection.isEmpty()) return null; |
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.
Weren't we going to return a Feature<null>
instead of null
?
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.
Sorry I didn't noticed your suggestion in the issue comment.
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 worries 👍
I think we are all in agreement that if we have no results in collection of Features, then we would have an empty FeatureCollection, if the output is a single Feature which would be undefined
or null
then we would output a Feature<null>
that way things don't blow up when you chain TurfJS methods by sending a null
as input to another module.
I like the new |
Shouldn't this have bumped the major version as it changed the API for turf.union? Any code that interpreted an undefined responses to mean there is no union breaks on this change. |
Feature<null>
if no geometryJSON.stringify
Ref #820