diff --git a/lerna.json b/lerna.json
index 8a2b31580a..ea1b75adc2 100644
--- a/lerna.json
+++ b/lerna.json
@@ -1,7 +1,7 @@
{
"lerna": "2.0.0-beta.34",
"npmClient": "yarn",
- "version": "4.3.1",
+ "version": "4.4.0",
"packages": [
"packages/*"
]
diff --git a/packages/turf-along/package.json b/packages/turf-along/package.json
index 3cb1ca8868..ccb6241ed1 100644
--- a/packages/turf-along/package.json
+++ b/packages/turf-along/package.json
@@ -1,6 +1,6 @@
{
"name": "@turf/along",
- "version": "4.3.0",
+ "version": "4.4.0",
"description": "turf along module",
"main": "index.js",
"types": "index.d.ts",
@@ -34,9 +34,9 @@
"tape": "^3.5.0"
},
"dependencies": {
- "@turf/bearing": "^4.3.0",
- "@turf/destination": "^4.3.0",
- "@turf/distance": "^4.3.0",
- "@turf/helpers": "^4.3.0"
+ "@turf/bearing": "^4.4.0",
+ "@turf/destination": "^4.4.0",
+ "@turf/distance": "^4.4.0",
+ "@turf/helpers": "^4.4.0"
}
}
diff --git a/packages/turf-area/package.json b/packages/turf-area/package.json
index 4c6ed5ea5d..3b41786fdc 100644
--- a/packages/turf-area/package.json
+++ b/packages/turf-area/package.json
@@ -1,6 +1,6 @@
{
"name": "@turf/area",
- "version": "4.3.0",
+ "version": "4.4.0",
"description": "turf area module",
"main": "index.js",
"types": "index.d.ts",
@@ -36,6 +36,6 @@
},
"dependencies": {
"@mapbox/geojson-area": "^0.2.2",
- "@turf/meta": "^4.3.0"
+ "@turf/meta": "^4.4.0"
}
}
diff --git a/packages/turf-bbox-clip/package.json b/packages/turf-bbox-clip/package.json
index 985d98145e..426cbf5d44 100644
--- a/packages/turf-bbox-clip/package.json
+++ b/packages/turf-bbox-clip/package.json
@@ -1,6 +1,6 @@
{
"name": "@turf/bbox-clip",
- "version": "4.3.0",
+ "version": "4.4.0",
"description": "turf bbox-clip module",
"main": "index.js",
"types": "index.d.ts",
@@ -35,15 +35,15 @@
},
"homepage": "/~https://github.com/Turfjs/turf",
"devDependencies": {
- "@turf/bbox": "^4.3.0",
+ "@turf/bbox": "^4.4.0",
"benchmark": "^2.1.4",
"load-json-file": "^2.0.0",
"tape": "^4.6.3",
"write-json-file": "^2.0.0"
},
"dependencies": {
- "@turf/helpers": "^4.3.0",
- "@turf/invariant": "^4.3.0",
+ "@turf/helpers": "^4.4.0",
+ "@turf/invariant": "^4.4.0",
"lineclip": "^1.1.5"
}
}
diff --git a/packages/turf-bbox-polygon/package.json b/packages/turf-bbox-polygon/package.json
index c7d18c52b7..45f7f70d15 100644
--- a/packages/turf-bbox-polygon/package.json
+++ b/packages/turf-bbox-polygon/package.json
@@ -1,6 +1,6 @@
{
"name": "@turf/bbox-polygon",
- "version": "4.3.0",
+ "version": "4.4.0",
"description": "turf bbox-polygon module",
"main": "index.js",
"types": "index.d.ts",
@@ -34,6 +34,6 @@
"tape": "^4.6.3"
},
"dependencies": {
- "@turf/helpers": "^4.3.0"
+ "@turf/helpers": "^4.4.0"
}
}
diff --git a/packages/turf-bbox/package.json b/packages/turf-bbox/package.json
index 4c211da831..2d652d9bcb 100644
--- a/packages/turf-bbox/package.json
+++ b/packages/turf-bbox/package.json
@@ -1,6 +1,6 @@
{
"name": "@turf/bbox",
- "version": "4.3.0",
+ "version": "4.4.0",
"description": "turf bbox module",
"main": "index.js",
"types": "index.d.ts",
@@ -35,6 +35,6 @@
"tape": "^4.6.3"
},
"dependencies": {
- "@turf/meta": "^4.3.0"
+ "@turf/meta": "^4.4.0"
}
}
diff --git a/packages/turf-bearing/package.json b/packages/turf-bearing/package.json
index 28369e1445..c2366e5bd5 100644
--- a/packages/turf-bearing/package.json
+++ b/packages/turf-bearing/package.json
@@ -1,6 +1,6 @@
{
"name": "@turf/bearing",
- "version": "4.3.0",
+ "version": "4.4.0",
"description": "turf bearing module",
"main": "index.js",
"types": "index.d.ts",
@@ -27,13 +27,13 @@
},
"homepage": "/~https://github.com/Turfjs/turf",
"devDependencies": {
- "@turf/destination": "^4.3.0",
- "@turf/helpers": "^4.3.0",
+ "@turf/destination": "^4.4.0",
+ "@turf/helpers": "^4.4.0",
"benchmark": "^2.1.4",
"tape": "^4.6.3",
"write-json-file": "^2.0.0"
},
"dependencies": {
- "@turf/invariant": "^4.3.0"
+ "@turf/invariant": "^4.4.0"
}
}
diff --git a/packages/turf-bezier/package.json b/packages/turf-bezier/package.json
index 765f323f0e..9dc9cc09f1 100644
--- a/packages/turf-bezier/package.json
+++ b/packages/turf-bezier/package.json
@@ -1,6 +1,6 @@
{
"name": "@turf/bezier",
- "version": "4.3.0",
+ "version": "4.4.0",
"description": "turf bezier module",
"main": "index.js",
"types": "index.d.ts",
@@ -37,6 +37,6 @@
"write-json-file": "^2.0.0"
},
"dependencies": {
- "@turf/helpers": "^4.3.0"
+ "@turf/helpers": "^4.4.0"
}
}
diff --git a/packages/turf-boolean-clockwise/LICENSE b/packages/turf-boolean-clockwise/LICENSE
new file mode 100644
index 0000000000..96ce51b76f
--- /dev/null
+++ b/packages/turf-boolean-clockwise/LICENSE
@@ -0,0 +1,20 @@
+The MIT License (MIT)
+
+Copyright (c) 2017 TurfJS
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of
+this software and associated documentation files (the "Software"), to deal in
+the Software without restriction, including without limitation the rights to
+use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
+the Software, and to permit persons to whom the Software is furnished to do so,
+subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
+FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
+COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
diff --git a/packages/turf-boolean-clockwise/README.md b/packages/turf-boolean-clockwise/README.md
new file mode 100755
index 0000000000..f53e2e4abf
--- /dev/null
+++ b/packages/turf-boolean-clockwise/README.md
@@ -0,0 +1,48 @@
+# @turf/boolean-clockwise
+
+# booleanClockwise
+
+Takes a ring and return true or false whether or not the ring is clockwise or counter-clockwise.
+
+**Parameters**
+
+- `line` **([Geometry](http://geojson.org/geojson-spec.html#geometry) \| [Feature](http://geojson.org/geojson-spec.html#feature-objects)<[LineString](http://geojson.org/geojson-spec.html#linestring)> | [Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)<[Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)<[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)>>)** to be evaluated
+
+**Examples**
+
+```javascript
+var clockwiseRing = [[0,0],[1,1],[1,0],[0,0]]
+var counterClockwiseRing = [[0,0],[1,0],[1,1],[0,0]]
+
+turf.booleanClockwise(clockwiseRing)
+//=true
+turf.booleanClockwise(counterClockwiseRing)
+//=false
+```
+
+Returns **[Boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** true/false
+
+
+
+---
+
+This module is part of the [Turfjs project](http://turfjs.org/), an open source
+module collection dedicated to geographic algorithms. It is maintained in the
+[Turfjs/turf](/~https://github.com/Turfjs/turf) repository, where you can create
+PRs and issues.
+
+### Installation
+
+Install this module individually:
+
+```sh
+$ npm install @turf/boolean-clockwise
+```
+
+Or install the Turf module that includes it as a function:
+
+```sh
+$ npm install @turf/turf
+```
diff --git a/packages/turf-boolean-clockwise/bench.js b/packages/turf-boolean-clockwise/bench.js
new file mode 100755
index 0000000000..e64e5f2655
--- /dev/null
+++ b/packages/turf-boolean-clockwise/bench.js
@@ -0,0 +1,24 @@
+const path = require('path');
+const glob = require('glob');
+const Benchmark = require('benchmark');
+const load = require('load-json-file');
+const isClockwise = require('./');
+
+/**
+ * Benchmark Results
+ *
+ * counter-clockwise-line x 7,272,353 ops/sec ±11.64% (58 runs sampled)
+ * clockwise-line x 10,724,102 ops/sec ±2.19% (76 runs sampled)
+ */
+const suite = new Benchmark.Suite('turf-boolean-clockwise');
+glob.sync(path.join(__dirname, 'test', '**', '*.geojson')).forEach(filepath => {
+ const {name} = path.parse(filepath);
+ const geojson = load.sync(filepath);
+ const [feature] = geojson.features;
+ suite.add(name, () => isClockwise(feature));
+});
+
+suite
+ .on('cycle', e => console.log(String(e.target)))
+ .on('complete', () => {})
+ .run();
\ No newline at end of file
diff --git a/packages/turf-boolean-clockwise/index.d.ts b/packages/turf-boolean-clockwise/index.d.ts
new file mode 100644
index 0000000000..c39380a2ad
--- /dev/null
+++ b/packages/turf-boolean-clockwise/index.d.ts
@@ -0,0 +1,10 @@
+///
+
+type Line = GeoJSON.Feature | GeoJSON.LineString | Array>;
+
+/**
+ * http://turfjs.org/docs/#boolean-clockwise
+ */
+declare function clockwise(line: Line): boolean;
+declare namespace clockwise { }
+export = clockwise;
diff --git a/packages/turf-boolean-clockwise/index.js b/packages/turf-boolean-clockwise/index.js
new file mode 100755
index 0000000000..089d10757c
--- /dev/null
+++ b/packages/turf-boolean-clockwise/index.js
@@ -0,0 +1,36 @@
+var invariant = require('@turf/invariant');
+var getCoords = invariant.getCoords;
+
+/**
+ * Takes a ring and return true or false whether or not the ring is clockwise or counter-clockwise.
+ *
+ * @name booleanClockwise
+ * @param {Geometry|Feature|Array>} line to be evaluated
+ * @returns {Boolean} true/false
+ * @example
+ * var clockwiseRing = [[0,0],[1,1],[1,0],[0,0]]
+ * var counterClockwiseRing = [[0,0],[1,0],[1,1],[0,0]]
+ *
+ * turf.booleanClockwise(clockwiseRing)
+ * //=true
+ * turf.booleanClockwise(counterClockwiseRing)
+ * //=false
+ */
+module.exports = function (line) {
+ // validation
+ if (!line) throw new Error('line is required');
+ var type = (line.geometry) ? line.geometry.type : line.type;
+ if (!Array.isArray(line) && type !== 'LineString') throw new Error('geometry must be a LineString');
+
+ var ring = getCoords(line);
+ var sum = 0;
+ var i = 1;
+ var prev, cur;
+ while (i < ring.length) {
+ prev = cur || ring[0];
+ cur = ring[i];
+ sum += ((cur[0] - prev[0]) * (cur[1] + prev[1]));
+ i++;
+ }
+ return sum > 0;
+};
diff --git a/packages/turf-boolean-clockwise/package.json b/packages/turf-boolean-clockwise/package.json
new file mode 100755
index 0000000000..505f0ca6cd
--- /dev/null
+++ b/packages/turf-boolean-clockwise/package.json
@@ -0,0 +1,46 @@
+{
+ "name": "@turf/boolean-clockwise",
+ "version": "4.0.0",
+ "description": "turf boolean-clockwise module",
+ "main": "index.js",
+ "types": "index.d.ts",
+ "files": [
+ "index.js",
+ "index.d.ts"
+ ],
+ "scripts": {
+ "test": "node test.js",
+ "bench": "node bench.js"
+ },
+ "repository": {
+ "type": "git",
+ "url": "git://github.com/Turfjs/turf.git"
+ },
+ "keywords": [
+ "turf",
+ "clockwise",
+ "boolean"
+ ],
+ "author": "Turf Authors",
+ "contributors": [
+ "Morgan Herlocker <@morganherlocker>",
+ "Rowan Winsemius <@rowanwins>",
+ "Denis Carriere <@DenisCarriere>",
+ "Stefano Borghi <@stebogit>"
+ ],
+ "license": "MIT",
+ "bugs": {
+ "url": "/~https://github.com/Turfjs/turf/issues"
+ },
+ "homepage": "/~https://github.com/Turfjs/turf",
+ "devDependencies": {
+ "@turf/helpers": "^4.2.0",
+ "benchmark": "^2.1.4",
+ "glob": "^7.1.1",
+ "load-json-file": "^2.0.0",
+ "tape": "^4.6.3"
+ },
+ "dependencies": {
+ "@turf/invariant": "^4.2.0"
+ }
+}
diff --git a/packages/turf-boolean-clockwise/test.js b/packages/turf-boolean-clockwise/test.js
new file mode 100755
index 0000000000..ed29aa1097
--- /dev/null
+++ b/packages/turf-boolean-clockwise/test.js
@@ -0,0 +1,50 @@
+const glob = require('glob');
+const path = require('path');
+const test = require('tape');
+const load = require('load-json-file');
+const {point, lineString} = require('@turf/helpers');
+const isClockwise = require('./');
+
+test('isClockwise#fixtures', t => {
+ // True Fixtures
+ glob.sync(path.join(__dirname, 'test', 'true', '*.geojson')).forEach(filepath => {
+ const {name} = path.parse(filepath);
+ const geojson = load.sync(filepath);
+ const [feature] = geojson.features;
+ t.true(isClockwise(feature), '[true] ' + name);
+ });
+ // False Fixtures
+ glob.sync(path.join(__dirname, 'test', 'false', '*.geojson')).forEach(filepath => {
+ const {name} = path.parse(filepath);
+ const geojson = load.sync(filepath);
+ const [feature] = geojson.features;
+ t.false(isClockwise(feature), '[false] ' + name);
+ });
+ t.end();
+});
+
+test('isClockwise', t => {
+ const cwArray = [[0, 0], [1, 1], [1, 0], [0, 0]];
+ const ccwArray = [[0, 0], [1, 0], [1, 1], [0, 0]];
+
+ t.equal(isClockwise(cwArray), true, '[true] clockwise array input');
+ t.equal(isClockwise(ccwArray), false, '[false] counter-clockwise array input');
+
+ t.end();
+});
+
+test('isClockwise -- Geometry types', t => {
+ const line = lineString([[0, 0], [1, 1], [1, 0], [0, 0]]);
+
+ t.equal(isClockwise(line), true, 'Feature');
+ t.equal(isClockwise(line.geometry), true, 'Geometry Object');
+
+ t.end();
+});
+
+test('isClockwise -- throws', t => {
+ const pt = point([-10, -33]);
+ t.throws(() => isClockwise(pt), 'feature geometry not supported');
+
+ t.end();
+});
diff --git a/packages/turf-boolean-clockwise/test/false/counter-clockwise-line.geojson b/packages/turf-boolean-clockwise/test/false/counter-clockwise-line.geojson
new file mode 100644
index 0000000000..ddf62c07f3
--- /dev/null
+++ b/packages/turf-boolean-clockwise/test/false/counter-clockwise-line.geojson
@@ -0,0 +1,30 @@
+{
+ "type": "FeatureCollection",
+ "features": [
+ {
+ "type": "Feature",
+ "properties": {},
+ "geometry": {
+ "type": "LineString",
+ "coordinates": [
+ [
+ 0,
+ 0
+ ],
+ [
+ 1,
+ 0
+ ],
+ [
+ 1,
+ 1
+ ],
+ [
+ 0,
+ 0
+ ]
+ ]
+ }
+ }
+ ]
+}
\ No newline at end of file
diff --git a/packages/turf-boolean-clockwise/test/true/clockwise-line.geojson b/packages/turf-boolean-clockwise/test/true/clockwise-line.geojson
new file mode 100644
index 0000000000..cf650762f0
--- /dev/null
+++ b/packages/turf-boolean-clockwise/test/true/clockwise-line.geojson
@@ -0,0 +1,30 @@
+{
+ "type": "FeatureCollection",
+ "features": [
+ {
+ "type": "Feature",
+ "properties": {},
+ "geometry": {
+ "type": "LineString",
+ "coordinates": [
+ [
+ 0,
+ 0
+ ],
+ [
+ 1,
+ 1
+ ],
+ [
+ 1,
+ 0
+ ],
+ [
+ 0,
+ 0
+ ]
+ ]
+ }
+ }
+ ]
+}
\ No newline at end of file
diff --git a/packages/turf-boolean-clockwise/yarn.lock b/packages/turf-boolean-clockwise/yarn.lock
new file mode 100644
index 0000000000..0bcdab2429
--- /dev/null
+++ b/packages/turf-boolean-clockwise/yarn.lock
@@ -0,0 +1,250 @@
+# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
+# yarn lockfile v1
+
+
+"@turf/helpers@^4.2.0":
+ version "4.4.0"
+ resolved "https://registry.yarnpkg.com/@turf/helpers/-/helpers-4.4.0.tgz#c83112f7fbe6ed183c7c0c2f776481b94d1cbd01"
+
+"@turf/invariant@^4.2.0":
+ version "4.4.0"
+ resolved "https://registry.yarnpkg.com/@turf/invariant/-/invariant-4.4.0.tgz#aac0afb840ae40908f9c80393f416222dcf79c32"
+
+balanced-match@^1.0.0:
+ version "1.0.0"
+ resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-1.0.0.tgz#89b4d199ab2bee49de164ea02b89ce462d71b767"
+
+benchmark@^2.1.4:
+ version "2.1.4"
+ resolved "https://registry.yarnpkg.com/benchmark/-/benchmark-2.1.4.tgz#09f3de31c916425d498cc2ee565a0ebf3c2a5629"
+ dependencies:
+ lodash "^4.17.4"
+ platform "^1.3.3"
+
+brace-expansion@^1.1.7:
+ version "1.1.8"
+ resolved "https://registry.yarnpkg.com/brace-expansion/-/brace-expansion-1.1.8.tgz#c07b211c7c952ec1f8efd51a77ef0d1d3990a292"
+ dependencies:
+ balanced-match "^1.0.0"
+ concat-map "0.0.1"
+
+concat-map@0.0.1:
+ version "0.0.1"
+ resolved "https://registry.yarnpkg.com/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b"
+
+deep-equal@~1.0.1:
+ version "1.0.1"
+ resolved "https://registry.yarnpkg.com/deep-equal/-/deep-equal-1.0.1.tgz#f5d260292b660e084eff4cdbc9f08ad3247448b5"
+
+define-properties@^1.1.2:
+ version "1.1.2"
+ resolved "https://registry.yarnpkg.com/define-properties/-/define-properties-1.1.2.tgz#83a73f2fea569898fb737193c8f873caf6d45c94"
+ dependencies:
+ foreach "^2.0.5"
+ object-keys "^1.0.8"
+
+defined@~1.0.0:
+ version "1.0.0"
+ resolved "https://registry.yarnpkg.com/defined/-/defined-1.0.0.tgz#c98d9bcef75674188e110969151199e39b1fa693"
+
+error-ex@^1.2.0:
+ version "1.3.1"
+ resolved "https://registry.yarnpkg.com/error-ex/-/error-ex-1.3.1.tgz#f855a86ce61adc4e8621c3cda21e7a7612c3a8dc"
+ dependencies:
+ is-arrayish "^0.2.1"
+
+es-abstract@^1.5.0:
+ version "1.7.0"
+ resolved "https://registry.yarnpkg.com/es-abstract/-/es-abstract-1.7.0.tgz#dfade774e01bfcd97f96180298c449c8623fb94c"
+ dependencies:
+ es-to-primitive "^1.1.1"
+ function-bind "^1.1.0"
+ is-callable "^1.1.3"
+ is-regex "^1.0.3"
+
+es-to-primitive@^1.1.1:
+ version "1.1.1"
+ resolved "https://registry.yarnpkg.com/es-to-primitive/-/es-to-primitive-1.1.1.tgz#45355248a88979034b6792e19bb81f2b7975dd0d"
+ dependencies:
+ is-callable "^1.1.1"
+ is-date-object "^1.0.1"
+ is-symbol "^1.0.1"
+
+for-each@~0.3.2:
+ version "0.3.2"
+ resolved "https://registry.yarnpkg.com/for-each/-/for-each-0.3.2.tgz#2c40450b9348e97f281322593ba96704b9abd4d4"
+ dependencies:
+ is-function "~1.0.0"
+
+foreach@^2.0.5:
+ version "2.0.5"
+ resolved "https://registry.yarnpkg.com/foreach/-/foreach-2.0.5.tgz#0bee005018aeb260d0a3af3ae658dd0136ec1b99"
+
+fs.realpath@^1.0.0:
+ version "1.0.0"
+ resolved "https://registry.yarnpkg.com/fs.realpath/-/fs.realpath-1.0.0.tgz#1504ad2523158caa40db4a2787cb01411994ea4f"
+
+function-bind@^1.0.2, function-bind@^1.1.0, function-bind@~1.1.0:
+ version "1.1.0"
+ resolved "https://registry.yarnpkg.com/function-bind/-/function-bind-1.1.0.tgz#16176714c801798e4e8f2cf7f7529467bb4a5771"
+
+glob@^7.1.1, glob@~7.1.1:
+ version "7.1.2"
+ resolved "https://registry.yarnpkg.com/glob/-/glob-7.1.2.tgz#c19c9df9a028702d678612384a6552404c636d15"
+ dependencies:
+ fs.realpath "^1.0.0"
+ inflight "^1.0.4"
+ inherits "2"
+ minimatch "^3.0.4"
+ once "^1.3.0"
+ path-is-absolute "^1.0.0"
+
+graceful-fs@^4.1.2:
+ version "4.1.11"
+ resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.1.11.tgz#0e8bdfe4d1ddb8854d64e04ea7c00e2a026e5658"
+
+has@^1.0.1, has@~1.0.1:
+ version "1.0.1"
+ resolved "https://registry.yarnpkg.com/has/-/has-1.0.1.tgz#8461733f538b0837c9361e39a9ab9e9704dc2f28"
+ dependencies:
+ function-bind "^1.0.2"
+
+inflight@^1.0.4:
+ version "1.0.6"
+ resolved "https://registry.yarnpkg.com/inflight/-/inflight-1.0.6.tgz#49bd6331d7d02d0c09bc910a1075ba8165b56df9"
+ dependencies:
+ once "^1.3.0"
+ wrappy "1"
+
+inherits@2, inherits@~2.0.3:
+ version "2.0.3"
+ resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.3.tgz#633c2c83e3da42a502f52466022480f4208261de"
+
+is-arrayish@^0.2.1:
+ version "0.2.1"
+ resolved "https://registry.yarnpkg.com/is-arrayish/-/is-arrayish-0.2.1.tgz#77c99840527aa8ecb1a8ba697b80645a7a926a9d"
+
+is-callable@^1.1.1, is-callable@^1.1.3:
+ version "1.1.3"
+ resolved "https://registry.yarnpkg.com/is-callable/-/is-callable-1.1.3.tgz#86eb75392805ddc33af71c92a0eedf74ee7604b2"
+
+is-date-object@^1.0.1:
+ version "1.0.1"
+ resolved "https://registry.yarnpkg.com/is-date-object/-/is-date-object-1.0.1.tgz#9aa20eb6aeebbff77fbd33e74ca01b33581d3a16"
+
+is-function@~1.0.0:
+ version "1.0.1"
+ resolved "https://registry.yarnpkg.com/is-function/-/is-function-1.0.1.tgz#12cfb98b65b57dd3d193a3121f5f6e2f437602b5"
+
+is-regex@^1.0.3:
+ version "1.0.4"
+ resolved "https://registry.yarnpkg.com/is-regex/-/is-regex-1.0.4.tgz#5517489b547091b0930e095654ced25ee97e9491"
+ dependencies:
+ has "^1.0.1"
+
+is-symbol@^1.0.1:
+ version "1.0.1"
+ resolved "https://registry.yarnpkg.com/is-symbol/-/is-symbol-1.0.1.tgz#3cc59f00025194b6ab2e38dbae6689256b660572"
+
+load-json-file@^2.0.0:
+ version "2.0.0"
+ resolved "https://registry.yarnpkg.com/load-json-file/-/load-json-file-2.0.0.tgz#7947e42149af80d696cbf797bcaabcfe1fe29ca8"
+ dependencies:
+ graceful-fs "^4.1.2"
+ parse-json "^2.2.0"
+ pify "^2.0.0"
+ strip-bom "^3.0.0"
+
+lodash@^4.17.4:
+ version "4.17.4"
+ resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.4.tgz#78203a4d1c328ae1d86dca6460e369b57f4055ae"
+
+minimatch@^3.0.4:
+ version "3.0.4"
+ resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.0.4.tgz#5166e286457f03306064be5497e8dbb0c3d32083"
+ dependencies:
+ brace-expansion "^1.1.7"
+
+minimist@~1.2.0:
+ version "1.2.0"
+ resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.0.tgz#a35008b20f41383eec1fb914f4cd5df79a264284"
+
+object-inspect@~1.2.1:
+ version "1.2.2"
+ resolved "https://registry.yarnpkg.com/object-inspect/-/object-inspect-1.2.2.tgz#c82115e4fcc888aea14d64c22e4f17f6a70d5e5a"
+
+object-keys@^1.0.8:
+ version "1.0.11"
+ resolved "https://registry.yarnpkg.com/object-keys/-/object-keys-1.0.11.tgz#c54601778ad560f1142ce0e01bcca8b56d13426d"
+
+once@^1.3.0:
+ version "1.4.0"
+ resolved "https://registry.yarnpkg.com/once/-/once-1.4.0.tgz#583b1aa775961d4b113ac17d9c50baef9dd76bd1"
+ dependencies:
+ wrappy "1"
+
+parse-json@^2.2.0:
+ version "2.2.0"
+ resolved "https://registry.yarnpkg.com/parse-json/-/parse-json-2.2.0.tgz#f480f40434ef80741f8469099f8dea18f55a4dc9"
+ dependencies:
+ error-ex "^1.2.0"
+
+path-is-absolute@^1.0.0:
+ version "1.0.1"
+ resolved "https://registry.yarnpkg.com/path-is-absolute/-/path-is-absolute-1.0.1.tgz#174b9268735534ffbc7ace6bf53a5a9e1b5c5f5f"
+
+pify@^2.0.0:
+ version "2.3.0"
+ resolved "https://registry.yarnpkg.com/pify/-/pify-2.3.0.tgz#ed141a6ac043a849ea588498e7dca8b15330e90c"
+
+platform@^1.3.3:
+ version "1.3.4"
+ resolved "https://registry.yarnpkg.com/platform/-/platform-1.3.4.tgz#6f0fb17edaaa48f21442b3a975c063130f1c3ebd"
+
+resolve@~1.1.7:
+ version "1.1.7"
+ resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.1.7.tgz#203114d82ad2c5ed9e8e0411b3932875e889e97b"
+
+resumer@~0.0.0:
+ version "0.0.0"
+ resolved "https://registry.yarnpkg.com/resumer/-/resumer-0.0.0.tgz#f1e8f461e4064ba39e82af3cdc2a8c893d076759"
+ dependencies:
+ through "~2.3.4"
+
+string.prototype.trim@~1.1.2:
+ version "1.1.2"
+ resolved "https://registry.yarnpkg.com/string.prototype.trim/-/string.prototype.trim-1.1.2.tgz#d04de2c89e137f4d7d206f086b5ed2fae6be8cea"
+ dependencies:
+ define-properties "^1.1.2"
+ es-abstract "^1.5.0"
+ function-bind "^1.0.2"
+
+strip-bom@^3.0.0:
+ version "3.0.0"
+ resolved "https://registry.yarnpkg.com/strip-bom/-/strip-bom-3.0.0.tgz#2334c18e9c759f7bdd56fdef7e9ae3d588e68ed3"
+
+tape@^4.6.3:
+ version "4.6.3"
+ resolved "https://registry.yarnpkg.com/tape/-/tape-4.6.3.tgz#637e77581e9ab2ce17577e9bd4ce4f575806d8b6"
+ dependencies:
+ deep-equal "~1.0.1"
+ defined "~1.0.0"
+ for-each "~0.3.2"
+ function-bind "~1.1.0"
+ glob "~7.1.1"
+ has "~1.0.1"
+ inherits "~2.0.3"
+ minimist "~1.2.0"
+ object-inspect "~1.2.1"
+ resolve "~1.1.7"
+ resumer "~0.0.0"
+ string.prototype.trim "~1.1.2"
+ through "~2.3.8"
+
+through@~2.3.4, through@~2.3.8:
+ version "2.3.8"
+ resolved "https://registry.yarnpkg.com/through/-/through-2.3.8.tgz#0dd4c9ffaabc357960b1b724115d7e0e86a2e1f5"
+
+wrappy@1:
+ version "1.0.2"
+ resolved "https://registry.yarnpkg.com/wrappy/-/wrappy-1.0.2.tgz#b5243d8f3ec1aa35f1364605bc0d1036e30ab69f"
diff --git a/packages/turf-boolean-contains/LICENSE b/packages/turf-boolean-contains/LICENSE
new file mode 100644
index 0000000000..96ce51b76f
--- /dev/null
+++ b/packages/turf-boolean-contains/LICENSE
@@ -0,0 +1,20 @@
+The MIT License (MIT)
+
+Copyright (c) 2017 TurfJS
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of
+this software and associated documentation files (the "Software"), to deal in
+the Software without restriction, including without limitation the rights to
+use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
+the Software, and to permit persons to whom the Software is furnished to do so,
+subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
+FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
+COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
diff --git a/packages/turf-boolean-contains/README.md b/packages/turf-boolean-contains/README.md
new file mode 100644
index 0000000000..9386189adf
--- /dev/null
+++ b/packages/turf-boolean-contains/README.md
@@ -0,0 +1,60 @@
+# @turf/boolean-contains
+
+# contains
+
+Contains returns True if the second geometry is completely contained by the first geometry.
+
+**Parameters**
+
+- `feature1` **([Geometry](http://geojson.org/geojson-spec.html#geometry) \| [Feature](http://geojson.org/geojson-spec.html#feature-objects)<any>)** GeoJSON Feature or Geometry
+- `feature2` **([Geometry](http://geojson.org/geojson-spec.html#geometry) \| [Feature](http://geojson.org/geojson-spec.html#feature-objects)<any>)** GeoJSON Feature or Geometry
+
+**Examples**
+
+```javascript
+const point = {
+ "type": "Feature",
+ "properties": {},
+ "geometry": {
+ "type": "Point",
+ "coordinates": [1, 1]
+ }
+}
+const line = {
+ "type": "Feature",
+ "properties": {},
+ "geometry": {
+ "type": "LineString",
+ "coordinates": [[1, 1], [1, 2], [1, 3], [1, 4]]
+ }
+}
+turf.contains(line, point);
+//=true
+```
+
+Returns **[Boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** true/false
+
+
+
+---
+
+This module is part of the [Turfjs project](http://turfjs.org/), an open source
+module collection dedicated to geographic algorithms. It is maintained in the
+[Turfjs/turf](/~https://github.com/Turfjs/turf) repository, where you can create
+PRs and issues.
+
+### Installation
+
+Install this module individually:
+
+```sh
+$ npm install @turf/boolean-contains
+```
+
+Or install the Turf module that includes it as a function:
+
+```sh
+$ npm install @turf/turf
+```
diff --git a/packages/turf-boolean-contains/bench.js b/packages/turf-boolean-contains/bench.js
new file mode 100644
index 0000000000..eaedea0250
--- /dev/null
+++ b/packages/turf-boolean-contains/bench.js
@@ -0,0 +1,30 @@
+const path = require('path');
+const glob = require('glob');
+const Benchmark = require('benchmark');
+const load = require('load-json-file');
+const bbox = require('@turf/bbox');
+const contains = require('./');
+
+/**
+ * Benchmark Results
+ *
+ * false-polygon-overlap x 110,681 ops/sec ±1.35% (89 runs sampled)
+ * false-polygons1 x 5,008,431 ops/sec ±5.25% (83 runs sampled)
+ * false-polygons2 x 4,958,640 ops/sec ±5.64% (82 runs sampled)
+ * true-polygons1 x 235,353 ops/sec ±1.27% (90 runs sampled)
+ * true-polygons2 x 170,512 ops/sec ±1.24% (91 runs sampled)
+ */
+const suite = new Benchmark.Suite('turf-boolean-contains');
+glob.sync(path.join(__dirname, 'test', '**', '*.geojson')).forEach(filepath => {
+ const {name} = path.parse(filepath);
+ const geojson = load.sync(filepath);
+ const [feature1, feature2] = geojson.features;
+ feature1.bbox = bbox(feature1);
+ feature2.bbox = bbox(feature2);
+ suite.add(name, () => contains(feature1, feature2));
+});
+
+suite
+ .on('cycle', e => console.log(String(e.target)))
+ .on('complete', () => {})
+ .run();
diff --git a/packages/turf-boolean-contains/index.d.ts b/packages/turf-boolean-contains/index.d.ts
new file mode 100644
index 0000000000..17629c4481
--- /dev/null
+++ b/packages/turf-boolean-contains/index.d.ts
@@ -0,0 +1,10 @@
+///
+
+type Feature = GeoJSON.Feature | GeoJSON.GeometryObject;
+
+/**
+ * http://turfjs.org/docs/#boolean-contains
+ */
+declare function contains(feature1: Feature, feature2: Feature): boolean;
+declare namespace contains { }
+export = contains;
diff --git a/packages/turf-boolean-contains/index.js b/packages/turf-boolean-contains/index.js
new file mode 100644
index 0000000000..2fb5b10d17
--- /dev/null
+++ b/packages/turf-boolean-contains/index.js
@@ -0,0 +1,286 @@
+var inside = require('@turf/inside');
+var helpers = require('@turf/helpers'); //= Remove @turf/helpers at Turf v4.3
+var getCoords = require('@turf/invariant').getCoords;
+var deepEqual = require('deep-equal');
+var lineOverlap = require('@turf/line-overlap');
+
+/**
+ * Contains returns True if the second geometry is completely contained by the first geometry.
+ *
+ * @name contains
+ * @param {Geometry|Feature} feature1 GeoJSON Feature or Geometry
+ * @param {Geometry|Feature} feature2 GeoJSON Feature or Geometry
+ * @returns {Boolean} true/false
+ * @example
+ * const point = {
+ * "type": "Feature",
+ * "properties": {},
+ * "geometry": {
+ * "type": "Point",
+ * "coordinates": [1, 1]
+ * }
+ * }
+ * const line = {
+ * "type": "Feature",
+ * "properties": {},
+ * "geometry": {
+ * "type": "LineString",
+ * "coordinates": [[1, 1], [1, 2], [1, 3], [1, 4]]
+ * }
+ * }
+ * turf.contains(line, point);
+ * //=true
+ */
+module.exports = function (feature1, feature2) {
+ var type1 = getGeomType(feature1);
+ var type2 = getGeomType(feature2);
+ var geom1 = getGeom(feature1);
+ var geom2 = getGeom(feature2);
+ var coords1 = getCoords(feature1);
+ var coords2 = getCoords(feature2);
+
+ switch (type1) {
+ case 'Point':
+ switch (type2) {
+ case 'Point':
+ return deepEqual(coords1, coords2);
+ }
+ throw new Error('feature2 ' + type2 + ' geometry not supported');
+ case 'MultiPoint':
+ switch (type2) {
+ case 'Point':
+ return isPointInMultiPoint(geom1, geom2);
+ case 'MultiPoint':
+ return isMultiPointInMultiPoint(geom1, geom2);
+ }
+ throw new Error('feature2 ' + type2 + ' geometry not supported');
+ case 'LineString':
+ switch (type2) {
+ case 'Point':
+ return isPointOnLine(geom1, geom2);
+ case 'LineString':
+ return isLineOnLine(geom1, geom2);
+ case 'MultiPoint':
+ return isMultiPointOnLine(geom1, geom2);
+ }
+ throw new Error('feature2 ' + type2 + ' geometry not supported');
+ case 'Polygon':
+ switch (type2) {
+ case 'Point':
+ return inside(geom2, geom1);
+ case 'LineString':
+ return isLineInPoly(geom1, geom2);
+ case 'Polygon':
+ return isPolyInPoly(feature2, feature1);
+ case 'MultiPoint':
+ return isMultiPointInPoly(geom1, geom2);
+ }
+ throw new Error('feature2 ' + type2 + ' geometry not supported');
+ default:
+ throw new Error('feature1 ' + type1 + ' geometry not supported');
+ }
+};
+
+function isPointInMultiPoint(MultiPoint, Point) {
+ var i;
+ var output = false;
+ for (i = 0; i < MultiPoint.coordinates.length; i++) {
+ if (deepEqual(MultiPoint.coordinates[i], Point.coordinates)) {
+ output = true;
+ break;
+ }
+ }
+ return output;
+}
+
+function isMultiPointInMultiPoint(MultiPoint1, MultiPoint2) {
+ var foundAMatch = 0;
+ for (var i = 0; i < MultiPoint2.coordinates.length; i++) {
+ var anyMatch = false;
+ for (var i2 = 0; i2 < MultiPoint1.coordinates.length; i2++) {
+ if (deepEqual(MultiPoint2.coordinates[i], MultiPoint1.coordinates[i2])) {
+ foundAMatch++;
+ anyMatch = true;
+ break;
+ }
+ }
+ if (!anyMatch) {
+ return false;
+ }
+ }
+ return foundAMatch > 0;
+}
+
+// http://stackoverflow.com/a/11908158/1979085
+function isPointOnLine(LineString, Point) {
+ var output = false;
+ for (var i = 0; i < LineString.coordinates.length - 1; i++) {
+ if (isPointOnLineSegment(LineString.coordinates[i], LineString.coordinates[i + 1], Point.coordinates)) {
+ output = true;
+ break;
+ }
+ }
+ return output;
+}
+
+function isMultiPointOnLine(LineString, MultiPoint) {
+ var output = true;
+ for (var i = 0; i < MultiPoint.coordinates.length; i++) {
+ var pointIsOnLine = false;
+ for (var i2 = 0; i2 < LineString.coordinates.length - 1; i2++) {
+ if (isPointOnLineSegment(LineString.coordinates[i2], LineString.coordinates[i2 + 1], MultiPoint.coordinates[i])) {
+ pointIsOnLine = true;
+ break;
+ }
+ }
+ if (!pointIsOnLine) {
+ output = false;
+ break;
+ }
+ }
+ return output;
+}
+
+function isMultiPointInPoly(Polygon, MultiPoint) {
+ var output = true;
+ for (var i = 0; i < MultiPoint.coordinates.length; i++) {
+ var isInside = inside(MultiPoint.coordinates[1], Polygon);
+ if (!isInside) {
+ output = false;
+ break;
+ }
+ }
+ return output;
+}
+
+// TO DO - Work out how to check if line is in line (can potentially use line overlap module)
+// Also need to make sure lines are exactly the same, eg the second must be smaller than the first
+function isLineOnLine(LineString1, LineString2) {
+ var output = true;
+ //== CHANGE Turf v4.3 - LineOverlap supports Geometry Objects ==//
+ var overlappingLine = lineOverlap(helpers.feature(LineString1), helpers.feature(LineString2)).features[0];
+ if (!overlappingLine) return false;
+ overlappingLine = getGeom(overlappingLine);
+ if (overlappingLine.coordinates[0] === LineString1.coordinates[0] &&
+ overlappingLine.coordinates[overlappingLine.coordinates.length - 1] === LineString1.coordinates[LineString1.coordinates.length - 1]) {
+ output = false;
+ }
+ return output;
+}
+
+function isLineInPoly(Polygon, Linestring) {
+ var output = true;
+ for (var i = 0; i < Linestring.coordinates.length; i++) {
+ var isInside = inside(Linestring.coordinates[i], Polygon);
+ if (!isInside) {
+ output = false;
+ break;
+ }
+ }
+ return output;
+}
+
+/**
+ * Is Polygon (geom1) in Polygon (geom2)
+ * Only takes into account outer rings
+ * See http://stackoverflow.com/a/4833823/1979085
+ *
+ * @private
+ * @param {Geometry|Feature} feature1 Polygon1
+ * @param {Geometry|Feature} feature2 Polygon2
+ * @returns {Boolean} true/false
+ */
+function isPolyInPoly(feature1, feature2) {
+ var coords = getCoords(feature1)[0];
+ var ring = getCoords(feature2)[0];
+ var bbox = feature2.bbox;
+
+ // check if outer coordinates is inside outer ring
+ for (var i = 0; i < coords.length; i++) {
+ // 3x performance increase if BBox is present
+ if (bbox && !inBBox(coords[i], bbox)) return false;
+ if (!inRing(coords[i], ring)) return false;
+ }
+ // Outer geometries cannot be the same
+ if (deepEqual(coords, ring)) return false;
+ return true;
+}
+
+function isPointOnLineSegment(LineSegmentStart, LineSegmentEnd, Point) {
+ var dxc = Point[0] - LineSegmentStart[0];
+ var dyc = Point[1] - LineSegmentStart[1];
+ var dxl = LineSegmentEnd[0] - LineSegmentStart[0];
+ var dyl = LineSegmentEnd[1] - LineSegmentStart[1];
+ var cross = dxc * dyl - dyc * dxl;
+ if (cross !== 0) {
+ return false;
+ }
+ if (Math.abs(dxl) >= Math.abs(dyl)) {
+ return dxl > 0 ? LineSegmentStart[0] <= Point[0] && Point[0] <= LineSegmentEnd[0] : LineSegmentEnd[0] <= Point[0] && Point[0] <= LineSegmentStart[0];
+ } else {
+ return dyl > 0 ? LineSegmentStart[1] <= Point[1] && Point[1] <= LineSegmentEnd[1] : LineSegmentEnd[1] <= Point[1] && Point[1] <= LineSegmentStart[1];
+ }
+}
+
+/**
+ * Get Geometry from Feature or Geometry Object
+ * //!! Remove this method when implemented to @turf/invariant
+ *
+ * @private
+ * @param {Feature|Geometry} geojson GeoJSON Feature or Geometry Object
+ * @returns {Geometry} GeoJSON Geometry Object
+ * @throws {Error} if geojson is not a Feature or Geometry Object
+ */
+function getGeom(geojson) {
+ if (geojson.geometry) return geojson.geometry;
+ if (geojson.coordinates) return geojson;
+ throw new Error('geojson must be a feature or geometry object');
+}
+
+// Remove this method when implemented to @turf/invariant
+function getGeomType(geojson) {
+ if (geojson.geometry) return geojson.geometry.type;
+ if (geojson.coordinates) return geojson.type;
+ throw new Error('geojson must be a feature or geometry object');
+}
+
+/**
+ * inRing - @turf/inside
+ *
+ * @private
+ * @param {[number, number]} pt [x,y]
+ * @param {Array<[number, number]>} ring [[x,y], [x,y],..]
+ * @param {boolean} ignoreBoundary ignoreBoundary
+ * @returns {boolean} inRing
+ */
+function inRing(pt, ring, ignoreBoundary) {
+ var isInside = false;
+ if (ring[0][0] === ring[ring.length - 1][0] && ring[0][1] === ring[ring.length - 1][1]) ring = ring.slice(0, ring.length - 1);
+
+ for (var i = 0, j = ring.length - 1; i < ring.length; j = i++) {
+ var xi = ring[i][0], yi = ring[i][1];
+ var xj = ring[j][0], yj = ring[j][1];
+ var onBoundary = (pt[1] * (xi - xj) + yi * (xj - pt[0]) + yj * (pt[0] - xi) === 0) &&
+ ((xi - pt[0]) * (xj - pt[0]) <= 0) && ((yi - pt[1]) * (yj - pt[1]) <= 0);
+ if (onBoundary) return !ignoreBoundary;
+ var intersect = ((yi > pt[1]) !== (yj > pt[1])) &&
+ (pt[0] < (xj - xi) * (pt[1] - yi) / (yj - yi) + xi);
+ if (intersect) isInside = !isInside;
+ }
+ return isInside;
+}
+
+/**
+ * inBBox - @turf/inside
+ *
+ * @private
+ * @param {[number, number]} pt point [x,y]
+ * @param {[number, number, number, number]} bbox BBox [west, south, east, north]
+ * @returns {boolean} true/false if point is inside BBox
+ */
+function inBBox(pt, bbox) {
+ return bbox[0] <= pt[0] &&
+ bbox[1] <= pt[1] &&
+ bbox[2] >= pt[0] &&
+ bbox[3] >= pt[1];
+}
diff --git a/packages/turf-boolean-contains/package.json b/packages/turf-boolean-contains/package.json
new file mode 100644
index 0000000000..8cbd647bab
--- /dev/null
+++ b/packages/turf-boolean-contains/package.json
@@ -0,0 +1,49 @@
+{
+ "name": "@turf/boolean-contains",
+ "version": "4.0.0",
+ "description": "turf boolean-contains module",
+ "main": "index.js",
+ "types": "index.d.ts",
+ "files": [
+ "index.js",
+ "index.d.ts"
+ ],
+ "scripts": {
+ "test": "node test.js",
+ "bench": "node bench.js"
+ },
+ "repository": {
+ "type": "git",
+ "url": "git://github.com/Turfjs/turf.git"
+ },
+ "keywords": [
+ "turf",
+ "contains",
+ "boolean",
+ "de-9im"
+ ],
+ "author": "Turf Authors",
+ "contributors": [
+ "Rowan Winsemius <@rowanwins>",
+ "Denis Carriere <@DenisCarriere>"
+ ],
+ "license": "MIT",
+ "bugs": {
+ "url": "/~https://github.com/Turfjs/turf/issues"
+ },
+ "homepage": "/~https://github.com/Turfjs/turf",
+ "devDependencies": {
+ "@turf/bbox": "^4.2.0",
+ "benchmark": "^2.1.4",
+ "glob": "^7.1.1",
+ "load-json-file": "^2.0.0",
+ "tape": "^4.6.3"
+ },
+ "dependencies": {
+ "@turf/helpers": "^4.2.0",
+ "@turf/inside": "^4.2.0",
+ "@turf/invariant": "^4.2.0",
+ "@turf/line-overlap": "^4.2.0",
+ "deep-equal": "^1.0.1"
+ }
+}
diff --git a/packages/turf-boolean-contains/test.js b/packages/turf-boolean-contains/test.js
new file mode 100644
index 0000000000..f25af77f33
--- /dev/null
+++ b/packages/turf-boolean-contains/test.js
@@ -0,0 +1,76 @@
+const glob = require('glob');
+const path = require('path');
+const test = require('tape');
+const load = require('load-json-file');
+const {point, multiPoint, lineString, polygon} = require('@turf/helpers');
+const contains = require('./');
+
+test('turf-boolean-contains#fixtures', t => {
+ // True Fixtures
+ glob.sync(path.join(__dirname, 'test', 'true', '*.geojson')).forEach(filepath => {
+ const {name} = path.parse(filepath);
+ const geojson = load.sync(filepath);
+ const [feature1, feature2] = geojson.features;
+ t.true(contains(feature1, feature2), '[true] ' + name);
+ });
+ // False Fixtures
+ glob.sync(path.join(__dirname, 'test', 'false', '*.geojson')).forEach(filepath => {
+ const {name} = path.parse(filepath);
+ const geojson = load.sync(filepath);
+ const [feature1, feature2] = geojson.features;
+ t.false(contains(feature1, feature2), '[false] ' + name);
+ });
+ t.end();
+});
+
+test('turf-boolean-contains', t => {
+ const pt1 = point([1, 1]);
+ const pt2 = point([1, 4]);
+ const pt3 = point([4, 4]);
+ const pt4 = point([14, 14]);
+
+ const mp1 = multiPoint([[1, 1], [12, 12]]);
+ const mp2 = multiPoint([[1, 1], [1, 1.5]]);
+ const mp3 = multiPoint([[1, 1], [12, 12], [15, 15]]);
+
+ t.equal(contains(mp1, pt1), true, 'Point is contained within multipoint');
+ t.equal(contains(mp1, pt2), false, 'Point is not contained outside multipoint');
+
+ t.equal(contains(mp3, mp1), true, 'True if all multipoints are contained with within multipoints');
+ t.equal(contains(mp3, mp2), false, 'False if some multipoints are elsewhere');
+
+ const line1 = lineString([[1, 1], [1, 2], [1, 3], [1, 4]]);
+ t.equal(contains(line1, pt1), true, 'Point is on line');
+ t.equal(contains(line1, pt3), false, 'Point is not on line');
+
+ t.equal(contains(line1, mp2), true, 'MultiPoint is on line');
+ t.equal(contains(line1, mp3), false, 'MultiPoint is not on line');
+
+ const poly1 = polygon([[[1, 1], [1, 10], [10, 10], [10, 1], [1, 1]]]);
+ t.equal(contains(poly1, pt3), true, 'A point lies inside the polygon boundary');
+ t.equal(contains(poly1, pt1), true, 'A point lies on the polygon boundary');
+ t.equal(contains(poly1, pt4), false, 'A point lies outside the polygon boundary fails');
+
+ const mp4 = multiPoint([[1, 1], [4, 4]]);
+ t.equal(contains(poly1, mp4), true, 'A multipoint lies inside the polygon boundary');
+ t.equal(contains(poly1, mp1), false, 'A multipoint with a point outside fails');
+
+
+ const line2 = lineString([[1, 2], [1, 3], [1, 3.5]]);
+ const line3 = lineString([[1, 2], [1, 3], [1, 15.5]]);
+
+ t.equal(contains(line1, line2), true, 'A line lies inside the other line');
+ t.skip(contains(line1, line3), false, 'A line fails that lies partially outside the other line');
+
+ t.equal(contains(poly1, line1), true, 'A line within the poly passes as true');
+ t.equal(contains(poly1, line3), false, 'A line that lies partially outside the poly is false');
+
+
+ const poly2 = polygon([[[1, 1], [1, 2], [1, 3], [1, 4], [1, 1]]]);
+ const poly3 = polygon([[[1, 1], [1, 20], [1, 3], [1, 4], [1, 1]]]);
+
+ t.equal(contains(poly1, poly2), true, 'A poly passes that is inside although allows touching edges');
+ t.equal(contains(poly1, poly3), false, 'A poly fails that has a vertice outside the poly');
+
+ t.end();
+});
diff --git a/packages/turf-boolean-contains/test/false/false-polygon-overlap.geojson b/packages/turf-boolean-contains/test/false/false-polygon-overlap.geojson
new file mode 100644
index 0000000000..5f2774e9cb
--- /dev/null
+++ b/packages/turf-boolean-contains/test/false/false-polygon-overlap.geojson
@@ -0,0 +1,71 @@
+{
+ "type": "FeatureCollection",
+ "features": [
+ {
+ "type": "Feature",
+ "properties": {
+ "fill": "#F00"
+ },
+ "geometry": {
+ "type": "Polygon",
+ "coordinates": [
+ [
+ [
+ -12.65625,
+ 36.87962060502676
+ ],
+ [
+ 35.419921875,
+ 36.38591277287651
+ ],
+ [
+ 37.79296875,
+ 56.897003921272606
+ ],
+ [
+ -12.12890625,
+ 57.040729838360875
+ ],
+ [
+ -12.65625,
+ 36.87962060502676
+ ]
+ ]
+ ]
+ }
+ },
+ {
+ "type": "Feature",
+ "properties": {
+ "fill": "#F00"
+ },
+ "geometry": {
+ "type": "Polygon",
+ "coordinates": [
+ [
+ [
+ -12.65625,
+ 36.87962060502676
+ ],
+ [
+ 35.419921875,
+ 36.38591277287651
+ ],
+ [
+ 37.79296875,
+ 56.897003921272606
+ ],
+ [
+ -12.12890625,
+ 57.040729838360875
+ ],
+ [
+ -12.65625,
+ 36.87962060502676
+ ]
+ ]
+ ]
+ }
+ }
+ ]
+}
\ No newline at end of file
diff --git a/packages/turf-boolean-contains/test/false/false-polygons1.geojson b/packages/turf-boolean-contains/test/false/false-polygons1.geojson
new file mode 100644
index 0000000000..8fb03f4ffb
--- /dev/null
+++ b/packages/turf-boolean-contains/test/false/false-polygons1.geojson
@@ -0,0 +1,71 @@
+{
+ "type": "FeatureCollection",
+ "features": [
+ {
+ "type": "Feature",
+ "properties": {
+ "fill": "#00F"
+ },
+ "geometry": {
+ "type": "Polygon",
+ "coordinates": [
+ [
+ [
+ 11.162109375000028,
+ 46.37725420510028
+ ],
+ [
+ 19.24804687500004,
+ 46.37725420510028
+ ],
+ [
+ 19.24804687500004,
+ 50.12057809796008
+ ],
+ [
+ 11.162109375000028,
+ 50.12057809796008
+ ],
+ [
+ 11.162109375000028,
+ 46.37725420510028
+ ]
+ ]
+ ]
+ }
+ },
+ {
+ "type": "Feature",
+ "properties": {
+ "fill": "#F00"
+ },
+ "geometry": {
+ "type": "Polygon",
+ "coordinates": [
+ [
+ [
+ -12.65625,
+ 36.87962060502676
+ ],
+ [
+ 35.419921875,
+ 36.38591277287651
+ ],
+ [
+ 37.79296875,
+ 56.897003921272606
+ ],
+ [
+ -12.12890625,
+ 57.040729838360875
+ ],
+ [
+ -12.65625,
+ 36.87962060502676
+ ]
+ ]
+ ]
+ }
+ }
+ ]
+}
\ No newline at end of file
diff --git a/packages/turf-boolean-contains/test/false/false-polygons2.geojson b/packages/turf-boolean-contains/test/false/false-polygons2.geojson
new file mode 100644
index 0000000000..0fd7930128
--- /dev/null
+++ b/packages/turf-boolean-contains/test/false/false-polygons2.geojson
@@ -0,0 +1,159 @@
+{
+ "type": "FeatureCollection",
+ "features": [
+ {
+ "type": "Feature",
+ "properties": {},
+ "geometry": {
+ "type": "Polygon",
+ "coordinates": [
+ [
+ [
+ -2.109375,
+ 44.08758502824516
+ ],
+ [
+ -12.65625,
+ 25.799891182088334
+ ],
+ [
+ -1.40625,
+ 7.710991655433217
+ ],
+ [
+ 24.609375,
+ 7.710991655433217
+ ],
+ [
+ 20.390625,
+ 22.59372606392931
+ ],
+ [
+ 25.3125,
+ 31.952162238024975
+ ],
+ [
+ 18.984375,
+ 46.07323062540835
+ ],
+ [
+ 11.25,
+ 37.71859032558816
+ ],
+ [
+ -2.109375,
+ 44.08758502824516
+ ]
+ ]
+ ]
+ }
+ },
+ {
+ "type": "Feature",
+ "properties": {},
+ "geometry": {
+ "type": "Polygon",
+ "coordinates": [
+ [
+ [
+ -49.92187499999999,
+ 9.44906182688142
+ ],
+ [
+ -40.42968749999999,
+ -14.944784875088372
+ ],
+ [
+ -28.125,
+ -27.68352808378776
+ ],
+ [
+ -9.140625,
+ -32.842673631954305
+ ],
+ [
+ 9.84375,
+ -34.30714385628803
+ ],
+ [
+ 23.203125,
+ -34.016241889667015
+ ],
+ [
+ 39.375,
+ -29.84064389983441
+ ],
+ [
+ 60.8203125,
+ -17.978733095556155
+ ],
+ [
+ 62.9296875,
+ -2.460181181020993
+ ],
+ [
+ 72.421875,
+ 16.97274101999902
+ ],
+ [
+ 79.8046875,
+ 16.97274101999902
+ ],
+ [
+ 75.5859375,
+ 39.90973623453719
+ ],
+ [
+ 62.9296875,
+ 47.27922900257082
+ ],
+ [
+ 30.585937499999996,
+ 62.2679226294176
+ ],
+ [
+ 9.4921875,
+ 66.65297740055279
+ ],
+ [
+ -25.6640625,
+ 70.1403642720717
+ ],
+ [
+ -46.7578125,
+ 70.02058730174062
+ ],
+ [
+ -61.52343749999999,
+ 63.704722429433225
+ ],
+ [
+ -62.9296875,
+ 48.922499263758255
+ ],
+ [
+ -57.65624999999999,
+ 39.095962936305476
+ ],
+ [
+ -45,
+ 31.952162238024975
+ ],
+ [
+ -37.96875,
+ 18.646245142670608
+ ],
+ [
+ -32.6953125,
+ 12.554563528593656
+ ],
+ [
+ -49.92187499999999,
+ 9.44906182688142
+ ]
+ ]
+ ]
+ }
+ }
+ ]
+}
\ No newline at end of file
diff --git a/packages/turf-boolean-contains/test/true/true-polygons1.geojson b/packages/turf-boolean-contains/test/true/true-polygons1.geojson
new file mode 100644
index 0000000000..4b92dda9a9
--- /dev/null
+++ b/packages/turf-boolean-contains/test/true/true-polygons1.geojson
@@ -0,0 +1,71 @@
+{
+ "type": "FeatureCollection",
+ "features": [
+ {
+ "type": "Feature",
+ "properties": {
+ "fill": "#F00"
+ },
+ "geometry": {
+ "type": "Polygon",
+ "coordinates": [
+ [
+ [
+ -12.65625,
+ 36.87962060502676
+ ],
+ [
+ 35.419921875,
+ 36.38591277287651
+ ],
+ [
+ 37.79296875,
+ 56.897003921272606
+ ],
+ [
+ -12.12890625,
+ 57.040729838360875
+ ],
+ [
+ -12.65625,
+ 36.87962060502676
+ ]
+ ]
+ ]
+ }
+ },
+ {
+ "type": "Feature",
+ "properties": {
+ "fill": "#00F"
+ },
+ "geometry": {
+ "type": "Polygon",
+ "coordinates": [
+ [
+ [
+ 11.162109375000028,
+ 46.37725420510028
+ ],
+ [
+ 19.24804687500004,
+ 46.37725420510028
+ ],
+ [
+ 19.24804687500004,
+ 50.12057809796008
+ ],
+ [
+ 11.162109375000028,
+ 50.12057809796008
+ ],
+ [
+ 11.162109375000028,
+ 46.37725420510028
+ ]
+ ]
+ ]
+ }
+ }
+ ]
+}
\ No newline at end of file
diff --git a/packages/turf-boolean-contains/test/true/true-polygons2.geojson b/packages/turf-boolean-contains/test/true/true-polygons2.geojson
new file mode 100644
index 0000000000..b49ed76e9b
--- /dev/null
+++ b/packages/turf-boolean-contains/test/true/true-polygons2.geojson
@@ -0,0 +1,159 @@
+{
+ "type": "FeatureCollection",
+ "features": [
+ {
+ "type": "Feature",
+ "properties": {},
+ "geometry": {
+ "type": "Polygon",
+ "coordinates": [
+ [
+ [
+ -49.92187499999999,
+ 9.44906182688142
+ ],
+ [
+ -40.42968749999999,
+ -14.944784875088372
+ ],
+ [
+ -28.125,
+ -27.68352808378776
+ ],
+ [
+ -9.140625,
+ -32.842673631954305
+ ],
+ [
+ 9.84375,
+ -34.30714385628803
+ ],
+ [
+ 23.203125,
+ -34.016241889667015
+ ],
+ [
+ 39.375,
+ -29.84064389983441
+ ],
+ [
+ 60.8203125,
+ -17.978733095556155
+ ],
+ [
+ 62.9296875,
+ -2.460181181020993
+ ],
+ [
+ 72.421875,
+ 16.97274101999902
+ ],
+ [
+ 79.8046875,
+ 16.97274101999902
+ ],
+ [
+ 75.5859375,
+ 39.90973623453719
+ ],
+ [
+ 62.9296875,
+ 47.27922900257082
+ ],
+ [
+ 30.585937499999996,
+ 62.2679226294176
+ ],
+ [
+ 9.4921875,
+ 66.65297740055279
+ ],
+ [
+ -25.6640625,
+ 70.1403642720717
+ ],
+ [
+ -46.7578125,
+ 70.02058730174062
+ ],
+ [
+ -61.52343749999999,
+ 63.704722429433225
+ ],
+ [
+ -62.9296875,
+ 48.922499263758255
+ ],
+ [
+ -57.65624999999999,
+ 39.095962936305476
+ ],
+ [
+ -45,
+ 31.952162238024975
+ ],
+ [
+ -37.96875,
+ 18.646245142670608
+ ],
+ [
+ -32.6953125,
+ 12.554563528593656
+ ],
+ [
+ -49.92187499999999,
+ 9.44906182688142
+ ]
+ ]
+ ]
+ }
+ },
+ {
+ "type": "Feature",
+ "properties": {},
+ "geometry": {
+ "type": "Polygon",
+ "coordinates": [
+ [
+ [
+ -2.109375,
+ 44.08758502824516
+ ],
+ [
+ -12.65625,
+ 25.799891182088334
+ ],
+ [
+ -1.40625,
+ 7.710991655433217
+ ],
+ [
+ 24.609375,
+ 7.710991655433217
+ ],
+ [
+ 20.390625,
+ 22.59372606392931
+ ],
+ [
+ 25.3125,
+ 31.952162238024975
+ ],
+ [
+ 18.984375,
+ 46.07323062540835
+ ],
+ [
+ 11.25,
+ 37.71859032558816
+ ],
+ [
+ -2.109375,
+ 44.08758502824516
+ ]
+ ]
+ ]
+ }
+ }
+ ]
+}
\ No newline at end of file
diff --git a/packages/turf-boolean-contains/yarn.lock b/packages/turf-boolean-contains/yarn.lock
new file mode 100644
index 0000000000..8680049857
--- /dev/null
+++ b/packages/turf-boolean-contains/yarn.lock
@@ -0,0 +1,318 @@
+# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
+# yarn lockfile v1
+
+
+"@turf/bbox@^3.10.5":
+ version "3.14.0"
+ resolved "https://registry.yarnpkg.com/@turf/bbox/-/bbox-3.14.0.tgz#cee5f396dde78aca9cede05e1122db18bc504635"
+ dependencies:
+ "@turf/meta" "^3.14.0"
+
+"@turf/bbox@^4.2.0":
+ version "4.3.0"
+ resolved "https://registry.yarnpkg.com/@turf/bbox/-/bbox-4.3.0.tgz#644c4b745172d21aae70d1584b2a7866f1040865"
+ dependencies:
+ "@turf/meta" "^4.3.0"
+
+"@turf/helpers@^3.10.5":
+ version "3.13.0"
+ resolved "https://registry.yarnpkg.com/@turf/helpers/-/helpers-3.13.0.tgz#d06078a1464cf56cdb7ea624ea1e13a71b88b806"
+
+"@turf/helpers@^4.2.0", "@turf/helpers@^4.3.0":
+ version "4.3.0"
+ resolved "https://registry.yarnpkg.com/@turf/helpers/-/helpers-4.3.0.tgz#7b2f733aa0eb3ea1f07d467ac02ede00cc6cde0d"
+
+"@turf/inside@^4.2.0":
+ version "4.3.0"
+ resolved "https://registry.yarnpkg.com/@turf/inside/-/inside-4.3.0.tgz#ba06be5966a5ab31c1cabb9819241e0802422c45"
+ dependencies:
+ "@turf/invariant" "^4.3.0"
+
+"@turf/invariant@^4.2.0", "@turf/invariant@^4.3.0":
+ version "4.3.0"
+ resolved "https://registry.yarnpkg.com/@turf/invariant/-/invariant-4.3.0.tgz#5bd1ce6ae51b1229dc0dc7d09d973fabae49af89"
+
+"@turf/line-overlap@^4.2.0":
+ version "4.3.0"
+ resolved "https://registry.yarnpkg.com/@turf/line-overlap/-/line-overlap-4.3.0.tgz#f0572d3a3f536a35055d857099b5d1549cfd0074"
+ dependencies:
+ "@turf/helpers" "^4.3.0"
+ "@turf/invariant" "^4.3.0"
+ "@turf/line-segment" "^4.3.0"
+ "@turf/meta" "^4.3.0"
+ deep-equal "^1.0.1"
+ geojson-rbush "^1.0.1"
+
+"@turf/line-segment@^4.3.0":
+ version "4.3.0"
+ resolved "https://registry.yarnpkg.com/@turf/line-segment/-/line-segment-4.3.0.tgz#7835209227f3c0712ec549c6f51af72394c638ab"
+ dependencies:
+ "@turf/helpers" "^4.3.0"
+ "@turf/invariant" "^4.3.0"
+ "@turf/meta" "^4.3.0"
+
+"@turf/meta@^3.10.5", "@turf/meta@^3.14.0":
+ version "3.14.0"
+ resolved "https://registry.yarnpkg.com/@turf/meta/-/meta-3.14.0.tgz#8d3050c1a0f44bf406a633b6bd28c510f7bcee27"
+
+"@turf/meta@^4.3.0":
+ version "4.3.0"
+ resolved "https://registry.yarnpkg.com/@turf/meta/-/meta-4.3.0.tgz#eb11dd2c2511524258123767fe0f5c3bd963e8d7"
+
+balanced-match@^0.4.1:
+ version "0.4.2"
+ resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-0.4.2.tgz#cb3f3e3c732dc0f01ee70b403f302e61d7709838"
+
+benchmark@^2.1.4:
+ version "2.1.4"
+ resolved "https://registry.yarnpkg.com/benchmark/-/benchmark-2.1.4.tgz#09f3de31c916425d498cc2ee565a0ebf3c2a5629"
+ dependencies:
+ lodash "^4.17.4"
+ platform "^1.3.3"
+
+brace-expansion@^1.1.7:
+ version "1.1.7"
+ resolved "https://registry.yarnpkg.com/brace-expansion/-/brace-expansion-1.1.7.tgz#3effc3c50e000531fb720eaff80f0ae8ef23cf59"
+ dependencies:
+ balanced-match "^0.4.1"
+ concat-map "0.0.1"
+
+concat-map@0.0.1:
+ version "0.0.1"
+ resolved "https://registry.yarnpkg.com/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b"
+
+deep-equal@^1.0.1, deep-equal@~1.0.1:
+ version "1.0.1"
+ resolved "https://registry.yarnpkg.com/deep-equal/-/deep-equal-1.0.1.tgz#f5d260292b660e084eff4cdbc9f08ad3247448b5"
+
+define-properties@^1.1.2:
+ version "1.1.2"
+ resolved "https://registry.yarnpkg.com/define-properties/-/define-properties-1.1.2.tgz#83a73f2fea569898fb737193c8f873caf6d45c94"
+ dependencies:
+ foreach "^2.0.5"
+ object-keys "^1.0.8"
+
+defined@~1.0.0:
+ version "1.0.0"
+ resolved "https://registry.yarnpkg.com/defined/-/defined-1.0.0.tgz#c98d9bcef75674188e110969151199e39b1fa693"
+
+error-ex@^1.2.0:
+ version "1.3.1"
+ resolved "https://registry.yarnpkg.com/error-ex/-/error-ex-1.3.1.tgz#f855a86ce61adc4e8621c3cda21e7a7612c3a8dc"
+ dependencies:
+ is-arrayish "^0.2.1"
+
+es-abstract@^1.5.0:
+ version "1.7.0"
+ resolved "https://registry.yarnpkg.com/es-abstract/-/es-abstract-1.7.0.tgz#dfade774e01bfcd97f96180298c449c8623fb94c"
+ dependencies:
+ es-to-primitive "^1.1.1"
+ function-bind "^1.1.0"
+ is-callable "^1.1.3"
+ is-regex "^1.0.3"
+
+es-to-primitive@^1.1.1:
+ version "1.1.1"
+ resolved "https://registry.yarnpkg.com/es-to-primitive/-/es-to-primitive-1.1.1.tgz#45355248a88979034b6792e19bb81f2b7975dd0d"
+ dependencies:
+ is-callable "^1.1.1"
+ is-date-object "^1.0.1"
+ is-symbol "^1.0.1"
+
+for-each@~0.3.2:
+ version "0.3.2"
+ resolved "https://registry.yarnpkg.com/for-each/-/for-each-0.3.2.tgz#2c40450b9348e97f281322593ba96704b9abd4d4"
+ dependencies:
+ is-function "~1.0.0"
+
+foreach@^2.0.5:
+ version "2.0.5"
+ resolved "https://registry.yarnpkg.com/foreach/-/foreach-2.0.5.tgz#0bee005018aeb260d0a3af3ae658dd0136ec1b99"
+
+fs.realpath@^1.0.0:
+ version "1.0.0"
+ resolved "https://registry.yarnpkg.com/fs.realpath/-/fs.realpath-1.0.0.tgz#1504ad2523158caa40db4a2787cb01411994ea4f"
+
+function-bind@^1.0.2, function-bind@^1.1.0, function-bind@~1.1.0:
+ version "1.1.0"
+ resolved "https://registry.yarnpkg.com/function-bind/-/function-bind-1.1.0.tgz#16176714c801798e4e8f2cf7f7529467bb4a5771"
+
+geojson-rbush@^1.0.1:
+ version "1.0.1"
+ resolved "https://registry.yarnpkg.com/geojson-rbush/-/geojson-rbush-1.0.1.tgz#450559bc18457e725191ac9acbbe0a8b5e18ddae"
+ dependencies:
+ "@turf/bbox" "^3.10.5"
+ "@turf/helpers" "^3.10.5"
+ "@turf/meta" "^3.10.5"
+ rbush "^2.0.1"
+
+glob@^7.1.1, glob@~7.1.1:
+ version "7.1.2"
+ resolved "https://registry.yarnpkg.com/glob/-/glob-7.1.2.tgz#c19c9df9a028702d678612384a6552404c636d15"
+ dependencies:
+ fs.realpath "^1.0.0"
+ inflight "^1.0.4"
+ inherits "2"
+ minimatch "^3.0.4"
+ once "^1.3.0"
+ path-is-absolute "^1.0.0"
+
+graceful-fs@^4.1.2:
+ version "4.1.11"
+ resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.1.11.tgz#0e8bdfe4d1ddb8854d64e04ea7c00e2a026e5658"
+
+has@^1.0.1, has@~1.0.1:
+ version "1.0.1"
+ resolved "https://registry.yarnpkg.com/has/-/has-1.0.1.tgz#8461733f538b0837c9361e39a9ab9e9704dc2f28"
+ dependencies:
+ function-bind "^1.0.2"
+
+inflight@^1.0.4:
+ version "1.0.6"
+ resolved "https://registry.yarnpkg.com/inflight/-/inflight-1.0.6.tgz#49bd6331d7d02d0c09bc910a1075ba8165b56df9"
+ dependencies:
+ once "^1.3.0"
+ wrappy "1"
+
+inherits@2, inherits@~2.0.3:
+ version "2.0.3"
+ resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.3.tgz#633c2c83e3da42a502f52466022480f4208261de"
+
+is-arrayish@^0.2.1:
+ version "0.2.1"
+ resolved "https://registry.yarnpkg.com/is-arrayish/-/is-arrayish-0.2.1.tgz#77c99840527aa8ecb1a8ba697b80645a7a926a9d"
+
+is-callable@^1.1.1, is-callable@^1.1.3:
+ version "1.1.3"
+ resolved "https://registry.yarnpkg.com/is-callable/-/is-callable-1.1.3.tgz#86eb75392805ddc33af71c92a0eedf74ee7604b2"
+
+is-date-object@^1.0.1:
+ version "1.0.1"
+ resolved "https://registry.yarnpkg.com/is-date-object/-/is-date-object-1.0.1.tgz#9aa20eb6aeebbff77fbd33e74ca01b33581d3a16"
+
+is-function@~1.0.0:
+ version "1.0.1"
+ resolved "https://registry.yarnpkg.com/is-function/-/is-function-1.0.1.tgz#12cfb98b65b57dd3d193a3121f5f6e2f437602b5"
+
+is-regex@^1.0.3:
+ version "1.0.4"
+ resolved "https://registry.yarnpkg.com/is-regex/-/is-regex-1.0.4.tgz#5517489b547091b0930e095654ced25ee97e9491"
+ dependencies:
+ has "^1.0.1"
+
+is-symbol@^1.0.1:
+ version "1.0.1"
+ resolved "https://registry.yarnpkg.com/is-symbol/-/is-symbol-1.0.1.tgz#3cc59f00025194b6ab2e38dbae6689256b660572"
+
+load-json-file@^2.0.0:
+ version "2.0.0"
+ resolved "https://registry.yarnpkg.com/load-json-file/-/load-json-file-2.0.0.tgz#7947e42149af80d696cbf797bcaabcfe1fe29ca8"
+ dependencies:
+ graceful-fs "^4.1.2"
+ parse-json "^2.2.0"
+ pify "^2.0.0"
+ strip-bom "^3.0.0"
+
+lodash@^4.17.4:
+ version "4.17.4"
+ resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.4.tgz#78203a4d1c328ae1d86dca6460e369b57f4055ae"
+
+minimatch@^3.0.4:
+ version "3.0.4"
+ resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.0.4.tgz#5166e286457f03306064be5497e8dbb0c3d32083"
+ dependencies:
+ brace-expansion "^1.1.7"
+
+minimist@~1.2.0:
+ version "1.2.0"
+ resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.0.tgz#a35008b20f41383eec1fb914f4cd5df79a264284"
+
+object-inspect@~1.2.1:
+ version "1.2.2"
+ resolved "https://registry.yarnpkg.com/object-inspect/-/object-inspect-1.2.2.tgz#c82115e4fcc888aea14d64c22e4f17f6a70d5e5a"
+
+object-keys@^1.0.8:
+ version "1.0.11"
+ resolved "https://registry.yarnpkg.com/object-keys/-/object-keys-1.0.11.tgz#c54601778ad560f1142ce0e01bcca8b56d13426d"
+
+once@^1.3.0:
+ version "1.4.0"
+ resolved "https://registry.yarnpkg.com/once/-/once-1.4.0.tgz#583b1aa775961d4b113ac17d9c50baef9dd76bd1"
+ dependencies:
+ wrappy "1"
+
+parse-json@^2.2.0:
+ version "2.2.0"
+ resolved "https://registry.yarnpkg.com/parse-json/-/parse-json-2.2.0.tgz#f480f40434ef80741f8469099f8dea18f55a4dc9"
+ dependencies:
+ error-ex "^1.2.0"
+
+path-is-absolute@^1.0.0:
+ version "1.0.1"
+ resolved "https://registry.yarnpkg.com/path-is-absolute/-/path-is-absolute-1.0.1.tgz#174b9268735534ffbc7ace6bf53a5a9e1b5c5f5f"
+
+pify@^2.0.0:
+ version "2.3.0"
+ resolved "https://registry.yarnpkg.com/pify/-/pify-2.3.0.tgz#ed141a6ac043a849ea588498e7dca8b15330e90c"
+
+platform@^1.3.3:
+ version "1.3.4"
+ resolved "https://registry.yarnpkg.com/platform/-/platform-1.3.4.tgz#6f0fb17edaaa48f21442b3a975c063130f1c3ebd"
+
+quickselect@^1.0.0:
+ version "1.0.0"
+ resolved "https://registry.yarnpkg.com/quickselect/-/quickselect-1.0.0.tgz#02630818f9aae4ecab26f0103f98d061c17c58f3"
+
+rbush@^2.0.1:
+ version "2.0.1"
+ resolved "https://registry.yarnpkg.com/rbush/-/rbush-2.0.1.tgz#4cfaca28c3064bc0ee75431a1b79990e875eefa9"
+ dependencies:
+ quickselect "^1.0.0"
+
+resolve@~1.1.7:
+ version "1.1.7"
+ resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.1.7.tgz#203114d82ad2c5ed9e8e0411b3932875e889e97b"
+
+resumer@~0.0.0:
+ version "0.0.0"
+ resolved "https://registry.yarnpkg.com/resumer/-/resumer-0.0.0.tgz#f1e8f461e4064ba39e82af3cdc2a8c893d076759"
+ dependencies:
+ through "~2.3.4"
+
+string.prototype.trim@~1.1.2:
+ version "1.1.2"
+ resolved "https://registry.yarnpkg.com/string.prototype.trim/-/string.prototype.trim-1.1.2.tgz#d04de2c89e137f4d7d206f086b5ed2fae6be8cea"
+ dependencies:
+ define-properties "^1.1.2"
+ es-abstract "^1.5.0"
+ function-bind "^1.0.2"
+
+strip-bom@^3.0.0:
+ version "3.0.0"
+ resolved "https://registry.yarnpkg.com/strip-bom/-/strip-bom-3.0.0.tgz#2334c18e9c759f7bdd56fdef7e9ae3d588e68ed3"
+
+tape@^4.6.3:
+ version "4.6.3"
+ resolved "https://registry.yarnpkg.com/tape/-/tape-4.6.3.tgz#637e77581e9ab2ce17577e9bd4ce4f575806d8b6"
+ dependencies:
+ deep-equal "~1.0.1"
+ defined "~1.0.0"
+ for-each "~0.3.2"
+ function-bind "~1.1.0"
+ glob "~7.1.1"
+ has "~1.0.1"
+ inherits "~2.0.3"
+ minimist "~1.2.0"
+ object-inspect "~1.2.1"
+ resolve "~1.1.7"
+ resumer "~0.0.0"
+ string.prototype.trim "~1.1.2"
+ through "~2.3.8"
+
+through@~2.3.4, through@~2.3.8:
+ version "2.3.8"
+ resolved "https://registry.yarnpkg.com/through/-/through-2.3.8.tgz#0dd4c9ffaabc357960b1b724115d7e0e86a2e1f5"
+
+wrappy@1:
+ version "1.0.2"
+ resolved "https://registry.yarnpkg.com/wrappy/-/wrappy-1.0.2.tgz#b5243d8f3ec1aa35f1364605bc0d1036e30ab69f"
diff --git a/packages/turf-boolean-cross/LICENSE b/packages/turf-boolean-cross/LICENSE
new file mode 100644
index 0000000000..96ce51b76f
--- /dev/null
+++ b/packages/turf-boolean-cross/LICENSE
@@ -0,0 +1,20 @@
+The MIT License (MIT)
+
+Copyright (c) 2017 TurfJS
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of
+this software and associated documentation files (the "Software"), to deal in
+the Software without restriction, including without limitation the rights to
+use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
+the Software, and to permit persons to whom the Software is furnished to do so,
+subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
+FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
+COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
diff --git a/packages/turf-boolean-cross/README.md b/packages/turf-boolean-cross/README.md
new file mode 100644
index 0000000000..321fe5c1fa
--- /dev/null
+++ b/packages/turf-boolean-cross/README.md
@@ -0,0 +1,47 @@
+# @turf/boolean-cross
+
+# cross
+
+Cross returns True if the intersection results in a geometry whose dimension is one less than
+the maximum dimension of the two source geometries and the intersection set is interior to
+both source geometries.
+
+Cross returns t (TRUE) for only multipoint/polygon, multipoint/linestring, linestring/linestring, linestring/polygon, and linestring/multipolygon comparisons.
+
+**Parameters**
+
+- `feature1` **([Geometry](http://geojson.org/geojson-spec.html#geometry) \| [Feature](http://geojson.org/geojson-spec.html#feature-objects)<any>)** GeoJSON Feature or Geometry
+- `feature2` **([Geometry](http://geojson.org/geojson-spec.html#geometry) \| [Feature](http://geojson.org/geojson-spec.html#feature-objects)<any>)** GeoJSON Feature or Geometry
+
+**Examples**
+
+```javascript
+var cross = turf.cross(feature1, feature2);
+```
+
+Returns **[Boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** true/false
+
+
+
+---
+
+This module is part of the [Turfjs project](http://turfjs.org/), an open source
+module collection dedicated to geographic algorithms. It is maintained in the
+[Turfjs/turf](/~https://github.com/Turfjs/turf) repository, where you can create
+PRs and issues.
+
+### Installation
+
+Install this module individually:
+
+```sh
+$ npm install @turf/boolean-cross
+```
+
+Or install the Turf module that includes it as a function:
+
+```sh
+$ npm install @turf/turf
+```
diff --git a/packages/turf-boolean-cross/bench.js b/packages/turf-boolean-cross/bench.js
new file mode 100644
index 0000000000..d60c656a01
--- /dev/null
+++ b/packages/turf-boolean-cross/bench.js
@@ -0,0 +1,28 @@
+const Benchmark = require('benchmark');
+const {point, lineString, polygon} = require('@turf/helpers');
+const cross = require('./');
+
+// Fixtures
+const pt = point([1, 1]);
+const line = lineString([[1, 1], [1, 2], [1, 3], [1, 4]]);
+const poly = polygon([[[1, 1], [1, 10], [10, 10], [10, 1], [1, 1]]]);
+
+/**
+ * Benchmark Results
+ *
+ * point - line x 49,662,649 ops/sec ±1.19% (87 runs sampled)
+ * point - polygon x 42,164,979 ops/sec ±0.84% (90 runs sampled)
+ * point - point x 19,729,671 ops/sec ±0.91% (93 runs sampled)
+ * polygon - polygon x 9,670,025 ops/sec ±1.10% (87 runs sampled)
+ * line - line x 12,731,539 ops/sec ±1.12% (85 runs sampled)
+ */
+const suite = new Benchmark.Suite('turf-boolean-cross');
+suite
+ .add('point - line', () => cross(pt, line))
+ .add('point - polygon', () => cross(pt, polygon))
+ .add('point - point', () => cross(pt, pt))
+ .add('polygon - polygon', () => cross(poly, poly))
+ .add('line - line', () => cross(line, line))
+ .on('cycle', e => console.log(String(e.target)))
+ .on('complete', () => {})
+ .run();
diff --git a/packages/turf-boolean-cross/index.d.ts b/packages/turf-boolean-cross/index.d.ts
new file mode 100644
index 0000000000..4e7f6a3bc4
--- /dev/null
+++ b/packages/turf-boolean-cross/index.d.ts
@@ -0,0 +1,10 @@
+///
+
+type Feature = GeoJSON.Feature | GeoJSON.GeometryObject;
+
+/**
+ * http://turfjs.org/docs/#boolean-cross
+ */
+declare function cross(feature1: Feature, feature2: Feature): boolean;
+declare namespace cross { }
+export = cross;
diff --git a/packages/turf-boolean-cross/index.js b/packages/turf-boolean-cross/index.js
new file mode 100644
index 0000000000..164712a1fb
--- /dev/null
+++ b/packages/turf-boolean-cross/index.js
@@ -0,0 +1,112 @@
+var helpers = require('@turf/helpers');
+var inside = require('@turf/inside');
+var lineIntersect = require('@turf/line-intersect');
+var polyToLinestring = require('@turf/polygon-to-linestring');
+
+/**
+ * Cross returns True if the intersection results in a geometry whose dimension is one less than
+ * the maximum dimension of the two source geometries and the intersection set is interior to
+ * both source geometries.
+ *
+ * Cross returns t (TRUE) for only multipoint/polygon, multipoint/linestring, linestring/linestring, linestring/polygon, and linestring/multipolygon comparisons.
+ *
+ * @name cross
+ * @param {Geometry|Feature} feature1 GeoJSON Feature or Geometry
+ * @param {Geometry|Feature} feature2 GeoJSON Feature or Geometry
+ * @returns {Boolean} true/false
+ * @example
+ * var cross = turf.cross(feature1, feature2);
+ */
+module.exports = function (feature1, feature2) {
+ if (feature1.geometry.type === 'MultiPoint' && feature2.geometry.type === 'LineString') {
+ return doMultiPointAndLineStringCross(feature1, feature2);
+ }
+ if (feature1.geometry.type === 'MultiPoint' && feature2.geometry.type === 'Polygon') {
+ return doesMultiPointCrossPoly(feature1, feature2);
+ }
+ if (feature1.geometry.type === 'LineString' && feature2.geometry.type === 'LineString') {
+ return doLineStringsCross(feature1, feature2);
+ }
+ if (feature1.geometry.type === 'LineString' && feature2.geometry.type === 'Polygon') {
+ return doLineStringAndPolygonCross(feature1, feature2);
+ }
+};
+
+function doMultiPointAndLineStringCross(MultiPoint, LineString) {
+ var foundIntPoint = false;
+ var foundExtPoint = false;
+ var pointLength = MultiPoint.geometry.coordinates.length;
+ var i = 0;
+ while (i < pointLength && !foundIntPoint && !foundExtPoint) {
+ for (var i2 = 0; i2 < LineString.geometry.coordinates.length - 1; i2++) {
+ if (isPointOnLineSegment(LineString.geometry.coordinates[i2], LineString.geometry.coordinates[i2 + 1], MultiPoint.geometry.coordinates[i])) {
+ foundIntPoint = true;
+ } else {
+ foundExtPoint = true;
+ }
+ }
+ i++;
+ }
+ return foundIntPoint && foundExtPoint;
+}
+
+function doLineStringsCross(LineString1, LineString2) {
+ var doLinesIntersect = lineIntersect(LineString1, LineString2);
+ if (doLinesIntersect.features.length > 0) {
+ // Check that one of the points doesn't lie on the line
+ for (var i = 0; i < LineString1.geometry.coordinates.length - 1; i++) {
+ for (var i2 = 0; i2 < LineString2.geometry.coordinates.length - 1; i2++) {
+ if (!isPointOnLineSegment(LineString1.geometry.coordinates[i], LineString1.geometry.coordinates[i + 1], LineString2.geometry.coordinates[i2])) {
+ return true;
+ }
+ }
+ }
+ }
+ return false;
+}
+
+function doLineStringAndPolygonCross(LineString, Polygon) {
+ var doLinesIntersect = lineIntersect(LineString, polyToLinestring(Polygon));
+ if (doLinesIntersect.features.length > 0) {
+ return true;
+ }
+ return false;
+}
+
+function isPointInPoly(Polygon, Point) {
+ return inside(Point, Polygon);
+}
+
+function doesMultiPointCrossPoly(MultiPoint, Polygon) {
+ var foundIntPoint = false;
+ var foundExtPoint = false;
+ var pointLength = MultiPoint.geometry.coordinates[0].length;
+ var i = 0;
+ while (i < pointLength && foundIntPoint && foundExtPoint) {
+ if (isPointInPoly(Polygon, helpers.point(MultiPoint.geometry.coordinates[0][i]), true)) {
+ foundIntPoint = true;
+ } else {
+ foundExtPoint = true;
+ }
+ i++;
+ }
+
+ return foundExtPoint && foundExtPoint;
+}
+
+// Shall be removed in favor of @turf/boolean-helpers
+function isPointOnLineSegment(LineSegmentStart, LineSegmentEnd, Point) {
+ var dxc = Point[0] - LineSegmentStart[0];
+ var dyc = Point[1] - LineSegmentStart[1];
+ var dxl = LineSegmentEnd[0] - LineSegmentStart[0];
+ var dyl = LineSegmentEnd[1] - LineSegmentStart[1];
+ var cross = dxc * dyl - dyc * dxl;
+ if (cross !== 0) {
+ return false;
+ }
+ if (Math.abs(dxl) >= Math.abs(dyl)) {
+ return dxl > 0 ? LineSegmentStart[0] <= Point[0] && Point[0] <= LineSegmentEnd[0] : LineSegmentEnd[0] <= Point[0] && Point[0] <= LineSegmentStart[0];
+ } else {
+ return dyl > 0 ? LineSegmentStart[1] <= Point[1] && Point[1] <= LineSegmentEnd[1] : LineSegmentEnd[1] <= Point[1] && Point[1] <= LineSegmentStart[1];
+ }
+}
diff --git a/packages/turf-boolean-cross/package.json b/packages/turf-boolean-cross/package.json
new file mode 100644
index 0000000000..4bb26bde71
--- /dev/null
+++ b/packages/turf-boolean-cross/package.json
@@ -0,0 +1,45 @@
+{
+ "name": "@turf/boolean-cross",
+ "version": "4.0.0",
+ "description": "turf boolean-cross module",
+ "main": "index.js",
+ "types": "index.d.ts",
+ "files": [
+ "index.js",
+ "index.d.ts"
+ ],
+ "scripts": {
+ "test": "node test.js",
+ "bench": "node bench.js"
+ },
+ "repository": {
+ "type": "git",
+ "url": "git://github.com/Turfjs/turf.git"
+ },
+ "keywords": [
+ "turf",
+ "equal",
+ "boolean",
+ "de-9im"
+ ],
+ "author": "Turf Authors",
+ "contributors": [
+ "Rowan Winsemius <@rowanwins>",
+ "Denis Carriere <@DenisCarriere>"
+ ],
+ "license": "MIT",
+ "bugs": {
+ "url": "/~https://github.com/Turfjs/turf/issues"
+ },
+ "homepage": "/~https://github.com/Turfjs/turf",
+ "devDependencies": {
+ "benchmark": "^2.1.4",
+ "tape": "^4.6.3"
+ },
+ "dependencies": {
+ "@turf/helpers": "^4.3.0",
+ "@turf/inside": "^4.3.0",
+ "@turf/line-intersect": "^4.3.0",
+ "@turf/polygon-to-linestring": "^4.3.0"
+ }
+}
diff --git a/packages/turf-boolean-cross/test.js b/packages/turf-boolean-cross/test.js
new file mode 100644
index 0000000000..38d72091d9
--- /dev/null
+++ b/packages/turf-boolean-cross/test.js
@@ -0,0 +1,30 @@
+const test = require('tape');
+const {multiPoint, lineString, polygon} = require('@turf/helpers');
+const cross = require('./');
+
+test('turf-boolean-cross', t => {
+
+ const mp1 = multiPoint([[1, 1], [12, 12]]);
+ const mp2 = multiPoint([[2, 2], [1, -1.5]]);
+ const line1 = lineString([[1, 1], [1, 2], [1, 3], [1, 4]]);
+
+ t.equal(cross(mp1, line1), true, 'A point is crosses the line');
+ t.equal(cross(mp2, line1), false, 'A point does not cross the line');
+
+ const line2 = lineString([[-2, 2], [4, 2]]);
+ const line3 = lineString([[-2, 2], [-4, 2]]);
+ const line4 = lineString([[-2, 2], [1, 1]]);
+
+ t.equal(cross(line1, line2), true, 'True if lines cross');
+ t.equal(cross(line1, line3), false, 'False if lines cross');
+ t.skip(cross(line1, line4), false, 'False if lines only touch');
+
+ const poly1 = polygon([[[-1, 2], [3, 2], [3, 3], [-1, 3], [-1, 2]]]);
+ const line5 = lineString([[0.5, 2.5], [1, 1]]);
+
+ t.equal(cross(line1, poly1), true, 'True where a line crosses a polygon');
+ t.equal(cross(line3, poly1), false, 'False where a line does not cross a polygon');
+ t.equal(cross(line5, poly1), true, 'True where a line is both in and outside a polygon');
+
+ t.end();
+});
diff --git a/packages/turf-boolean-cross/yarn.lock b/packages/turf-boolean-cross/yarn.lock
new file mode 100644
index 0000000000..b265d22ecd
--- /dev/null
+++ b/packages/turf-boolean-cross/yarn.lock
@@ -0,0 +1,281 @@
+# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
+# yarn lockfile v1
+
+
+"@turf/bbox@^3.10.5":
+ version "3.14.0"
+ resolved "https://registry.yarnpkg.com/@turf/bbox/-/bbox-3.14.0.tgz#cee5f396dde78aca9cede05e1122db18bc504635"
+ dependencies:
+ "@turf/meta" "^3.14.0"
+
+"@turf/helpers@^3.10.5":
+ version "3.13.0"
+ resolved "https://registry.yarnpkg.com/@turf/helpers/-/helpers-3.13.0.tgz#d06078a1464cf56cdb7ea624ea1e13a71b88b806"
+
+"@turf/helpers@^4.3.0":
+ version "4.3.0"
+ resolved "https://registry.yarnpkg.com/@turf/helpers/-/helpers-4.3.0.tgz#7b2f733aa0eb3ea1f07d467ac02ede00cc6cde0d"
+
+"@turf/inside@^4.3.0":
+ version "4.3.0"
+ resolved "https://registry.yarnpkg.com/@turf/inside/-/inside-4.3.0.tgz#ba06be5966a5ab31c1cabb9819241e0802422c45"
+ dependencies:
+ "@turf/invariant" "^4.3.0"
+
+"@turf/invariant@^4.3.0":
+ version "4.3.0"
+ resolved "https://registry.yarnpkg.com/@turf/invariant/-/invariant-4.3.0.tgz#5bd1ce6ae51b1229dc0dc7d09d973fabae49af89"
+
+"@turf/line-intersect@^4.3.0":
+ version "4.3.0"
+ resolved "https://registry.yarnpkg.com/@turf/line-intersect/-/line-intersect-4.3.0.tgz#0421d1eb2732e14bf8fc02e8b46223f91cd6f9d7"
+ dependencies:
+ "@turf/helpers" "^4.3.0"
+ "@turf/invariant" "^4.3.0"
+ "@turf/line-segment" "^4.3.0"
+ "@turf/meta" "^4.3.0"
+ geojson-rbush "^1.0.1"
+
+"@turf/line-segment@^4.3.0":
+ version "4.3.0"
+ resolved "https://registry.yarnpkg.com/@turf/line-segment/-/line-segment-4.3.0.tgz#7835209227f3c0712ec549c6f51af72394c638ab"
+ dependencies:
+ "@turf/helpers" "^4.3.0"
+ "@turf/invariant" "^4.3.0"
+ "@turf/meta" "^4.3.0"
+
+"@turf/meta@^3.10.5", "@turf/meta@^3.14.0":
+ version "3.14.0"
+ resolved "https://registry.yarnpkg.com/@turf/meta/-/meta-3.14.0.tgz#8d3050c1a0f44bf406a633b6bd28c510f7bcee27"
+
+"@turf/meta@^4.3.0":
+ version "4.3.0"
+ resolved "https://registry.yarnpkg.com/@turf/meta/-/meta-4.3.0.tgz#eb11dd2c2511524258123767fe0f5c3bd963e8d7"
+
+"@turf/polygon-to-linestring@^4.3.0":
+ version "4.3.0"
+ resolved "https://registry.yarnpkg.com/@turf/polygon-to-linestring/-/polygon-to-linestring-4.3.0.tgz#a17c580fc403f2b136295853ca5fff0c981eb0a2"
+ dependencies:
+ "@turf/helpers" "^4.3.0"
+ "@turf/invariant" "^4.3.0"
+
+balanced-match@^0.4.1:
+ version "0.4.2"
+ resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-0.4.2.tgz#cb3f3e3c732dc0f01ee70b403f302e61d7709838"
+
+benchmark@^2.1.4:
+ version "2.1.4"
+ resolved "https://registry.yarnpkg.com/benchmark/-/benchmark-2.1.4.tgz#09f3de31c916425d498cc2ee565a0ebf3c2a5629"
+ dependencies:
+ lodash "^4.17.4"
+ platform "^1.3.3"
+
+brace-expansion@^1.1.7:
+ version "1.1.7"
+ resolved "https://registry.yarnpkg.com/brace-expansion/-/brace-expansion-1.1.7.tgz#3effc3c50e000531fb720eaff80f0ae8ef23cf59"
+ dependencies:
+ balanced-match "^0.4.1"
+ concat-map "0.0.1"
+
+concat-map@0.0.1:
+ version "0.0.1"
+ resolved "https://registry.yarnpkg.com/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b"
+
+deep-equal@~1.0.1:
+ version "1.0.1"
+ resolved "https://registry.yarnpkg.com/deep-equal/-/deep-equal-1.0.1.tgz#f5d260292b660e084eff4cdbc9f08ad3247448b5"
+
+define-properties@^1.1.2:
+ version "1.1.2"
+ resolved "https://registry.yarnpkg.com/define-properties/-/define-properties-1.1.2.tgz#83a73f2fea569898fb737193c8f873caf6d45c94"
+ dependencies:
+ foreach "^2.0.5"
+ object-keys "^1.0.8"
+
+defined@~1.0.0:
+ version "1.0.0"
+ resolved "https://registry.yarnpkg.com/defined/-/defined-1.0.0.tgz#c98d9bcef75674188e110969151199e39b1fa693"
+
+es-abstract@^1.5.0:
+ version "1.7.0"
+ resolved "https://registry.yarnpkg.com/es-abstract/-/es-abstract-1.7.0.tgz#dfade774e01bfcd97f96180298c449c8623fb94c"
+ dependencies:
+ es-to-primitive "^1.1.1"
+ function-bind "^1.1.0"
+ is-callable "^1.1.3"
+ is-regex "^1.0.3"
+
+es-to-primitive@^1.1.1:
+ version "1.1.1"
+ resolved "https://registry.yarnpkg.com/es-to-primitive/-/es-to-primitive-1.1.1.tgz#45355248a88979034b6792e19bb81f2b7975dd0d"
+ dependencies:
+ is-callable "^1.1.1"
+ is-date-object "^1.0.1"
+ is-symbol "^1.0.1"
+
+for-each@~0.3.2:
+ version "0.3.2"
+ resolved "https://registry.yarnpkg.com/for-each/-/for-each-0.3.2.tgz#2c40450b9348e97f281322593ba96704b9abd4d4"
+ dependencies:
+ is-function "~1.0.0"
+
+foreach@^2.0.5:
+ version "2.0.5"
+ resolved "https://registry.yarnpkg.com/foreach/-/foreach-2.0.5.tgz#0bee005018aeb260d0a3af3ae658dd0136ec1b99"
+
+fs.realpath@^1.0.0:
+ version "1.0.0"
+ resolved "https://registry.yarnpkg.com/fs.realpath/-/fs.realpath-1.0.0.tgz#1504ad2523158caa40db4a2787cb01411994ea4f"
+
+function-bind@^1.0.2, function-bind@^1.1.0, function-bind@~1.1.0:
+ version "1.1.0"
+ resolved "https://registry.yarnpkg.com/function-bind/-/function-bind-1.1.0.tgz#16176714c801798e4e8f2cf7f7529467bb4a5771"
+
+geojson-rbush@^1.0.1:
+ version "1.0.1"
+ resolved "https://registry.yarnpkg.com/geojson-rbush/-/geojson-rbush-1.0.1.tgz#450559bc18457e725191ac9acbbe0a8b5e18ddae"
+ dependencies:
+ "@turf/bbox" "^3.10.5"
+ "@turf/helpers" "^3.10.5"
+ "@turf/meta" "^3.10.5"
+ rbush "^2.0.1"
+
+glob@~7.1.1:
+ version "7.1.1"
+ resolved "https://registry.yarnpkg.com/glob/-/glob-7.1.1.tgz#805211df04faaf1c63a3600306cdf5ade50b2ec8"
+ dependencies:
+ fs.realpath "^1.0.0"
+ inflight "^1.0.4"
+ inherits "2"
+ minimatch "^3.0.2"
+ once "^1.3.0"
+ path-is-absolute "^1.0.0"
+
+has@^1.0.1, has@~1.0.1:
+ version "1.0.1"
+ resolved "https://registry.yarnpkg.com/has/-/has-1.0.1.tgz#8461733f538b0837c9361e39a9ab9e9704dc2f28"
+ dependencies:
+ function-bind "^1.0.2"
+
+inflight@^1.0.4:
+ version "1.0.6"
+ resolved "https://registry.yarnpkg.com/inflight/-/inflight-1.0.6.tgz#49bd6331d7d02d0c09bc910a1075ba8165b56df9"
+ dependencies:
+ once "^1.3.0"
+ wrappy "1"
+
+inherits@2, inherits@~2.0.3:
+ version "2.0.3"
+ resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.3.tgz#633c2c83e3da42a502f52466022480f4208261de"
+
+is-callable@^1.1.1, is-callable@^1.1.3:
+ version "1.1.3"
+ resolved "https://registry.yarnpkg.com/is-callable/-/is-callable-1.1.3.tgz#86eb75392805ddc33af71c92a0eedf74ee7604b2"
+
+is-date-object@^1.0.1:
+ version "1.0.1"
+ resolved "https://registry.yarnpkg.com/is-date-object/-/is-date-object-1.0.1.tgz#9aa20eb6aeebbff77fbd33e74ca01b33581d3a16"
+
+is-function@~1.0.0:
+ version "1.0.1"
+ resolved "https://registry.yarnpkg.com/is-function/-/is-function-1.0.1.tgz#12cfb98b65b57dd3d193a3121f5f6e2f437602b5"
+
+is-regex@^1.0.3:
+ version "1.0.4"
+ resolved "https://registry.yarnpkg.com/is-regex/-/is-regex-1.0.4.tgz#5517489b547091b0930e095654ced25ee97e9491"
+ dependencies:
+ has "^1.0.1"
+
+is-symbol@^1.0.1:
+ version "1.0.1"
+ resolved "https://registry.yarnpkg.com/is-symbol/-/is-symbol-1.0.1.tgz#3cc59f00025194b6ab2e38dbae6689256b660572"
+
+lodash@^4.17.4:
+ version "4.17.4"
+ resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.4.tgz#78203a4d1c328ae1d86dca6460e369b57f4055ae"
+
+minimatch@^3.0.2:
+ version "3.0.4"
+ resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.0.4.tgz#5166e286457f03306064be5497e8dbb0c3d32083"
+ dependencies:
+ brace-expansion "^1.1.7"
+
+minimist@~1.2.0:
+ version "1.2.0"
+ resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.0.tgz#a35008b20f41383eec1fb914f4cd5df79a264284"
+
+object-inspect@~1.2.1:
+ version "1.2.2"
+ resolved "https://registry.yarnpkg.com/object-inspect/-/object-inspect-1.2.2.tgz#c82115e4fcc888aea14d64c22e4f17f6a70d5e5a"
+
+object-keys@^1.0.8:
+ version "1.0.11"
+ resolved "https://registry.yarnpkg.com/object-keys/-/object-keys-1.0.11.tgz#c54601778ad560f1142ce0e01bcca8b56d13426d"
+
+once@^1.3.0:
+ version "1.4.0"
+ resolved "https://registry.yarnpkg.com/once/-/once-1.4.0.tgz#583b1aa775961d4b113ac17d9c50baef9dd76bd1"
+ dependencies:
+ wrappy "1"
+
+path-is-absolute@^1.0.0:
+ version "1.0.1"
+ resolved "https://registry.yarnpkg.com/path-is-absolute/-/path-is-absolute-1.0.1.tgz#174b9268735534ffbc7ace6bf53a5a9e1b5c5f5f"
+
+platform@^1.3.3:
+ version "1.3.4"
+ resolved "https://registry.yarnpkg.com/platform/-/platform-1.3.4.tgz#6f0fb17edaaa48f21442b3a975c063130f1c3ebd"
+
+quickselect@^1.0.0:
+ version "1.0.0"
+ resolved "https://registry.yarnpkg.com/quickselect/-/quickselect-1.0.0.tgz#02630818f9aae4ecab26f0103f98d061c17c58f3"
+
+rbush@^2.0.1:
+ version "2.0.1"
+ resolved "https://registry.yarnpkg.com/rbush/-/rbush-2.0.1.tgz#4cfaca28c3064bc0ee75431a1b79990e875eefa9"
+ dependencies:
+ quickselect "^1.0.0"
+
+resolve@~1.1.7:
+ version "1.1.7"
+ resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.1.7.tgz#203114d82ad2c5ed9e8e0411b3932875e889e97b"
+
+resumer@~0.0.0:
+ version "0.0.0"
+ resolved "https://registry.yarnpkg.com/resumer/-/resumer-0.0.0.tgz#f1e8f461e4064ba39e82af3cdc2a8c893d076759"
+ dependencies:
+ through "~2.3.4"
+
+string.prototype.trim@~1.1.2:
+ version "1.1.2"
+ resolved "https://registry.yarnpkg.com/string.prototype.trim/-/string.prototype.trim-1.1.2.tgz#d04de2c89e137f4d7d206f086b5ed2fae6be8cea"
+ dependencies:
+ define-properties "^1.1.2"
+ es-abstract "^1.5.0"
+ function-bind "^1.0.2"
+
+tape@^4.6.3:
+ version "4.6.3"
+ resolved "https://registry.yarnpkg.com/tape/-/tape-4.6.3.tgz#637e77581e9ab2ce17577e9bd4ce4f575806d8b6"
+ dependencies:
+ deep-equal "~1.0.1"
+ defined "~1.0.0"
+ for-each "~0.3.2"
+ function-bind "~1.1.0"
+ glob "~7.1.1"
+ has "~1.0.1"
+ inherits "~2.0.3"
+ minimist "~1.2.0"
+ object-inspect "~1.2.1"
+ resolve "~1.1.7"
+ resumer "~0.0.0"
+ string.prototype.trim "~1.1.2"
+ through "~2.3.8"
+
+through@~2.3.4, through@~2.3.8:
+ version "2.3.8"
+ resolved "https://registry.yarnpkg.com/through/-/through-2.3.8.tgz#0dd4c9ffaabc357960b1b724115d7e0e86a2e1f5"
+
+wrappy@1:
+ version "1.0.2"
+ resolved "https://registry.yarnpkg.com/wrappy/-/wrappy-1.0.2.tgz#b5243d8f3ec1aa35f1364605bc0d1036e30ab69f"
diff --git a/packages/turf-boolean-disjoint/LICENSE b/packages/turf-boolean-disjoint/LICENSE
new file mode 100644
index 0000000000..96ce51b76f
--- /dev/null
+++ b/packages/turf-boolean-disjoint/LICENSE
@@ -0,0 +1,20 @@
+The MIT License (MIT)
+
+Copyright (c) 2017 TurfJS
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of
+this software and associated documentation files (the "Software"), to deal in
+the Software without restriction, including without limitation the rights to
+use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
+the Software, and to permit persons to whom the Software is furnished to do so,
+subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
+FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
+COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
diff --git a/packages/turf-boolean-disjoint/README.md b/packages/turf-boolean-disjoint/README.md
new file mode 100644
index 0000000000..4ab758cb5d
--- /dev/null
+++ b/packages/turf-boolean-disjoint/README.md
@@ -0,0 +1,44 @@
+# @turf/boolean-disjoint
+
+# disjoint
+
+Disjoint returns (TRUE) if the intersection of the two geometries is an empty set.
+
+**Parameters**
+
+- `feature1` **([Geometry](http://geojson.org/geojson-spec.html#geometry) \| [Feature](http://geojson.org/geojson-spec.html#feature-objects)<any>)** GeoJSON Feature or Geometry
+- `feature2` **([Geometry](http://geojson.org/geojson-spec.html#geometry) \| [Feature](http://geojson.org/geojson-spec.html#feature-objects)<any>)** GeoJSON Feature or Geometry
+
+**Examples**
+
+```javascript
+turf.disjoint(line, point);
+//=true/false
+```
+
+Returns **[Boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** true/false
+
+
+
+---
+
+This module is part of the [Turfjs project](http://turfjs.org/), an open source
+module collection dedicated to geographic algorithms. It is maintained in the
+[Turfjs/turf](/~https://github.com/Turfjs/turf) repository, where you can create
+PRs and issues.
+
+### Installation
+
+Install this module individually:
+
+```sh
+$ npm install @turf/boolean-disjoint
+```
+
+Or install the Turf module that includes it as a function:
+
+```sh
+$ npm install @turf/turf
+```
diff --git a/packages/turf-boolean-disjoint/bench.js b/packages/turf-boolean-disjoint/bench.js
new file mode 100644
index 0000000000..b7b6776ddb
--- /dev/null
+++ b/packages/turf-boolean-disjoint/bench.js
@@ -0,0 +1,30 @@
+const Benchmark = require('benchmark');
+const {point, lineString, polygon} = require('@turf/helpers');
+const disjoint = require('./');
+
+// Fixtures
+const pt = point([1, 1]);
+const line = lineString([[1, 1], [1, 2], [1, 3], [1, 4]]);
+const poly = polygon([[[1, 1], [1, 10], [10, 10], [10, 1], [1, 1]]]);
+
+/**
+ * Benchmark Results
+ *
+ * point - line x 14,283,680 ops/sec ±3.28% (85 runs sampled)
+ * point - polygon:
+ * point - point x 16,109,117 ops/sec ±1.89% (82 runs sampled)
+ * polygon - polygon x 11,758,387 ops/sec ±1.47% (88 runs sampled)
+ * polygon - line x 13,295,613 ops/sec ±1.00% (87 runs sampled)
+ * line - line x 15,459,060 ops/sec ±1.03% (89 runs sampled)
+ */
+const suite = new Benchmark.Suite('turf-boolean-disjoint');
+suite
+ .add('point - line', () => disjoint(pt, line))
+ .add('point - polygon', () => disjoint(pt, polygon))
+ .add('point - point', () => disjoint(pt, pt))
+ .add('polygon - polygon', () => disjoint(poly, poly))
+ .add('polygon - line', () => disjoint(poly, line))
+ .add('line - line', () => disjoint(line, line))
+ .on('cycle', e => console.log(String(e.target)))
+ .on('complete', () => {})
+ .run();
diff --git a/packages/turf-boolean-disjoint/index.d.ts b/packages/turf-boolean-disjoint/index.d.ts
new file mode 100644
index 0000000000..5d8c7df4a3
--- /dev/null
+++ b/packages/turf-boolean-disjoint/index.d.ts
@@ -0,0 +1,10 @@
+///
+
+type Feature = GeoJSON.Feature | GeoJSON.GeometryObject;
+
+/**
+ * http://turfjs.org/docs/#boolean-disjoint
+ */
+declare function disjoint(feature1: Feature, feature2: Feature): boolean;
+declare namespace disjoint { }
+export = disjoint;
diff --git a/packages/turf-boolean-disjoint/index.js b/packages/turf-boolean-disjoint/index.js
new file mode 100644
index 0000000000..1f75c5bc79
--- /dev/null
+++ b/packages/turf-boolean-disjoint/index.js
@@ -0,0 +1,244 @@
+var inside = require('@turf/inside');
+var getCoords = require('@turf/invariant').getCoords;
+var deepEqual = require('deep-equal');
+
+/**
+ * Disjoint returns (TRUE) if the intersection of the two geometries is an empty set.
+ *
+ * @name disjoint
+ * @param {Geometry|Feature} feature1 GeoJSON Feature or Geometry
+ * @param {Geometry|Feature} feature2 GeoJSON Feature or Geometry
+ * @returns {Boolean} true/false
+ * @example
+ * turf.disjoint(line, point);
+ * //=true/false
+ */
+module.exports = function (feature1, feature2) {
+ var type1 = getGeomType(feature1);
+ var type2 = getGeomType(feature2);
+ var geom1 = getGeom(feature1);
+ var geom2 = getGeom(feature2);
+ var coords1 = getCoords(feature1);
+ var coords2 = getCoords(feature2);
+
+ switch (type1) {
+ case 'Point':
+ switch (type2) {
+ case 'Point':
+ return !deepEqual(coords1, coords2) || false;
+ case 'MultiPoint':
+ return !isPointInMultiPoint(geom2, geom1) || false;
+ case 'LineString':
+ return !isPointOnLine(geom2, geom1) || false;
+ case 'Polygon':
+ return !inside(geom1, geom2) || false;
+ }
+ break;
+ case 'MultiPoint':
+ switch (type2) {
+ case 'MultiPoint':
+ return !isMultiPointInMultiPoint(geom1, geom2) || false;
+ case 'LineString':
+ return !isMultiPointOnLine(geom1, geom2) || false;
+ }
+ }
+};
+
+function isPointInMultiPoint(MultiPoint, Point) {
+ var i;
+ var output = false;
+ for (i = 0; i < MultiPoint.coordinates.length; i++) {
+ if (deepEqual(MultiPoint.coordinates[i], Point.coordinates)) {
+ output = true;
+ break;
+ }
+ }
+ return output;
+}
+
+function isMultiPointInMultiPoint(MultiPoint1, MultiPoint2) {
+ var match = false;
+ for (var i = 0; i < MultiPoint2.coordinates.length; i++) {
+ for (var i2 = 0; i2 < MultiPoint1.coordinates.length; i2++) {
+ if (deepEqual(MultiPoint2.coordinates[i], MultiPoint1.coordinates[i2])) {
+ match = true;
+ break;
+ }
+ }
+ }
+ return match;
+}
+
+// http://stackoverflow.com/a/11908158/1979085
+function isPointOnLine(LineString, Point) {
+ var output = false;
+ for (var i = 0; i < LineString.coordinates.length - 1; i++) {
+ if (isPointOnLineSegment(LineString.coordinates[i], LineString.coordinates[i + 1], Point.coordinates)) {
+ output = true;
+ break;
+ }
+ }
+ return output;
+}
+
+function isMultiPointOnLine(LineString, MultiPoint) {
+ var output = true;
+ for (var i = 0; i < MultiPoint.coordinates.length; i++) {
+ var pointIsOnLine = false;
+ for (var i2 = 0; i2 < LineString.coordinates.length - 1; i2++) {
+ if (isPointOnLineSegment(LineString.coordinates[i2], LineString.coordinates[i2 + 1], MultiPoint.coordinates[i])) {
+ pointIsOnLine = true;
+ break;
+ }
+ }
+ if (!pointIsOnLine) {
+ output = false;
+ break;
+ }
+ }
+ return output;
+}
+
+// function isMultiPointInPoly(Polygon, MultiPoint) {
+// var output = true;
+// for (var i = 0; i < MultiPoint.coordinates.length; i++) {
+// var isInside = inside(MultiPoint.coordinates[1], Polygon);
+// if (!isInside) {
+// output = false;
+// break;
+// }
+// }
+// return output;
+// }
+
+// // TO DO - Work out how to check if line is in line (can potentially use line overlap module)
+// // Also need to make sure lines are exactly the same, eg the second must be smaller than the first
+// function isLineOnLine(LineString1, LineString2) {
+// var output = true;
+// //== CHANGE Turf v4.3 - LineOverlap supports Geometry Objects ==//
+// var overlappingLine = lineOverlap(helpers.feature(LineString1), helpers.feature(LineString2)).features[0];
+// if (!overlappingLine) return false;
+// overlappingLine = getGeom(overlappingLine);
+// if (overlappingLine.coordinates[0] === LineString1.coordinates[0] &&
+// overlappingLine.coordinates[overlappingLine.coordinates.length - 1] === LineString1.coordinates[LineString1.coordinates.length - 1]) {
+// output = false;
+// }
+// return output;
+// }
+
+// function isLineInPoly(Polygon, Linestring) {
+// var output = true;
+// for (var i = 0; i < Linestring.coordinates.length; i++) {
+// var isInside = inside(Linestring.coordinates[i], Polygon);
+// if (!isInside) {
+// output = false;
+// break;
+// }
+// }
+// return output;
+// }
+
+// /**
+// * Is Polygon (geom1) in Polygon (geom2)
+// * Only takes into account outer rings
+// * See http://stackoverflow.com/a/4833823/1979085
+// *
+// * @private
+// * @param {Geometry|Feature} feature1 Polygon1
+// * @param {Geometry|Feature} feature2 Polygon2
+// * @returns {Boolean} true/false
+// */
+// function isPolyInPoly(feature1, feature2) {
+// var coords = getCoords(feature1)[0];
+// var ring = getCoords(feature2)[0];
+// var bbox = feature2.bbox;
+
+// // check if outer coordinates is inside outer ring
+// for (var i = 0; i < coords.length; i++) {
+// // 3x performance increase if BBox is present
+// if (bbox && !inBBox(coords[i], bbox)) return false;
+// if (!inRing(coords[i], ring)) return false;
+// }
+// // Outer geometries cannot be the same
+// if (deepEqual(coords, ring)) return false;
+// return true;
+// }
+
+function isPointOnLineSegment(LineSegmentStart, LineSegmentEnd, Point) {
+ var dxc = Point[0] - LineSegmentStart[0];
+ var dyc = Point[1] - LineSegmentStart[1];
+ var dxl = LineSegmentEnd[0] - LineSegmentStart[0];
+ var dyl = LineSegmentEnd[1] - LineSegmentStart[1];
+ var cross = dxc * dyl - dyc * dxl;
+ if (cross !== 0) {
+ return false;
+ }
+ if (Math.abs(dxl) >= Math.abs(dyl)) {
+ return dxl > 0 ? LineSegmentStart[0] <= Point[0] && Point[0] <= LineSegmentEnd[0] : LineSegmentEnd[0] <= Point[0] && Point[0] <= LineSegmentStart[0];
+ } else {
+ return dyl > 0 ? LineSegmentStart[1] <= Point[1] && Point[1] <= LineSegmentEnd[1] : LineSegmentEnd[1] <= Point[1] && Point[1] <= LineSegmentStart[1];
+ }
+}
+
+/**
+ * Get Geometry from Feature or Geometry Object
+ * //!! Remove this method when implemented to @turf/invariant
+ *
+ * @private
+ * @param {Feature|Geometry} geojson GeoJSON Feature or Geometry Object
+ * @returns {Geometry} GeoJSON Geometry Object
+ * @throws {Error} if geojson is not a Feature or Geometry Object
+ */
+function getGeom(geojson) {
+ if (geojson.geometry) return geojson.geometry;
+ if (geojson.coordinates) return geojson;
+ throw new Error('geojson must be a feature or geometry object');
+}
+
+// Remove this method when implemented to @turf/invariant
+function getGeomType(geojson) {
+ if (geojson.geometry) return geojson.geometry.type;
+ if (geojson.coordinates) return geojson.type;
+ throw new Error('geojson must be a feature or geometry object');
+}
+
+// /**
+// * inRing - @turf/inside
+// *
+// * @private
+// * @param {[number, number]} pt [x,y]
+// * @param {Array<[number, number]>} ring [[x,y], [x,y],..]
+// * @param {boolean} ignoreBoundary ignoreBoundary
+// * @returns {boolean} inRing
+// */
+// function inRing(pt, ring, ignoreBoundary) {
+// var isInside = false;
+// if (ring[0][0] === ring[ring.length - 1][0] && ring[0][1] === ring[ring.length - 1][1]) ring = ring.slice(0, ring.length - 1);
+
+// for (var i = 0, j = ring.length - 1; i < ring.length; j = i++) {
+// var xi = ring[i][0], yi = ring[i][1];
+// var xj = ring[j][0], yj = ring[j][1];
+// var onBoundary = (pt[1] * (xi - xj) + yi * (xj - pt[0]) + yj * (pt[0] - xi) === 0) &&
+// ((xi - pt[0]) * (xj - pt[0]) <= 0) && ((yi - pt[1]) * (yj - pt[1]) <= 0);
+// if (onBoundary) return !ignoreBoundary;
+// var intersect = ((yi > pt[1]) !== (yj > pt[1])) &&
+// (pt[0] < (xj - xi) * (pt[1] - yi) / (yj - yi) + xi);
+// if (intersect) isInside = !isInside;
+// }
+// return isInside;
+// }
+
+// /**
+// * inBBox - @turf/inside
+// *
+// * @private
+// * @param {[number, number]} pt point [x,y]
+// * @param {[number, number, number, number]} bbox BBox [west, south, east, north]
+// * @returns {boolean} true/false if point is inside BBox
+// */
+// function inBBox(pt, bbox) {
+// return bbox[0] <= pt[0] &&
+// bbox[1] <= pt[1] &&
+// bbox[2] >= pt[0] &&
+// bbox[3] >= pt[1];
+// }
diff --git a/packages/turf-boolean-disjoint/package.json b/packages/turf-boolean-disjoint/package.json
new file mode 100644
index 0000000000..9f4babc3bd
--- /dev/null
+++ b/packages/turf-boolean-disjoint/package.json
@@ -0,0 +1,45 @@
+{
+ "name": "@turf/boolean-disjoint",
+ "version": "4.0.0",
+ "description": "turf boolean-disjoint module",
+ "main": "index.js",
+ "types": "index.d.ts",
+ "files": [
+ "index.js",
+ "index.d.ts"
+ ],
+ "scripts": {
+ "test": "node test.js",
+ "bench": "node bench.js"
+ },
+ "repository": {
+ "type": "git",
+ "url": "git://github.com/Turfjs/turf.git"
+ },
+ "keywords": [
+ "turf",
+ "disjoint",
+ "boolean",
+ "de-9im"
+ ],
+ "author": "Turf Authors",
+ "contributors": [
+ "Rowan Winsemius <@rowanwins>",
+ "Denis Carriere <@DenisCarriere>"
+ ],
+ "license": "MIT",
+ "bugs": {
+ "url": "/~https://github.com/Turfjs/turf/issues"
+ },
+ "homepage": "/~https://github.com/Turfjs/turf",
+ "devDependencies": {
+ "@turf/helpers": "^4.3.0",
+ "benchmark": "^2.1.4",
+ "tape": "^4.6.3"
+ },
+ "dependencies": {
+ "@turf/inside": "^4.3.0",
+ "@turf/invariant": "^4.3.0",
+ "deep-equal": "^1.0.1"
+ }
+}
diff --git a/packages/turf-boolean-disjoint/test.js b/packages/turf-boolean-disjoint/test.js
new file mode 100644
index 0000000000..4a31e18a85
--- /dev/null
+++ b/packages/turf-boolean-disjoint/test.js
@@ -0,0 +1,55 @@
+const test = require('tape');
+const {point, multiPoint, lineString, polygon} = require('@turf/helpers');
+const disjoint = require('./');
+
+test('turf-boolean-disjoint', t => {
+ const p1 = point([0, 0]);
+ const p2 = point([1, 1]);
+
+ t.equal(disjoint(p1, p1), false, 'The points are the same and so disjoint is false');
+ t.equal(disjoint(p1, p2), true, 'The points are different and so disjoint is true');
+
+ const mp1 = multiPoint([[1, 1], [12, 12]]);
+ const mp2 = multiPoint([[0, 0], [12, 12]]);
+ const mp3 = multiPoint([[-1, -1], [-12, -12]]);
+
+ t.equal(disjoint(p1, mp1), true, 'The point does not hit the multipoint so disjoint is true');
+ t.equal(disjoint(p1, mp2), false, 'The point hits the multipoint so disjoint is false');
+
+ t.equal(disjoint(mp1, mp1), false, 'The multipoints are the same so disjoint is false');
+ t.equal(disjoint(mp1, mp3), true, 'The multipoints are different so disjoint is true');
+
+ t.equal(disjoint(mp1, mp2), false, 'One of multipoints are the same so disjoint is false');
+
+ const line1 = lineString([[1, 1], [1, 2], [1, 3], [1, 4]]);
+
+ t.equal(disjoint(p1, line1), true, 'A point is far from the line so disjoint is true');
+ t.equal(disjoint(p2, line1), false, 'A point is on the line so disjoint is false');
+
+ const poly1 = polygon([[[-1, 2], [3, 2], [3, 3], [-1, 3], [-1, 2]]]);
+ const p3 = point([2, 2.5]);
+
+ t.equal(disjoint(p1, poly1), true, 'A point is outside a polygon so disjoint is true');
+ t.equal(disjoint(p3, poly1), false, 'A point is inside a polygon so disjoint is false');
+
+ t.skip(disjoint(mp1, line1), false, 'A multipoint is partially on a line so disjoint is false');
+ t.equal(disjoint(mp2, line1), true, 'A multipoint does not touch a line so disjoint is true');
+
+
+ // const mp2 = multiPoint([[2, 2], [1, -1.5]]);
+
+ // const line2 = lineString([[-2, 2], [4, 2]]);
+ // const line3 = lineString([[-2, 2], [-4, 2]]);
+ // const line4 = lineString([[-2, 2], [1, 1]]);
+
+ // t.equal(disjoint(line1, line2), true, 'True if lines cross');
+ // t.equal(disjoint(line1, line3), false, 'False if lines cross');
+ // t.equal(disjoint(line1, line4), false, 'False if lines only touch');
+
+ // const line5 = lineString([[0.5, 2.5], [1, 1]]);
+
+ // t.equal(cross(line3, poly1), false, 'False where a line does not cross a polygon');
+ // t.equal(cross(line5, poly1), true, 'True where a line is both in and outside a polygon');
+
+ t.end();
+});
diff --git a/packages/turf-boolean-disjoint/yarn.lock b/packages/turf-boolean-disjoint/yarn.lock
new file mode 100644
index 0000000000..18f6925131
--- /dev/null
+++ b/packages/turf-boolean-disjoint/yarn.lock
@@ -0,0 +1,219 @@
+# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
+# yarn lockfile v1
+
+
+"@turf/helpers@^4.3.0":
+ version "4.3.0"
+ resolved "https://registry.yarnpkg.com/@turf/helpers/-/helpers-4.3.0.tgz#7b2f733aa0eb3ea1f07d467ac02ede00cc6cde0d"
+
+"@turf/inside@^4.3.0":
+ version "4.3.0"
+ resolved "https://registry.yarnpkg.com/@turf/inside/-/inside-4.3.0.tgz#ba06be5966a5ab31c1cabb9819241e0802422c45"
+ dependencies:
+ "@turf/invariant" "^4.3.0"
+
+"@turf/invariant@^4.3.0":
+ version "4.3.0"
+ resolved "https://registry.yarnpkg.com/@turf/invariant/-/invariant-4.3.0.tgz#5bd1ce6ae51b1229dc0dc7d09d973fabae49af89"
+
+balanced-match@^0.4.1:
+ version "0.4.2"
+ resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-0.4.2.tgz#cb3f3e3c732dc0f01ee70b403f302e61d7709838"
+
+benchmark@^2.1.4:
+ version "2.1.4"
+ resolved "https://registry.yarnpkg.com/benchmark/-/benchmark-2.1.4.tgz#09f3de31c916425d498cc2ee565a0ebf3c2a5629"
+ dependencies:
+ lodash "^4.17.4"
+ platform "^1.3.3"
+
+brace-expansion@^1.1.7:
+ version "1.1.7"
+ resolved "https://registry.yarnpkg.com/brace-expansion/-/brace-expansion-1.1.7.tgz#3effc3c50e000531fb720eaff80f0ae8ef23cf59"
+ dependencies:
+ balanced-match "^0.4.1"
+ concat-map "0.0.1"
+
+concat-map@0.0.1:
+ version "0.0.1"
+ resolved "https://registry.yarnpkg.com/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b"
+
+deep-equal@^1.0.1, deep-equal@~1.0.1:
+ version "1.0.1"
+ resolved "https://registry.yarnpkg.com/deep-equal/-/deep-equal-1.0.1.tgz#f5d260292b660e084eff4cdbc9f08ad3247448b5"
+
+define-properties@^1.1.2:
+ version "1.1.2"
+ resolved "https://registry.yarnpkg.com/define-properties/-/define-properties-1.1.2.tgz#83a73f2fea569898fb737193c8f873caf6d45c94"
+ dependencies:
+ foreach "^2.0.5"
+ object-keys "^1.0.8"
+
+defined@~1.0.0:
+ version "1.0.0"
+ resolved "https://registry.yarnpkg.com/defined/-/defined-1.0.0.tgz#c98d9bcef75674188e110969151199e39b1fa693"
+
+es-abstract@^1.5.0:
+ version "1.7.0"
+ resolved "https://registry.yarnpkg.com/es-abstract/-/es-abstract-1.7.0.tgz#dfade774e01bfcd97f96180298c449c8623fb94c"
+ dependencies:
+ es-to-primitive "^1.1.1"
+ function-bind "^1.1.0"
+ is-callable "^1.1.3"
+ is-regex "^1.0.3"
+
+es-to-primitive@^1.1.1:
+ version "1.1.1"
+ resolved "https://registry.yarnpkg.com/es-to-primitive/-/es-to-primitive-1.1.1.tgz#45355248a88979034b6792e19bb81f2b7975dd0d"
+ dependencies:
+ is-callable "^1.1.1"
+ is-date-object "^1.0.1"
+ is-symbol "^1.0.1"
+
+for-each@~0.3.2:
+ version "0.3.2"
+ resolved "https://registry.yarnpkg.com/for-each/-/for-each-0.3.2.tgz#2c40450b9348e97f281322593ba96704b9abd4d4"
+ dependencies:
+ is-function "~1.0.0"
+
+foreach@^2.0.5:
+ version "2.0.5"
+ resolved "https://registry.yarnpkg.com/foreach/-/foreach-2.0.5.tgz#0bee005018aeb260d0a3af3ae658dd0136ec1b99"
+
+fs.realpath@^1.0.0:
+ version "1.0.0"
+ resolved "https://registry.yarnpkg.com/fs.realpath/-/fs.realpath-1.0.0.tgz#1504ad2523158caa40db4a2787cb01411994ea4f"
+
+function-bind@^1.0.2, function-bind@^1.1.0, function-bind@~1.1.0:
+ version "1.1.0"
+ resolved "https://registry.yarnpkg.com/function-bind/-/function-bind-1.1.0.tgz#16176714c801798e4e8f2cf7f7529467bb4a5771"
+
+glob@~7.1.1:
+ version "7.1.1"
+ resolved "https://registry.yarnpkg.com/glob/-/glob-7.1.1.tgz#805211df04faaf1c63a3600306cdf5ade50b2ec8"
+ dependencies:
+ fs.realpath "^1.0.0"
+ inflight "^1.0.4"
+ inherits "2"
+ minimatch "^3.0.2"
+ once "^1.3.0"
+ path-is-absolute "^1.0.0"
+
+has@^1.0.1, has@~1.0.1:
+ version "1.0.1"
+ resolved "https://registry.yarnpkg.com/has/-/has-1.0.1.tgz#8461733f538b0837c9361e39a9ab9e9704dc2f28"
+ dependencies:
+ function-bind "^1.0.2"
+
+inflight@^1.0.4:
+ version "1.0.6"
+ resolved "https://registry.yarnpkg.com/inflight/-/inflight-1.0.6.tgz#49bd6331d7d02d0c09bc910a1075ba8165b56df9"
+ dependencies:
+ once "^1.3.0"
+ wrappy "1"
+
+inherits@2, inherits@~2.0.3:
+ version "2.0.3"
+ resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.3.tgz#633c2c83e3da42a502f52466022480f4208261de"
+
+is-callable@^1.1.1, is-callable@^1.1.3:
+ version "1.1.3"
+ resolved "https://registry.yarnpkg.com/is-callable/-/is-callable-1.1.3.tgz#86eb75392805ddc33af71c92a0eedf74ee7604b2"
+
+is-date-object@^1.0.1:
+ version "1.0.1"
+ resolved "https://registry.yarnpkg.com/is-date-object/-/is-date-object-1.0.1.tgz#9aa20eb6aeebbff77fbd33e74ca01b33581d3a16"
+
+is-function@~1.0.0:
+ version "1.0.1"
+ resolved "https://registry.yarnpkg.com/is-function/-/is-function-1.0.1.tgz#12cfb98b65b57dd3d193a3121f5f6e2f437602b5"
+
+is-regex@^1.0.3:
+ version "1.0.4"
+ resolved "https://registry.yarnpkg.com/is-regex/-/is-regex-1.0.4.tgz#5517489b547091b0930e095654ced25ee97e9491"
+ dependencies:
+ has "^1.0.1"
+
+is-symbol@^1.0.1:
+ version "1.0.1"
+ resolved "https://registry.yarnpkg.com/is-symbol/-/is-symbol-1.0.1.tgz#3cc59f00025194b6ab2e38dbae6689256b660572"
+
+lodash@^4.17.4:
+ version "4.17.4"
+ resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.4.tgz#78203a4d1c328ae1d86dca6460e369b57f4055ae"
+
+minimatch@^3.0.2:
+ version "3.0.4"
+ resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.0.4.tgz#5166e286457f03306064be5497e8dbb0c3d32083"
+ dependencies:
+ brace-expansion "^1.1.7"
+
+minimist@~1.2.0:
+ version "1.2.0"
+ resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.0.tgz#a35008b20f41383eec1fb914f4cd5df79a264284"
+
+object-inspect@~1.2.1:
+ version "1.2.2"
+ resolved "https://registry.yarnpkg.com/object-inspect/-/object-inspect-1.2.2.tgz#c82115e4fcc888aea14d64c22e4f17f6a70d5e5a"
+
+object-keys@^1.0.8:
+ version "1.0.11"
+ resolved "https://registry.yarnpkg.com/object-keys/-/object-keys-1.0.11.tgz#c54601778ad560f1142ce0e01bcca8b56d13426d"
+
+once@^1.3.0:
+ version "1.4.0"
+ resolved "https://registry.yarnpkg.com/once/-/once-1.4.0.tgz#583b1aa775961d4b113ac17d9c50baef9dd76bd1"
+ dependencies:
+ wrappy "1"
+
+path-is-absolute@^1.0.0:
+ version "1.0.1"
+ resolved "https://registry.yarnpkg.com/path-is-absolute/-/path-is-absolute-1.0.1.tgz#174b9268735534ffbc7ace6bf53a5a9e1b5c5f5f"
+
+platform@^1.3.3:
+ version "1.3.4"
+ resolved "https://registry.yarnpkg.com/platform/-/platform-1.3.4.tgz#6f0fb17edaaa48f21442b3a975c063130f1c3ebd"
+
+resolve@~1.1.7:
+ version "1.1.7"
+ resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.1.7.tgz#203114d82ad2c5ed9e8e0411b3932875e889e97b"
+
+resumer@~0.0.0:
+ version "0.0.0"
+ resolved "https://registry.yarnpkg.com/resumer/-/resumer-0.0.0.tgz#f1e8f461e4064ba39e82af3cdc2a8c893d076759"
+ dependencies:
+ through "~2.3.4"
+
+string.prototype.trim@~1.1.2:
+ version "1.1.2"
+ resolved "https://registry.yarnpkg.com/string.prototype.trim/-/string.prototype.trim-1.1.2.tgz#d04de2c89e137f4d7d206f086b5ed2fae6be8cea"
+ dependencies:
+ define-properties "^1.1.2"
+ es-abstract "^1.5.0"
+ function-bind "^1.0.2"
+
+tape@^4.6.3:
+ version "4.6.3"
+ resolved "https://registry.yarnpkg.com/tape/-/tape-4.6.3.tgz#637e77581e9ab2ce17577e9bd4ce4f575806d8b6"
+ dependencies:
+ deep-equal "~1.0.1"
+ defined "~1.0.0"
+ for-each "~0.3.2"
+ function-bind "~1.1.0"
+ glob "~7.1.1"
+ has "~1.0.1"
+ inherits "~2.0.3"
+ minimist "~1.2.0"
+ object-inspect "~1.2.1"
+ resolve "~1.1.7"
+ resumer "~0.0.0"
+ string.prototype.trim "~1.1.2"
+ through "~2.3.8"
+
+through@~2.3.4, through@~2.3.8:
+ version "2.3.8"
+ resolved "https://registry.yarnpkg.com/through/-/through-2.3.8.tgz#0dd4c9ffaabc357960b1b724115d7e0e86a2e1f5"
+
+wrappy@1:
+ version "1.0.2"
+ resolved "https://registry.yarnpkg.com/wrappy/-/wrappy-1.0.2.tgz#b5243d8f3ec1aa35f1364605bc0d1036e30ab69f"
diff --git a/packages/turf-boolean-equal/LICENSE b/packages/turf-boolean-equal/LICENSE
new file mode 100644
index 0000000000..96ce51b76f
--- /dev/null
+++ b/packages/turf-boolean-equal/LICENSE
@@ -0,0 +1,20 @@
+The MIT License (MIT)
+
+Copyright (c) 2017 TurfJS
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of
+this software and associated documentation files (the "Software"), to deal in
+the Software without restriction, including without limitation the rights to
+use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
+the Software, and to permit persons to whom the Software is furnished to do so,
+subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
+FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
+COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
diff --git a/packages/turf-boolean-equal/README.md b/packages/turf-boolean-equal/README.md
new file mode 100644
index 0000000000..45c065f74e
--- /dev/null
+++ b/packages/turf-boolean-equal/README.md
@@ -0,0 +1,62 @@
+# @turf/boolean-equal
+
+# equal
+
+Equal returns True if two geometries of the same type have identical X,Y coordinate values.
+
+**Parameters**
+
+- `feature1` **([Geometry](http://geojson.org/geojson-spec.html#geometry) \| [Feature](http://geojson.org/geojson-spec.html#feature-objects)<any>)** GeoJSON Feature or Geometry
+- `feature2` **([Geometry](http://geojson.org/geojson-spec.html#geometry) \| [Feature](http://geojson.org/geojson-spec.html#feature-objects)<any>)** GeoJSON Feature or Geometry
+- `direction` **\[[Boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)]** direction of LineString or Polygon (orientation) is ignored if false (optional, default `false`)
+- `precision` **\[[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)]** coordinate decimal precision
+
+**Examples**
+
+```javascript
+const point1 = {
+ "type": "Feature",
+ "properties": {},
+ "geometry": {
+ "type": "Point",
+ "coordinates": [1, 1]
+ }
+}
+const point2 = {
+ "type": "Feature",
+ "properties": {},
+ "geometry": {
+ "type": "Point",
+ "coordinates": [1, 1]
+ }
+}
+var equal = turf.equal(point1, point2);
+//=true
+```
+
+Returns **[Boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** true/false
+
+
+
+---
+
+This module is part of the [Turfjs project](http://turfjs.org/), an open source
+module collection dedicated to geographic algorithms. It is maintained in the
+[Turfjs/turf](/~https://github.com/Turfjs/turf) repository, where you can create
+PRs and issues.
+
+### Installation
+
+Install this module individually:
+
+```sh
+$ npm install @turf/boolean-equal
+```
+
+Or install the Turf module that includes it as a function:
+
+```sh
+$ npm install @turf/turf
+```
diff --git a/packages/turf-boolean-equal/bench.js b/packages/turf-boolean-equal/bench.js
new file mode 100644
index 0000000000..5aed1c62ec
--- /dev/null
+++ b/packages/turf-boolean-equal/bench.js
@@ -0,0 +1,30 @@
+const Benchmark = require('benchmark');
+const {point, lineString, polygon} = require('@turf/helpers');
+const equal = require('./');
+
+// Fixtures
+const pt = point([1, 1]);
+const line = lineString([[1, 1], [1, 2], [1, 3], [1, 4]]);
+const poly = polygon([[[1, 1], [1, 10], [10, 10], [10, 1], [1, 1]]]);
+
+/**
+ * Benchmark Results
+ *
+ * point - line x 49,662,649 ops/sec ±1.19% (87 runs sampled)
+ * point - polygon x 42,164,979 ops/sec ±0.84% (90 runs sampled)
+ * point - point x 19,729,671 ops/sec ±0.91% (93 runs sampled)
+ * polygon - polygon x 9,670,025 ops/sec ±1.10% (87 runs sampled)
+ * line - line x 12,731,539 ops/sec ±1.12% (85 runs sampled)
+ */
+const suite = new Benchmark.Suite('turf-boolean-equal');
+suite
+ .add('precision', () => equal(line, line, false, 6))
+ .add('direction', () => equal(line, line, true))
+ .add('point - line', () => equal(pt, line))
+ .add('point - polygon', () => equal(pt, polygon))
+ .add('point - point', () => equal(pt, pt))
+ .add('polygon - polygon', () => equal(poly, poly))
+ .add('line - line', () => equal(line, line))
+ .on('cycle', e => console.log(String(e.target)))
+ .on('complete', () => {})
+ .run();
diff --git a/packages/turf-boolean-equal/index.d.ts b/packages/turf-boolean-equal/index.d.ts
new file mode 100644
index 0000000000..802036c7fa
--- /dev/null
+++ b/packages/turf-boolean-equal/index.d.ts
@@ -0,0 +1,10 @@
+///
+
+type Feature = GeoJSON.Feature | GeoJSON.GeometryObject;
+
+/**
+ * http://turfjs.org/docs/#boolean-equal
+ */
+declare function equal(feature1: Feature, feature2: Feature, direction?: boolean, precision?: number): boolean;
+declare namespace equal { }
+export = equal;
diff --git a/packages/turf-boolean-equal/index.js b/packages/turf-boolean-equal/index.js
new file mode 100644
index 0000000000..516627c467
--- /dev/null
+++ b/packages/turf-boolean-equal/index.js
@@ -0,0 +1,62 @@
+var rewind = require('@turf/rewind');
+var deepEqual = require('deep-equal');
+var truncate = require('@turf/truncate');
+var getCoords = require('@turf/invariant').getCoords;
+
+/**
+ * Equal returns True if two geometries of the same type have identical X,Y coordinate values.
+ *
+ * @name equal
+ * @param {Geometry|Feature} feature1 GeoJSON Feature or Geometry
+ * @param {Geometry|Feature} feature2 GeoJSON Feature or Geometry
+ * @param {Boolean} [direction=false] direction of LineString or Polygon (orientation) is ignored if false
+ * @param {number} [precision] coordinate decimal precision
+ * @returns {Boolean} true/false
+ * @example
+ * const point1 = {
+ * "type": "Feature",
+ * "properties": {},
+ * "geometry": {
+ * "type": "Point",
+ * "coordinates": [1, 1]
+ * }
+ * }
+ * const point2 = {
+ * "type": "Feature",
+ * "properties": {},
+ * "geometry": {
+ * "type": "Point",
+ * "coordinates": [1, 1]
+ * }
+ * }
+ * var equal = turf.equal(point1, point2);
+ * //=true
+ */
+module.exports = function (feature1, feature2, direction, precision) {
+ // Check if geometry is the same type
+ var type1 = geomType(feature1);
+ var type2 = geomType(feature2);
+ if (type1 !== type2) return false;
+
+ // Truncate coordinate decimals based on precision
+ if (precision !== undefined) {
+ feature1 = truncate(feature1, precision);
+ feature2 = truncate(feature2, precision);
+ }
+
+ // direction of LineString or Polygon (orientation) is ignored if false
+ if (direction) {
+ feature1 = rewind(feature1);
+ feature2 = rewind(feature2);
+ }
+
+ // Check if coordinates are identical
+ var coords1 = getCoords(feature1);
+ var coords2 = getCoords(feature2);
+ return deepEqual(coords1, coords2);
+};
+
+// This method should be replaced when implemented in @turf/invariant
+function geomType(geojson) {
+ return (geojson.geometry) ? geojson.geometry.type : geojson.type;
+}
diff --git a/packages/turf-boolean-equal/package.json b/packages/turf-boolean-equal/package.json
new file mode 100644
index 0000000000..b40c65c9d4
--- /dev/null
+++ b/packages/turf-boolean-equal/package.json
@@ -0,0 +1,46 @@
+{
+ "name": "@turf/boolean-equal",
+ "version": "4.0.0",
+ "description": "turf boolean-equal module",
+ "main": "index.js",
+ "types": "index.d.ts",
+ "files": [
+ "index.js",
+ "index.d.ts"
+ ],
+ "scripts": {
+ "test": "node test.js",
+ "bench": "node bench.js"
+ },
+ "repository": {
+ "type": "git",
+ "url": "git://github.com/Turfjs/turf.git"
+ },
+ "keywords": [
+ "turf",
+ "equal",
+ "boolean",
+ "de-9im"
+ ],
+ "author": "Turf Authors",
+ "contributors": [
+ "Rowan Winsemius <@rowanwins>",
+ "Denis Carriere <@DenisCarriere>"
+ ],
+ "license": "MIT",
+ "bugs": {
+ "url": "/~https://github.com/Turfjs/turf/issues"
+ },
+ "homepage": "/~https://github.com/Turfjs/turf",
+ "devDependencies": {
+ "@turf/helpers": "^4.2.0",
+ "benchmark": "^2.1.4",
+ "tape": "^4.6.3"
+ },
+ "dependencies": {
+ "@turf/invariant": "^4.2.0",
+ "@turf/rewind": "^4.4.0",
+ "@turf/truncate": "^4.4.0",
+ "deep-equal": "^1.0.1"
+ }
+}
diff --git a/packages/turf-boolean-equal/test.js b/packages/turf-boolean-equal/test.js
new file mode 100644
index 0000000000..1973e5b01b
--- /dev/null
+++ b/packages/turf-boolean-equal/test.js
@@ -0,0 +1,82 @@
+const test = require('tape');
+const {point, lineString, polygon, multiPoint, multiLineString, multiPolygon} = require('@turf/helpers');
+const equal = require('./');
+
+test('turf-boolean-equal', t => {
+ const pt1 = point([-75.343, 39.984]);
+ const pt2 = point([-75.343, 39.984]);
+ const pt3 = point([-5.343, 3.984]);
+
+ t.true(equal(pt1, pt2), 'points are equal');
+ t.false(equal(pt1, pt3), 'points are not equal');
+
+ const mp1 = multiPoint([[0, 0], [0, 10], [10, 10], [10, 0], [0, 0]]);
+ const mp2 = multiPoint([[0, 0], [0, 10], [10, 10], [10, 0], [0, 0]]);
+ const mp3 = multiPoint([[10, 0], [10, 10], [10, 10], [10, 0], [0, 0]]);
+
+ t.true(equal(mp1, mp2), 'MultiPoints are equal');
+ t.false(equal(mp1, mp3), 'MultiPoints are not equal');
+
+ const line1 = lineString([[1, 1], [1, 2], [1, 3], [1, 4]]);
+ const line2 = lineString([[1, 1], [1, 2], [1, 3], [1, 4]]);
+ const line3 = lineString([[2, 1], [2, 2], [2, 3], [2, 4]]);
+
+ t.true(equal(line1, line2), 'Lines are equal');
+ t.false(equal(line1, line3), 'Lines are not equal');
+
+
+ const multiline1 = multiLineString([[[1, 1], [1, 2], [1, 3], [1, 4]], [[2, 1], [2, 2], [2, 3], [2, 4]]]);
+ const multiline2 = multiLineString([[[1, 1], [1, 2], [1, 3], [1, 4]], [[2, 1], [2, 2], [2, 3], [2, 4]]]);
+ const multiline3 = multiLineString([[[2, 1], [2, 2], [2, 3], [2, 4]], [[3, 1], [3, 2], [3, 3], [3, 4]]]);
+
+ t.true(equal(multiline1, multiline2), 'MultiLines are equal');
+ t.false(equal(multiline1, multiline3), 'MultiLines are not equal');
+
+ const poly1 = polygon([[[1, 1], [1, 2], [1, 3], [1, 4], [1, 1]]]);
+ const poly2 = polygon([[[1, 1], [1, 2], [1, 3], [1, 4], [1, 1]]]);
+ const poly3 = polygon([[[2, 1], [2, 2], [2, 3], [2, 4], [2, 1]]]);
+
+ t.true(equal(poly1, poly2), 'Polys are equal');
+ t.false(equal(poly1, poly3), 'Polys are not equal');
+
+ const multipoly1 = multiPolygon([[[1, 1], [1, 2], [1, 3], [1, 4], [1, 1]], [[3, 1], [3, 2], [3, 3], [3, 4], [3, 1]]]);
+ const multipoly2 = multiPolygon([[[1, 1], [1, 2], [1, 3], [1, 4], [1, 1]], [[3, 1], [3, 2], [3, 3], [3, 4], [3, 1]]]);
+ const multipoly3 = multiPolygon([[[2, 1], [2, 2], [2, 3], [2, 4], [2, 1]], [[3, 1], [3, 2], [3, 3], [3, 4], [3, 1]]]);
+
+ t.true(equal(multipoly1, multipoly2), 'MultiPolys are equal');
+ t.false(equal(multipoly1, multipoly3), 'MultiPolys are not equal');
+
+ t.end();
+});
+
+test('turf-boolean-equal -- reduce coordinate precision', t => {
+ const pt1 = point([30.2, 10]);
+ const pt2 = point([30.22233, 10]);
+
+ t.true(equal(pt1, pt2, false, 1));
+ t.false(equal(pt1, pt2, false, 3));
+ t.end();
+});
+
+
+test('turf-boolean-equal -- apply direction (orientation) rule', t => {
+ const line1 = lineString([[30, 10], [10, 30], [40, 40]]);
+ const line2 = lineString([[40, 40], [10, 30], [30, 10]]);
+
+ t.true(equal(line1, line2, true));
+ t.false(equal(line1, line2, false));
+ t.end();
+});
+
+
+test('scale -- prevent input mutation', t => {
+ const line1 = lineString([[30, 10], [10, 30], [40, 40]]);
+ const line2 = lineString([[40, 40], [10, 30], [30, 10]]);
+ const line1Before = JSON.parse(JSON.stringify(line1));
+ const line2Before = JSON.parse(JSON.stringify(line2));
+
+ equal(line1, line2, true, 3);
+ t.deepEqual(line1, line1Before, 'input should NOT be mutated');
+ t.deepEqual(line2, line2Before, 'input should NOT be mutated');
+ t.end();
+});
diff --git a/packages/turf-boolean-equal/yarn.lock b/packages/turf-boolean-equal/yarn.lock
new file mode 100644
index 0000000000..1d669f5a29
--- /dev/null
+++ b/packages/turf-boolean-equal/yarn.lock
@@ -0,0 +1,244 @@
+# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
+# yarn lockfile v1
+
+
+"@turf/helpers@^4.2.0":
+ version "4.3.0"
+ resolved "https://registry.yarnpkg.com/@turf/helpers/-/helpers-4.3.0.tgz#7b2f733aa0eb3ea1f07d467ac02ede00cc6cde0d"
+
+"@turf/helpers@^4.4.0":
+ version "4.4.0"
+ resolved "https://registry.yarnpkg.com/@turf/helpers/-/helpers-4.4.0.tgz#c83112f7fbe6ed183c7c0c2f776481b94d1cbd01"
+
+"@turf/invariant@^4.2.0":
+ version "4.3.0"
+ resolved "https://registry.yarnpkg.com/@turf/invariant/-/invariant-4.3.0.tgz#5bd1ce6ae51b1229dc0dc7d09d973fabae49af89"
+
+"@turf/invariant@^4.4.0":
+ version "4.4.0"
+ resolved "https://registry.yarnpkg.com/@turf/invariant/-/invariant-4.4.0.tgz#aac0afb840ae40908f9c80393f416222dcf79c32"
+
+"@turf/meta@^4.4.0":
+ version "4.4.0"
+ resolved "https://registry.yarnpkg.com/@turf/meta/-/meta-4.4.0.tgz#4fa25d4cc0525bd4cdbaf4ff68a6f8ae81f1975f"
+
+"@turf/rewind@^4.4.0":
+ version "4.4.0"
+ resolved "https://registry.yarnpkg.com/@turf/rewind/-/rewind-4.4.0.tgz#4942be56fe381cfbb0522ba26eb985153d386c72"
+ dependencies:
+ "@turf/helpers" "^4.4.0"
+ "@turf/invariant" "^4.4.0"
+ "@turf/meta" "^4.4.0"
+ turf-is-clockwise "^1.0.0"
+
+"@turf/truncate@^4.4.0":
+ version "4.4.0"
+ resolved "https://registry.yarnpkg.com/@turf/truncate/-/truncate-4.4.0.tgz#194deef33b91d6b27cc9b33a141cacb6e7ce23a0"
+ dependencies:
+ "@turf/meta" "^4.4.0"
+
+balanced-match@^0.4.1:
+ version "0.4.2"
+ resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-0.4.2.tgz#cb3f3e3c732dc0f01ee70b403f302e61d7709838"
+
+benchmark@^2.1.4:
+ version "2.1.4"
+ resolved "https://registry.yarnpkg.com/benchmark/-/benchmark-2.1.4.tgz#09f3de31c916425d498cc2ee565a0ebf3c2a5629"
+ dependencies:
+ lodash "^4.17.4"
+ platform "^1.3.3"
+
+brace-expansion@^1.1.7:
+ version "1.1.7"
+ resolved "https://registry.yarnpkg.com/brace-expansion/-/brace-expansion-1.1.7.tgz#3effc3c50e000531fb720eaff80f0ae8ef23cf59"
+ dependencies:
+ balanced-match "^0.4.1"
+ concat-map "0.0.1"
+
+concat-map@0.0.1:
+ version "0.0.1"
+ resolved "https://registry.yarnpkg.com/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b"
+
+deep-equal@^1.0.1, deep-equal@~1.0.1:
+ version "1.0.1"
+ resolved "https://registry.yarnpkg.com/deep-equal/-/deep-equal-1.0.1.tgz#f5d260292b660e084eff4cdbc9f08ad3247448b5"
+
+define-properties@^1.1.2:
+ version "1.1.2"
+ resolved "https://registry.yarnpkg.com/define-properties/-/define-properties-1.1.2.tgz#83a73f2fea569898fb737193c8f873caf6d45c94"
+ dependencies:
+ foreach "^2.0.5"
+ object-keys "^1.0.8"
+
+defined@~1.0.0:
+ version "1.0.0"
+ resolved "https://registry.yarnpkg.com/defined/-/defined-1.0.0.tgz#c98d9bcef75674188e110969151199e39b1fa693"
+
+es-abstract@^1.5.0:
+ version "1.7.0"
+ resolved "https://registry.yarnpkg.com/es-abstract/-/es-abstract-1.7.0.tgz#dfade774e01bfcd97f96180298c449c8623fb94c"
+ dependencies:
+ es-to-primitive "^1.1.1"
+ function-bind "^1.1.0"
+ is-callable "^1.1.3"
+ is-regex "^1.0.3"
+
+es-to-primitive@^1.1.1:
+ version "1.1.1"
+ resolved "https://registry.yarnpkg.com/es-to-primitive/-/es-to-primitive-1.1.1.tgz#45355248a88979034b6792e19bb81f2b7975dd0d"
+ dependencies:
+ is-callable "^1.1.1"
+ is-date-object "^1.0.1"
+ is-symbol "^1.0.1"
+
+for-each@~0.3.2:
+ version "0.3.2"
+ resolved "https://registry.yarnpkg.com/for-each/-/for-each-0.3.2.tgz#2c40450b9348e97f281322593ba96704b9abd4d4"
+ dependencies:
+ is-function "~1.0.0"
+
+foreach@^2.0.5:
+ version "2.0.5"
+ resolved "https://registry.yarnpkg.com/foreach/-/foreach-2.0.5.tgz#0bee005018aeb260d0a3af3ae658dd0136ec1b99"
+
+fs.realpath@^1.0.0:
+ version "1.0.0"
+ resolved "https://registry.yarnpkg.com/fs.realpath/-/fs.realpath-1.0.0.tgz#1504ad2523158caa40db4a2787cb01411994ea4f"
+
+function-bind@^1.0.2, function-bind@^1.1.0, function-bind@~1.1.0:
+ version "1.1.0"
+ resolved "https://registry.yarnpkg.com/function-bind/-/function-bind-1.1.0.tgz#16176714c801798e4e8f2cf7f7529467bb4a5771"
+
+glob@~7.1.1:
+ version "7.1.2"
+ resolved "https://registry.yarnpkg.com/glob/-/glob-7.1.2.tgz#c19c9df9a028702d678612384a6552404c636d15"
+ dependencies:
+ fs.realpath "^1.0.0"
+ inflight "^1.0.4"
+ inherits "2"
+ minimatch "^3.0.4"
+ once "^1.3.0"
+ path-is-absolute "^1.0.0"
+
+has@^1.0.1, has@~1.0.1:
+ version "1.0.1"
+ resolved "https://registry.yarnpkg.com/has/-/has-1.0.1.tgz#8461733f538b0837c9361e39a9ab9e9704dc2f28"
+ dependencies:
+ function-bind "^1.0.2"
+
+inflight@^1.0.4:
+ version "1.0.6"
+ resolved "https://registry.yarnpkg.com/inflight/-/inflight-1.0.6.tgz#49bd6331d7d02d0c09bc910a1075ba8165b56df9"
+ dependencies:
+ once "^1.3.0"
+ wrappy "1"
+
+inherits@2, inherits@~2.0.3:
+ version "2.0.3"
+ resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.3.tgz#633c2c83e3da42a502f52466022480f4208261de"
+
+is-callable@^1.1.1, is-callable@^1.1.3:
+ version "1.1.3"
+ resolved "https://registry.yarnpkg.com/is-callable/-/is-callable-1.1.3.tgz#86eb75392805ddc33af71c92a0eedf74ee7604b2"
+
+is-date-object@^1.0.1:
+ version "1.0.1"
+ resolved "https://registry.yarnpkg.com/is-date-object/-/is-date-object-1.0.1.tgz#9aa20eb6aeebbff77fbd33e74ca01b33581d3a16"
+
+is-function@~1.0.0:
+ version "1.0.1"
+ resolved "https://registry.yarnpkg.com/is-function/-/is-function-1.0.1.tgz#12cfb98b65b57dd3d193a3121f5f6e2f437602b5"
+
+is-regex@^1.0.3:
+ version "1.0.4"
+ resolved "https://registry.yarnpkg.com/is-regex/-/is-regex-1.0.4.tgz#5517489b547091b0930e095654ced25ee97e9491"
+ dependencies:
+ has "^1.0.1"
+
+is-symbol@^1.0.1:
+ version "1.0.1"
+ resolved "https://registry.yarnpkg.com/is-symbol/-/is-symbol-1.0.1.tgz#3cc59f00025194b6ab2e38dbae6689256b660572"
+
+lodash@^4.17.4:
+ version "4.17.4"
+ resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.4.tgz#78203a4d1c328ae1d86dca6460e369b57f4055ae"
+
+minimatch@^3.0.4:
+ version "3.0.4"
+ resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.0.4.tgz#5166e286457f03306064be5497e8dbb0c3d32083"
+ dependencies:
+ brace-expansion "^1.1.7"
+
+minimist@~1.2.0:
+ version "1.2.0"
+ resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.0.tgz#a35008b20f41383eec1fb914f4cd5df79a264284"
+
+object-inspect@~1.2.1:
+ version "1.2.2"
+ resolved "https://registry.yarnpkg.com/object-inspect/-/object-inspect-1.2.2.tgz#c82115e4fcc888aea14d64c22e4f17f6a70d5e5a"
+
+object-keys@^1.0.8:
+ version "1.0.11"
+ resolved "https://registry.yarnpkg.com/object-keys/-/object-keys-1.0.11.tgz#c54601778ad560f1142ce0e01bcca8b56d13426d"
+
+once@^1.3.0:
+ version "1.4.0"
+ resolved "https://registry.yarnpkg.com/once/-/once-1.4.0.tgz#583b1aa775961d4b113ac17d9c50baef9dd76bd1"
+ dependencies:
+ wrappy "1"
+
+path-is-absolute@^1.0.0:
+ version "1.0.1"
+ resolved "https://registry.yarnpkg.com/path-is-absolute/-/path-is-absolute-1.0.1.tgz#174b9268735534ffbc7ace6bf53a5a9e1b5c5f5f"
+
+platform@^1.3.3:
+ version "1.3.4"
+ resolved "https://registry.yarnpkg.com/platform/-/platform-1.3.4.tgz#6f0fb17edaaa48f21442b3a975c063130f1c3ebd"
+
+resolve@~1.1.7:
+ version "1.1.7"
+ resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.1.7.tgz#203114d82ad2c5ed9e8e0411b3932875e889e97b"
+
+resumer@~0.0.0:
+ version "0.0.0"
+ resolved "https://registry.yarnpkg.com/resumer/-/resumer-0.0.0.tgz#f1e8f461e4064ba39e82af3cdc2a8c893d076759"
+ dependencies:
+ through "~2.3.4"
+
+string.prototype.trim@~1.1.2:
+ version "1.1.2"
+ resolved "https://registry.yarnpkg.com/string.prototype.trim/-/string.prototype.trim-1.1.2.tgz#d04de2c89e137f4d7d206f086b5ed2fae6be8cea"
+ dependencies:
+ define-properties "^1.1.2"
+ es-abstract "^1.5.0"
+ function-bind "^1.0.2"
+
+tape@^4.6.3:
+ version "4.6.3"
+ resolved "https://registry.yarnpkg.com/tape/-/tape-4.6.3.tgz#637e77581e9ab2ce17577e9bd4ce4f575806d8b6"
+ dependencies:
+ deep-equal "~1.0.1"
+ defined "~1.0.0"
+ for-each "~0.3.2"
+ function-bind "~1.1.0"
+ glob "~7.1.1"
+ has "~1.0.1"
+ inherits "~2.0.3"
+ minimist "~1.2.0"
+ object-inspect "~1.2.1"
+ resolve "~1.1.7"
+ resumer "~0.0.0"
+ string.prototype.trim "~1.1.2"
+ through "~2.3.8"
+
+through@~2.3.4, through@~2.3.8:
+ version "2.3.8"
+ resolved "https://registry.yarnpkg.com/through/-/through-2.3.8.tgz#0dd4c9ffaabc357960b1b724115d7e0e86a2e1f5"
+
+turf-is-clockwise@^1.0.0:
+ version "1.0.0"
+ resolved "https://registry.yarnpkg.com/turf-is-clockwise/-/turf-is-clockwise-1.0.0.tgz#dc22e5ffd4cf10934683aa004627cff87a6dfe91"
+
+wrappy@1:
+ version "1.0.2"
+ resolved "https://registry.yarnpkg.com/wrappy/-/wrappy-1.0.2.tgz#b5243d8f3ec1aa35f1364605bc0d1036e30ab69f"
diff --git a/packages/turf-boolean-overlap/LICENSE b/packages/turf-boolean-overlap/LICENSE
new file mode 100644
index 0000000000..96ce51b76f
--- /dev/null
+++ b/packages/turf-boolean-overlap/LICENSE
@@ -0,0 +1,20 @@
+The MIT License (MIT)
+
+Copyright (c) 2017 TurfJS
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of
+this software and associated documentation files (the "Software"), to deal in
+the Software without restriction, including without limitation the rights to
+use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
+the Software, and to permit persons to whom the Software is furnished to do so,
+subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
+FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
+COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
diff --git a/packages/turf-boolean-overlap/README.md b/packages/turf-boolean-overlap/README.md
new file mode 100644
index 0000000000..12449eac26
--- /dev/null
+++ b/packages/turf-boolean-overlap/README.md
@@ -0,0 +1,45 @@
+# @turf/boolean-overlap
+
+# booleanOverlap
+
+Compares two geometries of the same dimension and returns (TRUE) if their
+intersection set results in a geometry different from both but of the same dimension.
+
+**Parameters**
+
+- `feature1` **([Geometry](http://geojson.org/geojson-spec.html#geometry) \| [Feature](http://geojson.org/geojson-spec.html#feature-objects)<any>)** GeoJSON Feature or Geometry
+- `feature2` **([Geometry](http://geojson.org/geojson-spec.html#geometry) \| [Feature](http://geojson.org/geojson-spec.html#feature-objects)<any>)** GeoJSON Feature or Geometry
+
+**Examples**
+
+```javascript
+turf.booleanOverlap(feature1, feature2);
+//=true/false
+```
+
+Returns **[Boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** true/false
+
+
+
+---
+
+This module is part of the [Turfjs project](http://turfjs.org/), an open source
+module collection dedicated to geographic algorithms. It is maintained in the
+[Turfjs/turf](/~https://github.com/Turfjs/turf) repository, where you can create
+PRs and issues.
+
+### Installation
+
+Install this module individually:
+
+```sh
+$ npm install @turf/boolean-overlap
+```
+
+Or install the Turf module that includes it as a function:
+
+```sh
+$ npm install @turf/turf
+```
diff --git a/packages/turf-boolean-overlap/bench.js b/packages/turf-boolean-overlap/bench.js
new file mode 100644
index 0000000000..148209d67c
--- /dev/null
+++ b/packages/turf-boolean-overlap/bench.js
@@ -0,0 +1,30 @@
+const Benchmark = require('benchmark');
+const {point, lineString, polygon} = require('@turf/helpers');
+const disjoint = require('./');
+
+// Fixtures
+const pt = point([1, 1]);
+const line = lineString([[1, 1], [1, 2], [1, 3], [1, 4]]);
+const poly = polygon([[[1, 1], [1, 10], [10, 10], [10, 1], [1, 1]]]);
+
+/**
+ * Benchmark Results
+ *
+ * point - line:
+ * point - polygon:
+ * point - point:
+ * polygon - polygon x 31,308 ops/sec ±4.59% (66 runs sampled)
+ * polygon - line:
+ * line - line x 19,328,831 ops/sec ±1.19% (86 runs sampled)
+ */
+const suite = new Benchmark.Suite('turf-boolean-disjoint');
+suite
+ .add('point - line', () => disjoint(pt, line))
+ .add('point - polygon', () => disjoint(pt, polygon))
+ .add('point - point', () => disjoint(pt, pt))
+ .add('polygon - polygon', () => disjoint(poly, poly))
+ .add('polygon - line', () => disjoint(poly, line))
+ .add('line - line', () => disjoint(line, line))
+ .on('cycle', e => console.log(String(e.target)))
+ .on('complete', () => {})
+ .run();
diff --git a/packages/turf-boolean-overlap/index.d.ts b/packages/turf-boolean-overlap/index.d.ts
new file mode 100644
index 0000000000..c66e0b884a
--- /dev/null
+++ b/packages/turf-boolean-overlap/index.d.ts
@@ -0,0 +1,10 @@
+///
+
+type Feature = GeoJSON.Feature | GeoJSON.GeometryObject;
+
+/**
+ * http://turfjs.org/docs/#boolean-overlap
+ */
+declare function overlap(feature1: Feature, feature2: Feature): boolean;
+declare namespace overlap { }
+export = overlap;
diff --git a/packages/turf-boolean-overlap/index.js b/packages/turf-boolean-overlap/index.js
new file mode 100644
index 0000000000..cb5ff31cf9
--- /dev/null
+++ b/packages/turf-boolean-overlap/index.js
@@ -0,0 +1,155 @@
+var inside = require('@turf/inside');
+var helpers = require('@turf/helpers');
+var deepEqual = require('deep-equal');
+var lineOverlap = require('@turf/line-overlap');
+var lineIntersect = require('@turf/line-intersect');
+var polyToLinestring = require('@turf/polygon-to-linestring');
+
+/**
+ * Compares two geometries of the same dimension and returns (TRUE) if their
+ * intersection set results in a geometry different from both but of the same dimension.
+ *
+ * @name booleanOverlap
+ * @param {Geometry|Feature} feature1 GeoJSON Feature or Geometry
+ * @param {Geometry|Feature} feature2 GeoJSON Feature or Geometry
+ * @returns {Boolean} true/false
+ * @example
+ * turf.booleanOverlap(feature1, feature2);
+ * //=true/false
+ */
+module.exports = function (feature1, feature2) {
+ var type1 = getGeomType(feature1);
+ var type2 = getGeomType(feature2);
+ var geom1 = getGeom(feature1);
+ var geom2 = getGeom(feature2);
+
+ switch (type1) {
+ case 'MultiPoint':
+ switch (type2) {
+ case 'MultiPoint':
+ return doMultiPointsOverlap(geom1, geom2);
+ }
+ throw new Error('feature2 ' + type2 + ' geometry not supported');
+ case 'LineString':
+ switch (type2) {
+ case 'LineString':
+ return isLineOnLine(geom1, geom2);
+ }
+ throw new Error('feature2 ' + type2 + ' geometry not supported');
+ case 'Polygon':
+ switch (type2) {
+ case 'Polygon':
+ return isPolyInPoly(geom1, geom2);
+ }
+ throw new Error('feature2 ' + type2 + ' geometry not supported');
+ default:
+ throw new Error('feature1 ' + type1 + ' geometry not supported');
+ }
+};
+
+function doMultiPointsOverlap(multipoint1, multipoint2) {
+ var foundMatch = false;
+ var foundMismatch = false;
+ for (var i = 0; i < multipoint2.coordinates.length; i++) {
+ var pointHasMatch = false;
+ for (var i2 = 0; i2 < multipoint1.coordinates.length; i2++) {
+ if (deepEqual(multipoint2.coordinates[i], multipoint1.coordinates[i2])) {
+ foundMatch = true;
+ pointHasMatch = true;
+ break;
+ }
+ }
+ if (!pointHasMatch) {
+ foundMismatch = true;
+ }
+ if (foundMatch && foundMismatch) {
+ return true;
+ }
+ }
+ return false;
+}
+
+function isLineOnLine(lineString1, lineString2) {
+ if (deepEqual(lineString1, lineString2)) {
+ return false;
+ }
+ var overlappingLine = lineOverlap(lineString1, lineString2);
+ if (overlappingLine.features.length !== 0) {
+ for (var i = 0; i < lineString1.coordinates.length; i++) {
+ if (!ispointOnLine(lineString2, lineString1.coordinates[i])) {
+ return true;
+ }
+ }
+ }
+ return false;
+}
+
+function ispointInPoly(polygon, point, ignoreBoundary) {
+ return inside(point, polygon, ignoreBoundary);
+}
+
+function isPolyInPoly(polygon1, polygon2) {
+ for (var i = 0; i < polygon1.coordinates[0].length; i++) {
+ if (ispointInPoly(polygon2, helpers.point(polygon1.coordinates[0][i]), true)) {
+ return true;
+ }
+ }
+ if (doLineStringAndPolygonCross(polygon1, polygon2)) {
+ return true;
+ }
+ return false;
+}
+
+function doLineStringAndPolygonCross(polygon1, polygon2) {
+ var doLinesIntersect = lineIntersect(polyToLinestring(polygon1), polyToLinestring(polygon2));
+ if (doLinesIntersect.features.length > 0) {
+ return true;
+ }
+ return false;
+}
+
+function ispointOnLine(lineString, pointCoords) {
+ for (var i = 0; i < lineString.coordinates.length - 1; i++) {
+ if (ispointOnLineSegment(lineString.coordinates[i], lineString.coordinates[i + 1], pointCoords)) {
+ return true;
+ }
+ }
+ return false;
+}
+
+function ispointOnLineSegment(LineSegmentStart, LineSegmentEnd, point) {
+ var dxc = point[0] - LineSegmentStart[0];
+ var dyc = point[1] - LineSegmentStart[1];
+ var dxl = LineSegmentEnd[0] - LineSegmentStart[0];
+ var dyl = LineSegmentEnd[1] - LineSegmentStart[1];
+ var cross = dxc * dyl - dyc * dxl;
+ if (cross !== 0) {
+ return false;
+ }
+ if (Math.abs(dxl) >= Math.abs(dyl)) {
+ return dxl > 0 ? LineSegmentStart[0] <= point[0] && point[0] <= LineSegmentEnd[0] : LineSegmentEnd[0] <= point[0] && point[0] <= LineSegmentStart[0];
+ } else {
+ return dyl > 0 ? LineSegmentStart[1] <= point[1] && point[1] <= LineSegmentEnd[1] : LineSegmentEnd[1] <= point[1] && point[1] <= LineSegmentStart[1];
+ }
+}
+/**
+ * Get Geometry from Feature or Geometry Object
+ * //!! Remove this method when implemented to @turf/invariant
+ *
+ * @private
+ * @param {Feature|Geometry} geojson GeoJSON Feature or Geometry Object
+ * @returns {Geometry} GeoJSON Geometry Object
+ * @throws {Error} if geojson is not a Feature or Geometry Object
+ */
+function getGeom(geojson) {
+ if (geojson.geometry) return geojson.geometry;
+ if (geojson.coordinates) return geojson;
+ throw new Error('geojson must be a feature or geometry object');
+}
+
+// Remove this method when implemented to @turf/invariant
+function getGeomType(geojson) {
+ if (geojson.geometry) return geojson.geometry.type;
+ if (geojson.coordinates) return geojson.type;
+ throw new Error('geojson must be a feature or geometry object');
+}
diff --git a/packages/turf-boolean-overlap/package.json b/packages/turf-boolean-overlap/package.json
new file mode 100644
index 0000000000..7c3c25c73d
--- /dev/null
+++ b/packages/turf-boolean-overlap/package.json
@@ -0,0 +1,49 @@
+{
+ "name": "@turf/boolean-overlap",
+ "version": "4.0.0",
+ "description": "turf boolean-overlap module",
+ "main": "index.js",
+ "types": "index.d.ts",
+ "files": [
+ "index.js",
+ "index.d.ts"
+ ],
+ "scripts": {
+ "test": "node test.js",
+ "bench": "node bench.js"
+ },
+ "repository": {
+ "type": "git",
+ "url": "git://github.com/Turfjs/turf.git"
+ },
+ "keywords": [
+ "turf",
+ "overlap",
+ "boolean",
+ "de-9im"
+ ],
+ "author": "Turf Authors",
+ "contributors": [
+ "Rowan Winsemius <@rowanwins>",
+ "Denis Carriere <@DenisCarriere>"
+ ],
+ "license": "MIT",
+ "bugs": {
+ "url": "/~https://github.com/Turfjs/turf/issues"
+ },
+ "homepage": "/~https://github.com/Turfjs/turf",
+ "devDependencies": {
+ "benchmark": "^2.1.4",
+ "glob": "^7.1.2",
+ "load-json-file": "^2.0.0",
+ "tape": "^4.6.3"
+ },
+ "dependencies": {
+ "@turf/helpers": "^4.3.0",
+ "@turf/inside": "^4.3.0",
+ "@turf/line-intersect": "^4.3.0",
+ "@turf/line-overlap": "^4.3.0",
+ "@turf/polygon-to-linestring": "^4.3.0",
+ "deep-equal": "^1.0.1"
+ }
+}
diff --git a/packages/turf-boolean-overlap/test.js b/packages/turf-boolean-overlap/test.js
new file mode 100644
index 0000000000..52f1df85b6
--- /dev/null
+++ b/packages/turf-boolean-overlap/test.js
@@ -0,0 +1,40 @@
+const path = require('path');
+const test = require('tape');
+const glob = require('glob');
+const load = require('load-json-file');
+const overlap = require('./');
+
+const directories = {
+ true: path.join(__dirname, 'test', 'true', '*.geojson'),
+ false: path.join(__dirname, 'test', 'false', '*.geojson')
+};
+
+const fixtures = [];
+
+glob.sync(directories.true).forEach(filepath => {
+ fixtures.push({
+ name: path.parse(filepath).name,
+ geojson: load.sync(filepath),
+ matchType: true
+ });
+});
+
+glob.sync(directories.false).forEach(filepath => {
+ fixtures.push({
+ name: path.parse(filepath).name,
+ geojson: load.sync(filepath),
+ matchType: false
+ });
+});
+
+test('turf-boolean-overlap', t => {
+ for (let {name, geojson, matchType} of fixtures) {
+ const [feature1, feature2] = geojson.features;
+ if (name === 'polygonsShareBoundary') {
+ t.skip(name);
+ continue;
+ }
+ t.deepEquals(overlap(feature1, feature2), matchType, `${name} returns as ${matchType}`);
+ }
+ t.end();
+});
diff --git a/packages/turf-boolean-overlap/test/false/lineStringExactDuplicate.geojson b/packages/turf-boolean-overlap/test/false/lineStringExactDuplicate.geojson
new file mode 100644
index 0000000000..34db9c8a98
--- /dev/null
+++ b/packages/turf-boolean-overlap/test/false/lineStringExactDuplicate.geojson
@@ -0,0 +1,21 @@
+{
+ "type": "FeatureCollection",
+ "features": [
+ {
+ "type": "Feature",
+ "properties": {},
+ "geometry": {
+ "type": "LineString",
+ "coordinates":[[1, 1], [1, 2], [1, 3], [1, 4]]
+ }
+ },
+ {
+ "type": "Feature",
+ "properties": {},
+ "geometry": {
+ "type": "LineString",
+ "coordinates": [[1, 1], [1, 2], [1, 3], [1, 4]]
+ }
+ }
+ ]
+}
\ No newline at end of file
diff --git a/packages/turf-boolean-overlap/test/false/lineStringWithinOtherLinestring.geojson b/packages/turf-boolean-overlap/test/false/lineStringWithinOtherLinestring.geojson
new file mode 100644
index 0000000000..441854f226
--- /dev/null
+++ b/packages/turf-boolean-overlap/test/false/lineStringWithinOtherLinestring.geojson
@@ -0,0 +1,21 @@
+{
+ "type": "FeatureCollection",
+ "features": [
+ {
+ "type": "Feature",
+ "properties": {},
+ "geometry": {
+ "type": "LineString",
+ "coordinates": [[1, 2], [1, 3]]
+ }
+ },
+ {
+ "type": "Feature",
+ "properties": {},
+ "geometry": {
+ "type": "LineString",
+ "coordinates":[[1, 1], [1, 2], [1, 3], [1, 4]]
+ }
+ }
+ ]
+}
\ No newline at end of file
diff --git a/packages/turf-boolean-overlap/test/false/multiPointExactDuplicateFeatures.geojson b/packages/turf-boolean-overlap/test/false/multiPointExactDuplicateFeatures.geojson
new file mode 100644
index 0000000000..5bd37a17dc
--- /dev/null
+++ b/packages/turf-boolean-overlap/test/false/multiPointExactDuplicateFeatures.geojson
@@ -0,0 +1,21 @@
+{
+ "type": "FeatureCollection",
+ "features": [
+ {
+ "type": "Feature",
+ "properties": {},
+ "geometry": {
+ "type": "MultiPoint",
+ "coordinates":[[0, 0], [0, 10], [10, 10], [10, 0], [0, 0]]
+ }
+ },
+ {
+ "type": "Feature",
+ "properties": {},
+ "geometry": {
+ "type": "MultiPoint",
+ "coordinates":[[0, 0], [0, 10], [10, 10], [10, 0], [0, 0]]
+ }
+ }
+ ]
+}
\ No newline at end of file
diff --git a/packages/turf-boolean-overlap/test/false/multiPointMisorderedButMatchingFeatures.geojson b/packages/turf-boolean-overlap/test/false/multiPointMisorderedButMatchingFeatures.geojson
new file mode 100644
index 0000000000..72c83c0ab3
--- /dev/null
+++ b/packages/turf-boolean-overlap/test/false/multiPointMisorderedButMatchingFeatures.geojson
@@ -0,0 +1,21 @@
+{
+ "type": "FeatureCollection",
+ "features": [
+ {
+ "type": "Feature",
+ "properties": {},
+ "geometry": {
+ "type": "MultiPoint",
+ "coordinates":[[0, 10], [0, 0], [10, 10], [10, 0], [0, 0]]
+ }
+ },
+ {
+ "type": "Feature",
+ "properties": {},
+ "geometry": {
+ "type": "MultiPoint",
+ "coordinates":[[0, 0], [0, 10], [10, 10], [10, 0], [0, 0]]
+ }
+ }
+ ]
+}
\ No newline at end of file
diff --git a/packages/turf-boolean-overlap/test/false/multiPointNoOverlap.geojson b/packages/turf-boolean-overlap/test/false/multiPointNoOverlap.geojson
new file mode 100644
index 0000000000..ef7047d414
--- /dev/null
+++ b/packages/turf-boolean-overlap/test/false/multiPointNoOverlap.geojson
@@ -0,0 +1,21 @@
+{
+ "type": "FeatureCollection",
+ "features": [
+ {
+ "type": "Feature",
+ "properties": {},
+ "geometry": {
+ "type": "MultiPoint",
+ "coordinates":[[0, 0], [0, 10], [10, 10], [10, 0], [0, 0]]
+ }
+ },
+ {
+ "type": "Feature",
+ "properties": {},
+ "geometry": {
+ "type": "MultiPoint",
+ "coordinates": [[100, 100], [20, 20]]
+ }
+ }
+ ]
+}
\ No newline at end of file
diff --git a/packages/turf-boolean-overlap/test/false/polygonsNoOverlap.geojson b/packages/turf-boolean-overlap/test/false/polygonsNoOverlap.geojson
new file mode 100644
index 0000000000..e7ffa3d5a7
--- /dev/null
+++ b/packages/turf-boolean-overlap/test/false/polygonsNoOverlap.geojson
@@ -0,0 +1,21 @@
+{
+ "type": "FeatureCollection",
+ "features": [
+ {
+ "type": "Feature",
+ "properties": {},
+ "geometry": {
+ "type": "Polygon",
+ "coordinates": [[[-1, 2], [3, 2], [3, 3], [-1, 3], [-1, 2]]]
+ }
+ },
+ {
+ "type": "Feature",
+ "properties": {},
+ "geometry": {
+ "type": "Polygon",
+ "coordinates": [[[-10, 20], [30, 20], [30, 30], [-10, 30], [-10, 20]]]
+ }
+ }
+ ]
+}
\ No newline at end of file
diff --git a/packages/turf-boolean-overlap/test/false/polygonsShareBoundary.geojson b/packages/turf-boolean-overlap/test/false/polygonsShareBoundary.geojson
new file mode 100644
index 0000000000..250b665a4c
--- /dev/null
+++ b/packages/turf-boolean-overlap/test/false/polygonsShareBoundary.geojson
@@ -0,0 +1,21 @@
+{
+ "type": "FeatureCollection",
+ "features": [
+ {
+ "type": "Feature",
+ "properties": {},
+ "geometry": {
+ "type": "Polygon",
+ "coordinates": [[[-1, 2], [3, 2], [3, 3], [-1, 3], [-1, 2]]]
+ }
+ },
+ {
+ "type": "Feature",
+ "properties": {},
+ "geometry": {
+ "type": "Polygon",
+ "coordinates": [[[-1, 3], [30, 3], [30, 30], [-10, 30], [-1, 3]]]
+ }
+ }
+ ]
+}
\ No newline at end of file
diff --git a/packages/turf-boolean-overlap/test/true/lineStringPartialOverlap.geojson b/packages/turf-boolean-overlap/test/true/lineStringPartialOverlap.geojson
new file mode 100644
index 0000000000..14632e72e2
--- /dev/null
+++ b/packages/turf-boolean-overlap/test/true/lineStringPartialOverlap.geojson
@@ -0,0 +1,21 @@
+{
+ "type": "FeatureCollection",
+ "features": [
+ {
+ "type": "Feature",
+ "properties": {},
+ "geometry": {
+ "type": "LineString",
+ "coordinates":[[1, 1], [1, 2], [1, 3], [1, 4]]
+ }
+ },
+ {
+ "type": "Feature",
+ "properties": {},
+ "geometry": {
+ "type": "LineString",
+ "coordinates": [[2, 1], [1, 2], [1, 3], [2, 4]]
+ }
+ }
+ ]
+}
\ No newline at end of file
diff --git a/packages/turf-boolean-overlap/test/true/multiPointPartialOverlapFeatures.geojson b/packages/turf-boolean-overlap/test/true/multiPointPartialOverlapFeatures.geojson
new file mode 100644
index 0000000000..294994c0b8
--- /dev/null
+++ b/packages/turf-boolean-overlap/test/true/multiPointPartialOverlapFeatures.geojson
@@ -0,0 +1,21 @@
+{
+ "type": "FeatureCollection",
+ "features": [
+ {
+ "type": "Feature",
+ "properties": {},
+ "geometry": {
+ "type": "MultiPoint",
+ "coordinates":[[0, 0], [0, 10], [10, 10], [10, 0], [0, 0]]
+ }
+ },
+ {
+ "type": "Feature",
+ "properties": {},
+ "geometry": {
+ "type": "MultiPoint",
+ "coordinates": [[-10, 0], [10, 10], [10, 10], [10, 0], [0, 0]]
+ }
+ }
+ ]
+}
\ No newline at end of file
diff --git a/packages/turf-boolean-overlap/test/true/polygonLineCrossesOtherPolygon.geojson b/packages/turf-boolean-overlap/test/true/polygonLineCrossesOtherPolygon.geojson
new file mode 100644
index 0000000000..a22f6599b6
--- /dev/null
+++ b/packages/turf-boolean-overlap/test/true/polygonLineCrossesOtherPolygon.geojson
@@ -0,0 +1,21 @@
+{
+ "type": "FeatureCollection",
+ "features": [
+ {
+ "type": "Feature",
+ "properties": {},
+ "geometry": {
+ "type": "Polygon",
+ "coordinates": [[[-1, 2], [3, 2], [3, 3], [-1, 3], [-1, 2]]]
+ }
+ },
+ {
+ "type": "Feature",
+ "properties": {},
+ "geometry": {
+ "type": "Polygon",
+ "coordinates": [[[1, 0], [4, 0], [4, 4], [1, 4], [1, 0]]]
+ }
+ }
+ ]
+}
\ No newline at end of file
diff --git a/packages/turf-boolean-overlap/test/true/polygonPointInsideOtherPolygon.geojson b/packages/turf-boolean-overlap/test/true/polygonPointInsideOtherPolygon.geojson
new file mode 100644
index 0000000000..08f2951da9
--- /dev/null
+++ b/packages/turf-boolean-overlap/test/true/polygonPointInsideOtherPolygon.geojson
@@ -0,0 +1,21 @@
+{
+ "type": "FeatureCollection",
+ "features": [
+ {
+ "type": "Feature",
+ "properties": {},
+ "geometry": {
+ "type": "Polygon",
+ "coordinates": [[[-1, 2], [3, 2], [3, 3], [-1, 3], [-1, 2]]]
+ }
+ },
+ {
+ "type": "Feature",
+ "properties": {},
+ "geometry": {
+ "type": "Polygon",
+ "coordinates": [[[0, 1], [3, 2], [3, 3], [-1, 3], [0, 1]]]
+ }
+ }
+ ]
+}
\ No newline at end of file
diff --git a/packages/turf-boolean-overlap/yarn.lock b/packages/turf-boolean-overlap/yarn.lock
new file mode 100644
index 0000000000..be7c555400
--- /dev/null
+++ b/packages/turf-boolean-overlap/yarn.lock
@@ -0,0 +1,340 @@
+# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
+# yarn lockfile v1
+
+
+"@turf/bbox@^3.10.5":
+ version "3.14.0"
+ resolved "https://registry.yarnpkg.com/@turf/bbox/-/bbox-3.14.0.tgz#cee5f396dde78aca9cede05e1122db18bc504635"
+ dependencies:
+ "@turf/meta" "^3.14.0"
+
+"@turf/helpers@^3.10.5":
+ version "3.13.0"
+ resolved "https://registry.yarnpkg.com/@turf/helpers/-/helpers-3.13.0.tgz#d06078a1464cf56cdb7ea624ea1e13a71b88b806"
+
+"@turf/helpers@^4.3.0":
+ version "4.3.0"
+ resolved "https://registry.yarnpkg.com/@turf/helpers/-/helpers-4.3.0.tgz#7b2f733aa0eb3ea1f07d467ac02ede00cc6cde0d"
+
+"@turf/inside@^4.3.0":
+ version "4.3.0"
+ resolved "https://registry.yarnpkg.com/@turf/inside/-/inside-4.3.0.tgz#ba06be5966a5ab31c1cabb9819241e0802422c45"
+ dependencies:
+ "@turf/invariant" "^4.3.0"
+
+"@turf/invariant@^4.3.0":
+ version "4.3.0"
+ resolved "https://registry.yarnpkg.com/@turf/invariant/-/invariant-4.3.0.tgz#5bd1ce6ae51b1229dc0dc7d09d973fabae49af89"
+
+"@turf/line-intersect@^4.3.0":
+ version "4.3.0"
+ resolved "https://registry.yarnpkg.com/@turf/line-intersect/-/line-intersect-4.3.0.tgz#0421d1eb2732e14bf8fc02e8b46223f91cd6f9d7"
+ dependencies:
+ "@turf/helpers" "^4.3.0"
+ "@turf/invariant" "^4.3.0"
+ "@turf/line-segment" "^4.3.0"
+ "@turf/meta" "^4.3.0"
+ geojson-rbush "^1.0.1"
+
+"@turf/line-overlap@^4.3.0":
+ version "4.3.0"
+ resolved "https://registry.yarnpkg.com/@turf/line-overlap/-/line-overlap-4.3.0.tgz#f0572d3a3f536a35055d857099b5d1549cfd0074"
+ dependencies:
+ "@turf/helpers" "^4.3.0"
+ "@turf/invariant" "^4.3.0"
+ "@turf/line-segment" "^4.3.0"
+ "@turf/meta" "^4.3.0"
+ deep-equal "^1.0.1"
+ geojson-rbush "^1.0.1"
+
+"@turf/line-segment@^4.3.0":
+ version "4.3.0"
+ resolved "https://registry.yarnpkg.com/@turf/line-segment/-/line-segment-4.3.0.tgz#7835209227f3c0712ec549c6f51af72394c638ab"
+ dependencies:
+ "@turf/helpers" "^4.3.0"
+ "@turf/invariant" "^4.3.0"
+ "@turf/meta" "^4.3.0"
+
+"@turf/meta@^3.10.5", "@turf/meta@^3.14.0":
+ version "3.14.0"
+ resolved "https://registry.yarnpkg.com/@turf/meta/-/meta-3.14.0.tgz#8d3050c1a0f44bf406a633b6bd28c510f7bcee27"
+
+"@turf/meta@^4.3.0":
+ version "4.3.0"
+ resolved "https://registry.yarnpkg.com/@turf/meta/-/meta-4.3.0.tgz#eb11dd2c2511524258123767fe0f5c3bd963e8d7"
+
+"@turf/polygon-to-linestring@^4.3.0":
+ version "4.3.0"
+ resolved "https://registry.yarnpkg.com/@turf/polygon-to-linestring/-/polygon-to-linestring-4.3.0.tgz#a17c580fc403f2b136295853ca5fff0c981eb0a2"
+ dependencies:
+ "@turf/helpers" "^4.3.0"
+ "@turf/invariant" "^4.3.0"
+
+balanced-match@^0.4.1:
+ version "0.4.2"
+ resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-0.4.2.tgz#cb3f3e3c732dc0f01ee70b403f302e61d7709838"
+
+benchmark@^2.1.4:
+ version "2.1.4"
+ resolved "https://registry.yarnpkg.com/benchmark/-/benchmark-2.1.4.tgz#09f3de31c916425d498cc2ee565a0ebf3c2a5629"
+ dependencies:
+ lodash "^4.17.4"
+ platform "^1.3.3"
+
+brace-expansion@^1.1.7:
+ version "1.1.7"
+ resolved "https://registry.yarnpkg.com/brace-expansion/-/brace-expansion-1.1.7.tgz#3effc3c50e000531fb720eaff80f0ae8ef23cf59"
+ dependencies:
+ balanced-match "^0.4.1"
+ concat-map "0.0.1"
+
+concat-map@0.0.1:
+ version "0.0.1"
+ resolved "https://registry.yarnpkg.com/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b"
+
+deep-equal@^1.0.1, deep-equal@~1.0.1:
+ version "1.0.1"
+ resolved "https://registry.yarnpkg.com/deep-equal/-/deep-equal-1.0.1.tgz#f5d260292b660e084eff4cdbc9f08ad3247448b5"
+
+define-properties@^1.1.2:
+ version "1.1.2"
+ resolved "https://registry.yarnpkg.com/define-properties/-/define-properties-1.1.2.tgz#83a73f2fea569898fb737193c8f873caf6d45c94"
+ dependencies:
+ foreach "^2.0.5"
+ object-keys "^1.0.8"
+
+defined@~1.0.0:
+ version "1.0.0"
+ resolved "https://registry.yarnpkg.com/defined/-/defined-1.0.0.tgz#c98d9bcef75674188e110969151199e39b1fa693"
+
+error-ex@^1.2.0:
+ version "1.3.1"
+ resolved "https://registry.yarnpkg.com/error-ex/-/error-ex-1.3.1.tgz#f855a86ce61adc4e8621c3cda21e7a7612c3a8dc"
+ dependencies:
+ is-arrayish "^0.2.1"
+
+es-abstract@^1.5.0:
+ version "1.7.0"
+ resolved "https://registry.yarnpkg.com/es-abstract/-/es-abstract-1.7.0.tgz#dfade774e01bfcd97f96180298c449c8623fb94c"
+ dependencies:
+ es-to-primitive "^1.1.1"
+ function-bind "^1.1.0"
+ is-callable "^1.1.3"
+ is-regex "^1.0.3"
+
+es-to-primitive@^1.1.1:
+ version "1.1.1"
+ resolved "https://registry.yarnpkg.com/es-to-primitive/-/es-to-primitive-1.1.1.tgz#45355248a88979034b6792e19bb81f2b7975dd0d"
+ dependencies:
+ is-callable "^1.1.1"
+ is-date-object "^1.0.1"
+ is-symbol "^1.0.1"
+
+for-each@~0.3.2:
+ version "0.3.2"
+ resolved "https://registry.yarnpkg.com/for-each/-/for-each-0.3.2.tgz#2c40450b9348e97f281322593ba96704b9abd4d4"
+ dependencies:
+ is-function "~1.0.0"
+
+foreach@^2.0.5:
+ version "2.0.5"
+ resolved "https://registry.yarnpkg.com/foreach/-/foreach-2.0.5.tgz#0bee005018aeb260d0a3af3ae658dd0136ec1b99"
+
+fs.realpath@^1.0.0:
+ version "1.0.0"
+ resolved "https://registry.yarnpkg.com/fs.realpath/-/fs.realpath-1.0.0.tgz#1504ad2523158caa40db4a2787cb01411994ea4f"
+
+function-bind@^1.0.2, function-bind@^1.1.0, function-bind@~1.1.0:
+ version "1.1.0"
+ resolved "https://registry.yarnpkg.com/function-bind/-/function-bind-1.1.0.tgz#16176714c801798e4e8f2cf7f7529467bb4a5771"
+
+geojson-rbush@^1.0.1:
+ version "1.0.1"
+ resolved "https://registry.yarnpkg.com/geojson-rbush/-/geojson-rbush-1.0.1.tgz#450559bc18457e725191ac9acbbe0a8b5e18ddae"
+ dependencies:
+ "@turf/bbox" "^3.10.5"
+ "@turf/helpers" "^3.10.5"
+ "@turf/meta" "^3.10.5"
+ rbush "^2.0.1"
+
+glob@^7.1.2:
+ version "7.1.2"
+ resolved "https://registry.yarnpkg.com/glob/-/glob-7.1.2.tgz#c19c9df9a028702d678612384a6552404c636d15"
+ dependencies:
+ fs.realpath "^1.0.0"
+ inflight "^1.0.4"
+ inherits "2"
+ minimatch "^3.0.4"
+ once "^1.3.0"
+ path-is-absolute "^1.0.0"
+
+glob@~7.1.1:
+ version "7.1.1"
+ resolved "https://registry.yarnpkg.com/glob/-/glob-7.1.1.tgz#805211df04faaf1c63a3600306cdf5ade50b2ec8"
+ dependencies:
+ fs.realpath "^1.0.0"
+ inflight "^1.0.4"
+ inherits "2"
+ minimatch "^3.0.2"
+ once "^1.3.0"
+ path-is-absolute "^1.0.0"
+
+graceful-fs@^4.1.2:
+ version "4.1.11"
+ resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.1.11.tgz#0e8bdfe4d1ddb8854d64e04ea7c00e2a026e5658"
+
+has@^1.0.1, has@~1.0.1:
+ version "1.0.1"
+ resolved "https://registry.yarnpkg.com/has/-/has-1.0.1.tgz#8461733f538b0837c9361e39a9ab9e9704dc2f28"
+ dependencies:
+ function-bind "^1.0.2"
+
+inflight@^1.0.4:
+ version "1.0.6"
+ resolved "https://registry.yarnpkg.com/inflight/-/inflight-1.0.6.tgz#49bd6331d7d02d0c09bc910a1075ba8165b56df9"
+ dependencies:
+ once "^1.3.0"
+ wrappy "1"
+
+inherits@2, inherits@~2.0.3:
+ version "2.0.3"
+ resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.3.tgz#633c2c83e3da42a502f52466022480f4208261de"
+
+is-arrayish@^0.2.1:
+ version "0.2.1"
+ resolved "https://registry.yarnpkg.com/is-arrayish/-/is-arrayish-0.2.1.tgz#77c99840527aa8ecb1a8ba697b80645a7a926a9d"
+
+is-callable@^1.1.1, is-callable@^1.1.3:
+ version "1.1.3"
+ resolved "https://registry.yarnpkg.com/is-callable/-/is-callable-1.1.3.tgz#86eb75392805ddc33af71c92a0eedf74ee7604b2"
+
+is-date-object@^1.0.1:
+ version "1.0.1"
+ resolved "https://registry.yarnpkg.com/is-date-object/-/is-date-object-1.0.1.tgz#9aa20eb6aeebbff77fbd33e74ca01b33581d3a16"
+
+is-function@~1.0.0:
+ version "1.0.1"
+ resolved "https://registry.yarnpkg.com/is-function/-/is-function-1.0.1.tgz#12cfb98b65b57dd3d193a3121f5f6e2f437602b5"
+
+is-regex@^1.0.3:
+ version "1.0.4"
+ resolved "https://registry.yarnpkg.com/is-regex/-/is-regex-1.0.4.tgz#5517489b547091b0930e095654ced25ee97e9491"
+ dependencies:
+ has "^1.0.1"
+
+is-symbol@^1.0.1:
+ version "1.0.1"
+ resolved "https://registry.yarnpkg.com/is-symbol/-/is-symbol-1.0.1.tgz#3cc59f00025194b6ab2e38dbae6689256b660572"
+
+load-json-file@^2.0.0:
+ version "2.0.0"
+ resolved "https://registry.yarnpkg.com/load-json-file/-/load-json-file-2.0.0.tgz#7947e42149af80d696cbf797bcaabcfe1fe29ca8"
+ dependencies:
+ graceful-fs "^4.1.2"
+ parse-json "^2.2.0"
+ pify "^2.0.0"
+ strip-bom "^3.0.0"
+
+lodash@^4.17.4:
+ version "4.17.4"
+ resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.4.tgz#78203a4d1c328ae1d86dca6460e369b57f4055ae"
+
+minimatch@^3.0.2, minimatch@^3.0.4:
+ version "3.0.4"
+ resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.0.4.tgz#5166e286457f03306064be5497e8dbb0c3d32083"
+ dependencies:
+ brace-expansion "^1.1.7"
+
+minimist@~1.2.0:
+ version "1.2.0"
+ resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.0.tgz#a35008b20f41383eec1fb914f4cd5df79a264284"
+
+object-inspect@~1.2.1:
+ version "1.2.2"
+ resolved "https://registry.yarnpkg.com/object-inspect/-/object-inspect-1.2.2.tgz#c82115e4fcc888aea14d64c22e4f17f6a70d5e5a"
+
+object-keys@^1.0.8:
+ version "1.0.11"
+ resolved "https://registry.yarnpkg.com/object-keys/-/object-keys-1.0.11.tgz#c54601778ad560f1142ce0e01bcca8b56d13426d"
+
+once@^1.3.0:
+ version "1.4.0"
+ resolved "https://registry.yarnpkg.com/once/-/once-1.4.0.tgz#583b1aa775961d4b113ac17d9c50baef9dd76bd1"
+ dependencies:
+ wrappy "1"
+
+parse-json@^2.2.0:
+ version "2.2.0"
+ resolved "https://registry.yarnpkg.com/parse-json/-/parse-json-2.2.0.tgz#f480f40434ef80741f8469099f8dea18f55a4dc9"
+ dependencies:
+ error-ex "^1.2.0"
+
+path-is-absolute@^1.0.0:
+ version "1.0.1"
+ resolved "https://registry.yarnpkg.com/path-is-absolute/-/path-is-absolute-1.0.1.tgz#174b9268735534ffbc7ace6bf53a5a9e1b5c5f5f"
+
+pify@^2.0.0:
+ version "2.3.0"
+ resolved "https://registry.yarnpkg.com/pify/-/pify-2.3.0.tgz#ed141a6ac043a849ea588498e7dca8b15330e90c"
+
+platform@^1.3.3:
+ version "1.3.4"
+ resolved "https://registry.yarnpkg.com/platform/-/platform-1.3.4.tgz#6f0fb17edaaa48f21442b3a975c063130f1c3ebd"
+
+quickselect@^1.0.0:
+ version "1.0.0"
+ resolved "https://registry.yarnpkg.com/quickselect/-/quickselect-1.0.0.tgz#02630818f9aae4ecab26f0103f98d061c17c58f3"
+
+rbush@^2.0.1:
+ version "2.0.1"
+ resolved "https://registry.yarnpkg.com/rbush/-/rbush-2.0.1.tgz#4cfaca28c3064bc0ee75431a1b79990e875eefa9"
+ dependencies:
+ quickselect "^1.0.0"
+
+resolve@~1.1.7:
+ version "1.1.7"
+ resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.1.7.tgz#203114d82ad2c5ed9e8e0411b3932875e889e97b"
+
+resumer@~0.0.0:
+ version "0.0.0"
+ resolved "https://registry.yarnpkg.com/resumer/-/resumer-0.0.0.tgz#f1e8f461e4064ba39e82af3cdc2a8c893d076759"
+ dependencies:
+ through "~2.3.4"
+
+string.prototype.trim@~1.1.2:
+ version "1.1.2"
+ resolved "https://registry.yarnpkg.com/string.prototype.trim/-/string.prototype.trim-1.1.2.tgz#d04de2c89e137f4d7d206f086b5ed2fae6be8cea"
+ dependencies:
+ define-properties "^1.1.2"
+ es-abstract "^1.5.0"
+ function-bind "^1.0.2"
+
+strip-bom@^3.0.0:
+ version "3.0.0"
+ resolved "https://registry.yarnpkg.com/strip-bom/-/strip-bom-3.0.0.tgz#2334c18e9c759f7bdd56fdef7e9ae3d588e68ed3"
+
+tape@^4.6.3:
+ version "4.6.3"
+ resolved "https://registry.yarnpkg.com/tape/-/tape-4.6.3.tgz#637e77581e9ab2ce17577e9bd4ce4f575806d8b6"
+ dependencies:
+ deep-equal "~1.0.1"
+ defined "~1.0.0"
+ for-each "~0.3.2"
+ function-bind "~1.1.0"
+ glob "~7.1.1"
+ has "~1.0.1"
+ inherits "~2.0.3"
+ minimist "~1.2.0"
+ object-inspect "~1.2.1"
+ resolve "~1.1.7"
+ resumer "~0.0.0"
+ string.prototype.trim "~1.1.2"
+ through "~2.3.8"
+
+through@~2.3.4, through@~2.3.8:
+ version "2.3.8"
+ resolved "https://registry.yarnpkg.com/through/-/through-2.3.8.tgz#0dd4c9ffaabc357960b1b724115d7e0e86a2e1f5"
+
+wrappy@1:
+ version "1.0.2"
+ resolved "https://registry.yarnpkg.com/wrappy/-/wrappy-1.0.2.tgz#b5243d8f3ec1aa35f1364605bc0d1036e30ab69f"
diff --git a/packages/turf-boolean-touch/LICENSE b/packages/turf-boolean-touch/LICENSE
new file mode 100644
index 0000000000..96ce51b76f
--- /dev/null
+++ b/packages/turf-boolean-touch/LICENSE
@@ -0,0 +1,20 @@
+The MIT License (MIT)
+
+Copyright (c) 2017 TurfJS
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of
+this software and associated documentation files (the "Software"), to deal in
+the Software without restriction, including without limitation the rights to
+use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
+the Software, and to permit persons to whom the Software is furnished to do so,
+subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
+FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
+COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
diff --git a/packages/turf-boolean-touch/README.md b/packages/turf-boolean-touch/README.md
new file mode 100644
index 0000000000..96b3cd8d61
--- /dev/null
+++ b/packages/turf-boolean-touch/README.md
@@ -0,0 +1,61 @@
+# @turf/boolean-touch
+
+# touch
+
+Touch returns True if none of the points common to both geometries intersect the interiors of both geometries.
+At least one geometry must be a linestring, polygon, multilinestring, or multipolygon.
+
+**Parameters**
+
+- `feature1` **([Geometry](http://geojson.org/geojson-spec.html#geometry) \| [Feature](http://geojson.org/geojson-spec.html#feature-objects)<any>)** GeoJSON Feature or Geometry
+- `feature2` **([Geometry](http://geojson.org/geojson-spec.html#geometry) \| [Feature](http://geojson.org/geojson-spec.html#feature-objects)<any>)** GeoJSON Feature or Geometry
+
+**Examples**
+
+```javascript
+const point = {
+ "type": "Feature",
+ "properties": {},
+ "geometry": {
+ "type": "Point",
+ "coordinates": [1, 1]
+ }
+}
+const line = {
+ "type": "Feature",
+ "properties": {},
+ "geometry": {
+ "type": "LineString",
+ "coordinates": [[1, 1], [1, 2], [1, 3], [1, 4]]
+ }
+}
+turf.touch(point, line);
+//=true/false
+```
+
+Returns **[Boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** true/false
+
+
+
+---
+
+This module is part of the [Turfjs project](http://turfjs.org/), an open source
+module collection dedicated to geographic algorithms. It is maintained in the
+[Turfjs/turf](/~https://github.com/Turfjs/turf) repository, where you can create
+PRs and issues.
+
+### Installation
+
+Install this module individually:
+
+```sh
+$ npm install @turf/boolean-touch
+```
+
+Or install the Turf module that includes it as a function:
+
+```sh
+$ npm install @turf/turf
+```
diff --git a/packages/turf-boolean-touch/bench.js b/packages/turf-boolean-touch/bench.js
new file mode 100644
index 0000000000..8119e6b457
--- /dev/null
+++ b/packages/turf-boolean-touch/bench.js
@@ -0,0 +1,28 @@
+const Benchmark = require('benchmark');
+const {point, lineString, polygon} = require('@turf/helpers');
+const touch = require('./');
+
+// Fixtures
+const pt = point([1, 1]);
+const line = lineString([[1, 1], [1, 2], [1, 3], [1, 4]]);
+const poly = polygon([[[1, 1], [1, 10], [10, 10], [10, 1], [1, 1]]]);
+
+/**
+ * Benchmark Results
+ *
+ * point - line x 787,087 ops/sec ±4.45% (81 runs sampled)
+ * point - polygon:
+ * point - point x 21,469,879 ops/sec ±7.21% (84 runs sampled)
+ * polygon - polygon x 11,608,532 ops/sec ±1.03% (88 runs sampled)
+ * line - line x 14,834,036 ops/sec ±1.15% (85 runs sampled)
+ */
+const suite = new Benchmark.Suite('turf-boolean-touch');
+suite
+ .add('point - line', () => touch(pt, line))
+ .add('point - polygon', () => touch(pt, polygon))
+ .add('point - point', () => touch(pt, pt))
+ .add('polygon - polygon', () => touch(poly, poly))
+ .add('line - line', () => touch(line, line))
+ .on('cycle', e => console.log(String(e.target)))
+ .on('complete', () => {})
+ .run();
diff --git a/packages/turf-boolean-touch/index.d.ts b/packages/turf-boolean-touch/index.d.ts
new file mode 100644
index 0000000000..082e327533
--- /dev/null
+++ b/packages/turf-boolean-touch/index.d.ts
@@ -0,0 +1,10 @@
+///
+
+type Feature = GeoJSON.Feature | GeoJSON.GeometryObject;
+
+/**
+ * http://turfjs.org/docs/#boolean-touch
+ */
+declare function touch(feature1: Feature, feature2: Feature): boolean;
+declare namespace touch { }
+export = touch;
diff --git a/packages/turf-boolean-touch/index.js b/packages/turf-boolean-touch/index.js
new file mode 100644
index 0000000000..3640ba0e11
--- /dev/null
+++ b/packages/turf-boolean-touch/index.js
@@ -0,0 +1,164 @@
+// var inside = require('@turf/inside');
+// var getCoords = require('@turf/invariant').getCoords;
+var deepEqual = require('deep-equal');
+// var lineOverlap = require('@turf/line-overlap');
+// var polyToLinestring = require('@turf/polygon-to-linestring');
+
+/**
+ * Touch returns True if none of the points common to both geometries intersect the interiors of both geometries.
+ * At least one geometry must be a linestring, polygon, multilinestring, or multipolygon.
+ *
+ * @name touch
+ * @param {Geometry|Feature} feature1 GeoJSON Feature or Geometry
+ * @param {Geometry|Feature} feature2 GeoJSON Feature or Geometry
+ * @returns {Boolean} true/false
+ * @example
+ * const point = {
+ * "type": "Feature",
+ * "properties": {},
+ * "geometry": {
+ * "type": "Point",
+ * "coordinates": [1, 1]
+ * }
+ * }
+ * const line = {
+ * "type": "Feature",
+ * "properties": {},
+ * "geometry": {
+ * "type": "LineString",
+ * "coordinates": [[1, 1], [1, 2], [1, 3], [1, 4]]
+ * }
+ * }
+ * turf.touch(point, line);
+ * //=true/false
+ */
+module.exports = function (feature1, feature2) {
+ // var geom1 = getGeom(feature1);
+ // var geom2 = getGeom(feature2);
+ var type1 = getGeomType(feature1);
+ var type2 = getGeomType(feature2);
+ // var coords1 = getCoords(feature1);
+ // var coords2 = getCoords(feature1);
+
+ switch (type1) {
+ case 'Point':
+ switch (type2) {
+ case 'LineString': return isPointAtEndOfLine(feature1, feature2);
+ case 'Polygon': return isPointOnPolygon(feature1, feature2);
+ default: throw new Error('geometry ' + type2 + ' is not supported');
+ }
+ case 'MultiPoint':
+ switch (type2) {
+ case 'LineString': return isMultiPointAtEndOfLine(feature1, feature2);
+ case 'Polygon': return isMultiPointOnPolygon(feature1, feature2);
+ default: throw new Error('geometry ' + type2 + ' is not supported');
+ }
+ case 'LineString':
+ switch (type2) {
+ // case 'LineString': return return isLineStringOnLineString(feature1, feature2);
+ // case 'Polygon': return isLineStringOnPolygon(feature1, feature2);
+ default: throw new Error('geometry ' + type2 + ' is not supported');
+ }
+ default: throw new Error('geometry ' + type1 + ' is not supported');
+ }
+};
+
+function isPointAtEndOfLine(Point, LineString) {
+ if (deepEqual(Point.geometry.coordinates, LineString.geometry.coordinates[0])) {
+ return true;
+ }
+ if (deepEqual(Point.geometry.coordinates, LineString.geometry.coordinates[LineString.geometry.coordinates.length - 1])) {
+ return true;
+ }
+ return false;
+}
+
+function isMultiPointAtEndOfLine(MultiPoint, LineString) {
+ var i;
+ var onStartOrEnd = 0;
+ var pointIsSomewhereOnLine = 0;
+ var lastLinestringCoordIndex = LineString.geometry.coordinates.length - 1;
+ for (i = 0; i < MultiPoint.geometry.coordinates.length; i++) {
+ if (deepEqual(MultiPoint.geometry.coordinates[i], LineString.geometry.coordinates[0])) {
+ onStartOrEnd++;
+ continue;
+ }
+ if (deepEqual(MultiPoint.geometry.coordinates[i], lastLinestringCoordIndex)) {
+ onStartOrEnd++;
+ continue;
+ }
+ for (var lineI = 0; lineI < LineString.geometry.coordinates.length - 1; lineI++) {
+ if (isPointOnLineSegment(LineString.geometry.coordinates[lineI], LineString.geometry.coordinates[lineI + 1], MultiPoint.geometry.coordinates[i])) {
+ pointIsSomewhereOnLine++;
+ }
+ }
+ }
+ return onStartOrEnd === 1 && pointIsSomewhereOnLine === 0;
+}
+
+function isPointOnPolygon(Point, Polygon) {
+ var output = false;
+ var i;
+ for (i = 0; i < Polygon.geometry.coordinates[0].length - 1; i++) {
+ if (isPointOnLineSegment(Polygon.geometry.coordinates[0][i], Polygon.geometry.coordinates[0][i + 1], Point.geometry.coordinates)) {
+ output = true;
+ break;
+ }
+ }
+ return output;
+}
+
+function isMultiPointOnPolygon(MultiPoint, Polygon) {
+ var i = 0;
+ var numberMatches = 0;
+ for (i; i < MultiPoint.geometry.coordinates.length; i++) {
+ var i2 = 0;
+ for (i2; i2 < Polygon.geometry.coordinates[0].length - 1; i2++) {
+ if (isPointOnLineSegment(Polygon.geometry.coordinates[0][i2], Polygon.geometry.coordinates[0][i2 + 1], MultiPoint.geometry.coordinates[i])) {
+ numberMatches++;
+ break;
+ }
+ }
+ }
+ return numberMatches === 1;
+}
+
+// function isLineStringOnPolygon (LineString, Polygon) {
+// for (var lineI = 0; lineI < LineString.geometry.coordinates.length; lineI++) {
+// var isVerticeInside = inside(LineString.geometry.coordinates[lineI], Polygon);
+// if (!isVerticeInside) {
+// return false;
+// }
+// }
+// var overLappingLines = lineOverlap(LineString, polyToLinestring(Polygon)).features[0];
+// }
+
+function isPointOnLineSegment(LineSegmentStart, LineSegmentEnd, Point) {
+ var dxc = Point[0] - LineSegmentStart[0];
+ var dyc = Point[1] - LineSegmentStart[1];
+ var dxl = LineSegmentEnd[0] - LineSegmentStart[0];
+ var dyl = LineSegmentEnd[1] - LineSegmentStart[1];
+ var cross = dxc * dyl - dyc * dxl;
+ if (cross !== 0) {
+ return false;
+ }
+ if (Math.abs(dxl) >= Math.abs(dyl)) {
+ return dxl > 0 ? LineSegmentStart[0] <= Point[0] && Point[0] <= LineSegmentEnd[0] : LineSegmentEnd[0] <= Point[0] && Point[0] <= LineSegmentStart[0];
+ } else {
+ return dyl > 0 ? LineSegmentStart[1] <= Point[1] && Point[1] <= LineSegmentEnd[1] : LineSegmentEnd[1] <= Point[1] && Point[1] <= LineSegmentStart[1];
+ }
+}
+
+// // Remove this method when implemented to @turf/invariant
+// function getGeom(geojson) {
+// if (geojson.geometry) return geojson.geometry;
+// if (geojson.coordinates) return geojson;
+// throw new Error('geojson must be a feature or geometry object');
+// }
+
+// Remove this method when implemented to @turf/invariant
+function getGeomType(geojson) {
+ if (geojson.geometry) return geojson.geometry.type;
+ if (geojson.coordinates) return geojson.type;
+ throw new Error('geojson must be a feature or geometry object');
+}
diff --git a/packages/turf-boolean-touch/package.json b/packages/turf-boolean-touch/package.json
new file mode 100644
index 0000000000..c694e51fe2
--- /dev/null
+++ b/packages/turf-boolean-touch/package.json
@@ -0,0 +1,47 @@
+{
+ "name": "@turf/boolean-touch",
+ "version": "4.0.0",
+ "description": "turf boolean-touch module",
+ "main": "index.js",
+ "types": "index.d.ts",
+ "files": [
+ "index.js",
+ "index.d.ts"
+ ],
+ "scripts": {
+ "test": "node test.js",
+ "bench": "node bench.js"
+ },
+ "repository": {
+ "type": "git",
+ "url": "git://github.com/Turfjs/turf.git"
+ },
+ "keywords": [
+ "turf",
+ "touch",
+ "boolean",
+ "de-9im"
+ ],
+ "author": "Turf Authors",
+ "contributors": [
+ "Rowan Winsemius <@rowanwins>",
+ "Denis Carriere <@DenisCarriere>"
+ ],
+ "license": "MIT",
+ "bugs": {
+ "url": "/~https://github.com/Turfjs/turf/issues"
+ },
+ "homepage": "/~https://github.com/Turfjs/turf",
+ "devDependencies": {
+ "@turf/helpers": "^4.2.0",
+ "benchmark": "^2.1.4",
+ "tape": "^4.6.3"
+ },
+ "dependencies": {
+ "@turf/inside": "^4.2.0",
+ "@turf/invariant": "^4.2.0",
+ "@turf/line-overlap": "^4.2.0",
+ "@turf/polygon-to-linestring": "^4.2.0",
+ "deep-equal": "^1.0.1"
+ }
+}
diff --git a/packages/turf-boolean-touch/test.js b/packages/turf-boolean-touch/test.js
new file mode 100644
index 0000000000..4938b5877e
--- /dev/null
+++ b/packages/turf-boolean-touch/test.js
@@ -0,0 +1,55 @@
+const test = require('tape');
+const {point, lineString, polygon, multiPoint, multiLineString, multiPolygon} = require('@turf/helpers');
+const touch = require('./');
+
+test('turf-boolean-touch', t => {
+ const pt1 = point([1, 1]);
+ const pt2 = point([1, 4]);
+ const line1 = lineString([[1, 1], [1, 2], [1, 3], [1, 4]]);
+ const pointOnMiddleOfLine = point([1, 2]);
+ const pointNotOnLine = point([12, 12]);
+
+ t.equal(touch(pt1, line1), true, 'point on start vertice touches linestring');
+ t.equal(touch(pt2, line1), true, 'point on end vertice touches linestring');
+ t.equal(touch(pointOnMiddleOfLine, line1), false, 'point in the middle of vertices does not touch linestring');
+ t.equal(touch(pointNotOnLine, line1), false, 'point far away does not touch linestring');
+
+ const mp1 = multiPoint([[1, 1], [12, 12]]);
+ const mp2 = multiPoint([[1, 1], [1, 1.5]]);
+ const mp3 = multiPoint([[1, 1], [1, 4]]);
+
+ t.equal(touch(mp1, line1), true, 'Single multipoint on end of line returns true');
+ t.equal(touch(mp2, line1), false, 'Multiple points on line returns false');
+ t.equal(touch(mp3, line1), false, 'Points on start and end of line returns false');
+
+ const poly1 = polygon([[[1, 1], [1, 10], [10, 10], [10, 1], [1, 1]]]);
+
+ t.equal(touch(pt1, poly1), true, 'A point lies on the polygon boundary');
+ t.equal(touch(pointNotOnLine, poly1), false, 'A point does not lie on the polygon boundary');
+
+ t.equal(touch(mp1, poly1), true, 'A multipoint lies on the polygon boundary');
+ t.equal(touch(mp2, poly1), false, 'Multiple points that lie on the polygon boundary returns false');
+ t.equal(touch(mp3, poly1), false, 'A point from a Multipoint that falls inside the polygon boundary returns false');
+
+ // const multiline1 = multiLineString([[[1, 1], [1, 2], [1, 3], [1, 4]], [[2, 1], [2, 2], [2, 3], [2, 4]]]);
+ // const multiline2 = multiLineString([[[1, 1], [1, 2], [1, 3], [1, 4]], [[2, 1], [2, 2], [2, 3], [2, 4]]]);
+ // const multiline3 = multiLineString([[[2, 1], [2, 2], [2, 3], [2, 4]], [[3, 1], [3, 2], [3, 3], [3, 4]]]);
+
+ // t.equal(equal(multiline1, multiline2), true, 'MultiLines are equal');
+ // t.equal(equal(multiline1, multiline3), false, 'MultiLines are not equal');
+
+ // const poly2 = polygon([[[1, 1], [1, 2], [1, 3], [1, 4], [1, 1]]]);
+ // const poly3 = polygon([[[2, 1], [2, 2], [2, 3], [2, 4], [2, 1]]]);
+
+ // t.equal(equal(poly1, poly2), true, 'Polys are equal');
+ // t.equal(equal(poly1, poly3), false, 'Polys are not equal');
+
+ // const multipoly1 = multiPolygon([[[1, 1], [1, 2], [1, 3], [1, 4], [1, 1]], [[3, 1], [3, 2], [3, 3], [3, 4], [3, 1]]]);
+ // const multipoly2 = multiPolygon([[[1, 1], [1, 2], [1, 3], [1, 4], [1, 1]], [[3, 1], [3, 2], [3, 3], [3, 4], [3, 1]]]);
+ // const multipoly3 = multiPolygon([[[2, 1], [2, 2], [2, 3], [2, 4], [2, 1]], [[3, 1], [3, 2], [3, 3], [3, 4], [3, 1]]]);
+
+ // t.equal(equal(multipoly1, multipoly2), true, 'MultiPolys are equal');
+ // t.equal(equal(multipoly1, multipoly3), false, 'MultiPolys are not equal');
+
+ t.end();
+});
diff --git a/packages/turf-boolean-touch/yarn.lock b/packages/turf-boolean-touch/yarn.lock
new file mode 100644
index 0000000000..afd6e5cae7
--- /dev/null
+++ b/packages/turf-boolean-touch/yarn.lock
@@ -0,0 +1,282 @@
+# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
+# yarn lockfile v1
+
+
+"@turf/bbox@^3.10.5":
+ version "3.14.0"
+ resolved "https://registry.yarnpkg.com/@turf/bbox/-/bbox-3.14.0.tgz#cee5f396dde78aca9cede05e1122db18bc504635"
+ dependencies:
+ "@turf/meta" "^3.14.0"
+
+"@turf/helpers@^3.10.5":
+ version "3.13.0"
+ resolved "https://registry.yarnpkg.com/@turf/helpers/-/helpers-3.13.0.tgz#d06078a1464cf56cdb7ea624ea1e13a71b88b806"
+
+"@turf/helpers@^4.2.0", "@turf/helpers@^4.3.0":
+ version "4.3.0"
+ resolved "https://registry.yarnpkg.com/@turf/helpers/-/helpers-4.3.0.tgz#7b2f733aa0eb3ea1f07d467ac02ede00cc6cde0d"
+
+"@turf/inside@^4.2.0":
+ version "4.3.0"
+ resolved "https://registry.yarnpkg.com/@turf/inside/-/inside-4.3.0.tgz#ba06be5966a5ab31c1cabb9819241e0802422c45"
+ dependencies:
+ "@turf/invariant" "^4.3.0"
+
+"@turf/invariant@^4.2.0", "@turf/invariant@^4.3.0":
+ version "4.3.0"
+ resolved "https://registry.yarnpkg.com/@turf/invariant/-/invariant-4.3.0.tgz#5bd1ce6ae51b1229dc0dc7d09d973fabae49af89"
+
+"@turf/line-overlap@^4.2.0":
+ version "4.3.0"
+ resolved "https://registry.yarnpkg.com/@turf/line-overlap/-/line-overlap-4.3.0.tgz#f0572d3a3f536a35055d857099b5d1549cfd0074"
+ dependencies:
+ "@turf/helpers" "^4.3.0"
+ "@turf/invariant" "^4.3.0"
+ "@turf/line-segment" "^4.3.0"
+ "@turf/meta" "^4.3.0"
+ deep-equal "^1.0.1"
+ geojson-rbush "^1.0.1"
+
+"@turf/line-segment@^4.3.0":
+ version "4.3.0"
+ resolved "https://registry.yarnpkg.com/@turf/line-segment/-/line-segment-4.3.0.tgz#7835209227f3c0712ec549c6f51af72394c638ab"
+ dependencies:
+ "@turf/helpers" "^4.3.0"
+ "@turf/invariant" "^4.3.0"
+ "@turf/meta" "^4.3.0"
+
+"@turf/meta@^3.10.5", "@turf/meta@^3.14.0":
+ version "3.14.0"
+ resolved "https://registry.yarnpkg.com/@turf/meta/-/meta-3.14.0.tgz#8d3050c1a0f44bf406a633b6bd28c510f7bcee27"
+
+"@turf/meta@^4.3.0":
+ version "4.3.0"
+ resolved "https://registry.yarnpkg.com/@turf/meta/-/meta-4.3.0.tgz#eb11dd2c2511524258123767fe0f5c3bd963e8d7"
+
+"@turf/polygon-to-linestring@^4.2.0":
+ version "4.3.0"
+ resolved "https://registry.yarnpkg.com/@turf/polygon-to-linestring/-/polygon-to-linestring-4.3.0.tgz#a17c580fc403f2b136295853ca5fff0c981eb0a2"
+ dependencies:
+ "@turf/helpers" "^4.3.0"
+ "@turf/invariant" "^4.3.0"
+
+balanced-match@^0.4.1:
+ version "0.4.2"
+ resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-0.4.2.tgz#cb3f3e3c732dc0f01ee70b403f302e61d7709838"
+
+benchmark@^2.1.4:
+ version "2.1.4"
+ resolved "https://registry.yarnpkg.com/benchmark/-/benchmark-2.1.4.tgz#09f3de31c916425d498cc2ee565a0ebf3c2a5629"
+ dependencies:
+ lodash "^4.17.4"
+ platform "^1.3.3"
+
+brace-expansion@^1.1.7:
+ version "1.1.7"
+ resolved "https://registry.yarnpkg.com/brace-expansion/-/brace-expansion-1.1.7.tgz#3effc3c50e000531fb720eaff80f0ae8ef23cf59"
+ dependencies:
+ balanced-match "^0.4.1"
+ concat-map "0.0.1"
+
+concat-map@0.0.1:
+ version "0.0.1"
+ resolved "https://registry.yarnpkg.com/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b"
+
+deep-equal@^1.0.1, deep-equal@~1.0.1:
+ version "1.0.1"
+ resolved "https://registry.yarnpkg.com/deep-equal/-/deep-equal-1.0.1.tgz#f5d260292b660e084eff4cdbc9f08ad3247448b5"
+
+define-properties@^1.1.2:
+ version "1.1.2"
+ resolved "https://registry.yarnpkg.com/define-properties/-/define-properties-1.1.2.tgz#83a73f2fea569898fb737193c8f873caf6d45c94"
+ dependencies:
+ foreach "^2.0.5"
+ object-keys "^1.0.8"
+
+defined@~1.0.0:
+ version "1.0.0"
+ resolved "https://registry.yarnpkg.com/defined/-/defined-1.0.0.tgz#c98d9bcef75674188e110969151199e39b1fa693"
+
+es-abstract@^1.5.0:
+ version "1.7.0"
+ resolved "https://registry.yarnpkg.com/es-abstract/-/es-abstract-1.7.0.tgz#dfade774e01bfcd97f96180298c449c8623fb94c"
+ dependencies:
+ es-to-primitive "^1.1.1"
+ function-bind "^1.1.0"
+ is-callable "^1.1.3"
+ is-regex "^1.0.3"
+
+es-to-primitive@^1.1.1:
+ version "1.1.1"
+ resolved "https://registry.yarnpkg.com/es-to-primitive/-/es-to-primitive-1.1.1.tgz#45355248a88979034b6792e19bb81f2b7975dd0d"
+ dependencies:
+ is-callable "^1.1.1"
+ is-date-object "^1.0.1"
+ is-symbol "^1.0.1"
+
+for-each@~0.3.2:
+ version "0.3.2"
+ resolved "https://registry.yarnpkg.com/for-each/-/for-each-0.3.2.tgz#2c40450b9348e97f281322593ba96704b9abd4d4"
+ dependencies:
+ is-function "~1.0.0"
+
+foreach@^2.0.5:
+ version "2.0.5"
+ resolved "https://registry.yarnpkg.com/foreach/-/foreach-2.0.5.tgz#0bee005018aeb260d0a3af3ae658dd0136ec1b99"
+
+fs.realpath@^1.0.0:
+ version "1.0.0"
+ resolved "https://registry.yarnpkg.com/fs.realpath/-/fs.realpath-1.0.0.tgz#1504ad2523158caa40db4a2787cb01411994ea4f"
+
+function-bind@^1.0.2, function-bind@^1.1.0, function-bind@~1.1.0:
+ version "1.1.0"
+ resolved "https://registry.yarnpkg.com/function-bind/-/function-bind-1.1.0.tgz#16176714c801798e4e8f2cf7f7529467bb4a5771"
+
+geojson-rbush@^1.0.1:
+ version "1.0.1"
+ resolved "https://registry.yarnpkg.com/geojson-rbush/-/geojson-rbush-1.0.1.tgz#450559bc18457e725191ac9acbbe0a8b5e18ddae"
+ dependencies:
+ "@turf/bbox" "^3.10.5"
+ "@turf/helpers" "^3.10.5"
+ "@turf/meta" "^3.10.5"
+ rbush "^2.0.1"
+
+glob@~7.1.1:
+ version "7.1.2"
+ resolved "https://registry.yarnpkg.com/glob/-/glob-7.1.2.tgz#c19c9df9a028702d678612384a6552404c636d15"
+ dependencies:
+ fs.realpath "^1.0.0"
+ inflight "^1.0.4"
+ inherits "2"
+ minimatch "^3.0.4"
+ once "^1.3.0"
+ path-is-absolute "^1.0.0"
+
+has@^1.0.1, has@~1.0.1:
+ version "1.0.1"
+ resolved "https://registry.yarnpkg.com/has/-/has-1.0.1.tgz#8461733f538b0837c9361e39a9ab9e9704dc2f28"
+ dependencies:
+ function-bind "^1.0.2"
+
+inflight@^1.0.4:
+ version "1.0.6"
+ resolved "https://registry.yarnpkg.com/inflight/-/inflight-1.0.6.tgz#49bd6331d7d02d0c09bc910a1075ba8165b56df9"
+ dependencies:
+ once "^1.3.0"
+ wrappy "1"
+
+inherits@2, inherits@~2.0.3:
+ version "2.0.3"
+ resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.3.tgz#633c2c83e3da42a502f52466022480f4208261de"
+
+is-callable@^1.1.1, is-callable@^1.1.3:
+ version "1.1.3"
+ resolved "https://registry.yarnpkg.com/is-callable/-/is-callable-1.1.3.tgz#86eb75392805ddc33af71c92a0eedf74ee7604b2"
+
+is-date-object@^1.0.1:
+ version "1.0.1"
+ resolved "https://registry.yarnpkg.com/is-date-object/-/is-date-object-1.0.1.tgz#9aa20eb6aeebbff77fbd33e74ca01b33581d3a16"
+
+is-function@~1.0.0:
+ version "1.0.1"
+ resolved "https://registry.yarnpkg.com/is-function/-/is-function-1.0.1.tgz#12cfb98b65b57dd3d193a3121f5f6e2f437602b5"
+
+is-regex@^1.0.3:
+ version "1.0.4"
+ resolved "https://registry.yarnpkg.com/is-regex/-/is-regex-1.0.4.tgz#5517489b547091b0930e095654ced25ee97e9491"
+ dependencies:
+ has "^1.0.1"
+
+is-symbol@^1.0.1:
+ version "1.0.1"
+ resolved "https://registry.yarnpkg.com/is-symbol/-/is-symbol-1.0.1.tgz#3cc59f00025194b6ab2e38dbae6689256b660572"
+
+lodash@^4.17.4:
+ version "4.17.4"
+ resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.4.tgz#78203a4d1c328ae1d86dca6460e369b57f4055ae"
+
+minimatch@^3.0.4:
+ version "3.0.4"
+ resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.0.4.tgz#5166e286457f03306064be5497e8dbb0c3d32083"
+ dependencies:
+ brace-expansion "^1.1.7"
+
+minimist@~1.2.0:
+ version "1.2.0"
+ resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.0.tgz#a35008b20f41383eec1fb914f4cd5df79a264284"
+
+object-inspect@~1.2.1:
+ version "1.2.2"
+ resolved "https://registry.yarnpkg.com/object-inspect/-/object-inspect-1.2.2.tgz#c82115e4fcc888aea14d64c22e4f17f6a70d5e5a"
+
+object-keys@^1.0.8:
+ version "1.0.11"
+ resolved "https://registry.yarnpkg.com/object-keys/-/object-keys-1.0.11.tgz#c54601778ad560f1142ce0e01bcca8b56d13426d"
+
+once@^1.3.0:
+ version "1.4.0"
+ resolved "https://registry.yarnpkg.com/once/-/once-1.4.0.tgz#583b1aa775961d4b113ac17d9c50baef9dd76bd1"
+ dependencies:
+ wrappy "1"
+
+path-is-absolute@^1.0.0:
+ version "1.0.1"
+ resolved "https://registry.yarnpkg.com/path-is-absolute/-/path-is-absolute-1.0.1.tgz#174b9268735534ffbc7ace6bf53a5a9e1b5c5f5f"
+
+platform@^1.3.3:
+ version "1.3.4"
+ resolved "https://registry.yarnpkg.com/platform/-/platform-1.3.4.tgz#6f0fb17edaaa48f21442b3a975c063130f1c3ebd"
+
+quickselect@^1.0.0:
+ version "1.0.0"
+ resolved "https://registry.yarnpkg.com/quickselect/-/quickselect-1.0.0.tgz#02630818f9aae4ecab26f0103f98d061c17c58f3"
+
+rbush@^2.0.1:
+ version "2.0.1"
+ resolved "https://registry.yarnpkg.com/rbush/-/rbush-2.0.1.tgz#4cfaca28c3064bc0ee75431a1b79990e875eefa9"
+ dependencies:
+ quickselect "^1.0.0"
+
+resolve@~1.1.7:
+ version "1.1.7"
+ resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.1.7.tgz#203114d82ad2c5ed9e8e0411b3932875e889e97b"
+
+resumer@~0.0.0:
+ version "0.0.0"
+ resolved "https://registry.yarnpkg.com/resumer/-/resumer-0.0.0.tgz#f1e8f461e4064ba39e82af3cdc2a8c893d076759"
+ dependencies:
+ through "~2.3.4"
+
+string.prototype.trim@~1.1.2:
+ version "1.1.2"
+ resolved "https://registry.yarnpkg.com/string.prototype.trim/-/string.prototype.trim-1.1.2.tgz#d04de2c89e137f4d7d206f086b5ed2fae6be8cea"
+ dependencies:
+ define-properties "^1.1.2"
+ es-abstract "^1.5.0"
+ function-bind "^1.0.2"
+
+tape@^4.6.3:
+ version "4.6.3"
+ resolved "https://registry.yarnpkg.com/tape/-/tape-4.6.3.tgz#637e77581e9ab2ce17577e9bd4ce4f575806d8b6"
+ dependencies:
+ deep-equal "~1.0.1"
+ defined "~1.0.0"
+ for-each "~0.3.2"
+ function-bind "~1.1.0"
+ glob "~7.1.1"
+ has "~1.0.1"
+ inherits "~2.0.3"
+ minimist "~1.2.0"
+ object-inspect "~1.2.1"
+ resolve "~1.1.7"
+ resumer "~0.0.0"
+ string.prototype.trim "~1.1.2"
+ through "~2.3.8"
+
+through@~2.3.4, through@~2.3.8:
+ version "2.3.8"
+ resolved "https://registry.yarnpkg.com/through/-/through-2.3.8.tgz#0dd4c9ffaabc357960b1b724115d7e0e86a2e1f5"
+
+wrappy@1:
+ version "1.0.2"
+ resolved "https://registry.yarnpkg.com/wrappy/-/wrappy-1.0.2.tgz#b5243d8f3ec1aa35f1364605bc0d1036e30ab69f"
diff --git a/packages/turf-boolean-within/LICENSE b/packages/turf-boolean-within/LICENSE
new file mode 100644
index 0000000000..96ce51b76f
--- /dev/null
+++ b/packages/turf-boolean-within/LICENSE
@@ -0,0 +1,20 @@
+The MIT License (MIT)
+
+Copyright (c) 2017 TurfJS
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of
+this software and associated documentation files (the "Software"), to deal in
+the Software without restriction, including without limitation the rights to
+use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
+the Software, and to permit persons to whom the Software is furnished to do so,
+subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
+FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
+COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
diff --git a/packages/turf-boolean-within/README.md b/packages/turf-boolean-within/README.md
new file mode 100644
index 0000000000..16179a1fef
--- /dev/null
+++ b/packages/turf-boolean-within/README.md
@@ -0,0 +1,94 @@
+# @turf/boolean-within
+
+# within
+
+Within returns True if the first geometry is completely within the second geometry.
+
+**Parameters**
+
+- `feature1` **([Geometry](http://geojson.org/geojson-spec.html#geometry) \| [Feature](http://geojson.org/geojson-spec.html#feature-objects)<any>)** GeoJSON Feature or Geometry
+- `feature2` **([Geometry](http://geojson.org/geojson-spec.html#geometry) \| [Feature](http://geojson.org/geojson-spec.html#feature-objects)<any>)** GeoJSON Feature or Geometry
+
+**Examples**
+
+```javascript
+const point = {
+ "type": "Feature",
+ "properties": {},
+ "geometry": {
+ "type": "Point",
+ "coordinates": [1, 1]
+ }
+}
+const line = {
+ "type": "Feature",
+ "properties": {},
+ "geometry": {
+ "type": "LineString",
+ "coordinates": [[1, 1], [1, 2], [1, 3], [1, 4]]
+ }
+}
+var within = turf.within(point, line);
+//=true
+```
+
+Returns **[Boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** true/false
+
+# contains
+
+Contains returns True if the second geometry is completely contained by the first geometry.
+
+**Parameters**
+
+- `feature1` **([Geometry](http://geojson.org/geojson-spec.html#geometry) \| [Feature](http://geojson.org/geojson-spec.html#feature-objects)<any>)** GeoJSON Feature or Geometry
+- `feature2` **([Geometry](http://geojson.org/geojson-spec.html#geometry) \| [Feature](http://geojson.org/geojson-spec.html#feature-objects)<any>)** GeoJSON Feature or Geometry
+
+**Examples**
+
+```javascript
+const point = {
+ "type": "Feature",
+ "properties": {},
+ "geometry": {
+ "type": "Point",
+ "coordinates": [1, 1]
+ }
+}
+const line = {
+ "type": "Feature",
+ "properties": {},
+ "geometry": {
+ "type": "LineString",
+ "coordinates": [[1, 1], [1, 2], [1, 3], [1, 4]]
+ }
+}
+turf.contains(line, point);
+//=true
+```
+
+Returns **[Boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** true/false
+
+
+
+---
+
+This module is part of the [Turfjs project](http://turfjs.org/), an open source
+module collection dedicated to geographic algorithms. It is maintained in the
+[Turfjs/turf](/~https://github.com/Turfjs/turf) repository, where you can create
+PRs and issues.
+
+### Installation
+
+Install this module individually:
+
+```sh
+$ npm install @turf/boolean-within
+```
+
+Or install the Turf module that includes it as a function:
+
+```sh
+$ npm install @turf/turf
+```
diff --git a/packages/turf-boolean-within/bench.js b/packages/turf-boolean-within/bench.js
new file mode 100644
index 0000000000..056e70ce61
--- /dev/null
+++ b/packages/turf-boolean-within/bench.js
@@ -0,0 +1,28 @@
+const Benchmark = require('benchmark');
+const {point, lineString, polygon} = require('@turf/helpers');
+const within = require('./');
+
+// Fixtures
+const pt = point([1, 1]);
+const line = lineString([[1, 1], [1, 2], [1, 3], [1, 4]]);
+const poly = polygon([[[1, 1], [1, 10], [10, 10], [10, 1], [1, 1]]]);
+
+/**
+ * Benchmark Results
+ *
+ * point - line x 10,269,477 ops/sec ±12.73% (73 runs sampled)
+ * point - polygon:
+ * point - point x 13,973,421 ops/sec ±8.59% (79 runs sampled)
+ * polygon - polygon x 634,618 ops/sec ±2.27% (87 runs sampled)
+ * line - line x 22,409 ops/sec ±3.44% (76 runs sampled)
+ */
+const suite = new Benchmark.Suite('turf-boolean-within');
+suite
+ .add('point - line', () => within(pt, line))
+ .add('point - polygon', () => within(pt, polygon))
+ .add('point - point', () => within(pt, pt))
+ .add('polygon - polygon', () => within(poly, poly))
+ .add('line - line', () => within(line, line))
+ .on('cycle', e => console.log(String(e.target)))
+ .on('complete', () => {})
+ .run();
diff --git a/packages/turf-boolean-within/index.d.ts b/packages/turf-boolean-within/index.d.ts
new file mode 100644
index 0000000000..2678551a50
--- /dev/null
+++ b/packages/turf-boolean-within/index.d.ts
@@ -0,0 +1,10 @@
+///
+
+type Feature = GeoJSON.Feature | GeoJSON.GeometryObject;
+
+/**
+ * http://turfjs.org/docs/#boolean-within
+ */
+declare function within(feature1: Feature, feature2: Feature): boolean;
+declare namespace within { }
+export = within;
diff --git a/packages/turf-boolean-within/index.js b/packages/turf-boolean-within/index.js
new file mode 100644
index 0000000000..70ee09db7c
--- /dev/null
+++ b/packages/turf-boolean-within/index.js
@@ -0,0 +1,32 @@
+var contains = require('../turf-boolean-contains');
+
+/**
+ * Within returns True if the first geometry is completely within the second geometry.
+ *
+ * @name within
+ * @param {Geometry|Feature} feature1 GeoJSON Feature or Geometry
+ * @param {Geometry|Feature} feature2 GeoJSON Feature or Geometry
+ * @returns {Boolean} true/false
+ * @example
+ * const point = {
+ * "type": "Feature",
+ * "properties": {},
+ * "geometry": {
+ * "type": "Point",
+ * "coordinates": [1, 1]
+ * }
+ * }
+ * const line = {
+ * "type": "Feature",
+ * "properties": {},
+ * "geometry": {
+ * "type": "LineString",
+ * "coordinates": [[1, 1], [1, 2], [1, 3], [1, 4]]
+ * }
+ * }
+ * var within = turf.within(point, line);
+ * //=true
+ */
+module.exports = function (feature1, feature2) {
+ return contains(feature2, feature1);
+};
diff --git a/packages/turf-boolean-within/package.json b/packages/turf-boolean-within/package.json
new file mode 100644
index 0000000000..112bc66dab
--- /dev/null
+++ b/packages/turf-boolean-within/package.json
@@ -0,0 +1,41 @@
+{
+ "name": "@turf/boolean-within",
+ "version": "4.0.0",
+ "description": "turf boolean-within module",
+ "main": "index.js",
+ "types": "index.d.ts",
+ "files": [
+ "index.js",
+ "index.d.ts"
+ ],
+ "scripts": {
+ "test": "node test.js",
+ "bench": "node bench.js"
+ },
+ "repository": {
+ "type": "git",
+ "url": "git://github.com/Turfjs/turf.git"
+ },
+ "keywords": [
+ "turf",
+ "within",
+ "boolean",
+ "de-9im"
+ ],
+ "author": "Turf Authors",
+ "contributors": [
+ "Rowan Winsemius <@rowanwins>",
+ "Denis Carriere <@DenisCarriere>"
+ ],
+ "license": "MIT",
+ "bugs": {
+ "url": "/~https://github.com/Turfjs/turf/issues"
+ },
+ "homepage": "/~https://github.com/Turfjs/turf",
+ "devDependencies": {
+ "@turf/helpers": "^4.2.0",
+ "benchmark": "^2.1.4",
+ "tape": "^4.6.3"
+ },
+ "dependencies": {}
+}
diff --git a/packages/turf-boolean-within/test.js b/packages/turf-boolean-within/test.js
new file mode 100644
index 0000000000..ab33ad41e6
--- /dev/null
+++ b/packages/turf-boolean-within/test.js
@@ -0,0 +1,55 @@
+const test = require('tape');
+const helpers = require('@turf/helpers');
+const within = require('./');
+
+test('turf-boolean-within', t => {
+ const pt1 = helpers.point([1, 1]);
+ const pt2 = helpers.point([1, 4]);
+ const pt3 = helpers.point([4, 4]);
+ const pt4 = helpers.point([14, 14]);
+
+ const mp1 = helpers.multiPoint([[1, 1], [12, 12]]);
+ const mp2 = helpers.multiPoint([[1, 1], [1, 1.5]]);
+ const mp3 = helpers.multiPoint([[1, 1], [12, 12], [15, 15]]);
+
+ t.equal(within(pt1, mp1), true, 'Point is contained within multipoint');
+ t.equal(within(pt2, mp1), false, 'Point is not contained outside multipoint');
+
+ t.equal(within(mp1, mp3), true, 'True if all multipoints are contained with within multipoints');
+ t.equal(within(mp2, mp3), false, 'False if some multipoints are elsewhere');
+
+ const line1 = helpers.lineString([[1, 1], [1, 2], [1, 3], [1, 4]]);
+ t.equal(within(pt1, line1), true, 'Point is on line');
+ t.equal(within(pt3, line1), false, 'Point is not on line');
+
+ t.equal(within(mp2, line1), true, 'MultiPoint is on line');
+ t.equal(within(mp3, line1), false, 'MultiPoint is not on line');
+
+ const poly1 = helpers.polygon([[[1, 1], [1, 10], [10, 10], [10, 1], [1, 1]]]);
+ t.equal(within(pt3, poly1), true, 'A point lies inside the polygon boundary');
+ t.equal(within(pt1, poly1), true, 'A point lies on the polygon boundary');
+ t.equal(within(pt4, poly1), false, 'A point lies outside the polygon boundary fails');
+
+ const mp4 = helpers.multiPoint([[1, 1], [4, 4]]);
+ t.equal(within(mp4, poly1), true, 'A multipoint lies inside the polygon boundary');
+ t.equal(within(mp1, poly1), false, 'A multipoint with a point outside fails');
+
+
+ const line2 = helpers.lineString([[1, 2], [1, 3], [1, 3.5]]);
+ const line3 = helpers.lineString([[1, 2], [1, 3], [1, 15.5]]);
+
+ t.equal(within(line2, line1), true, 'A line lies inside the other line');
+ t.skip(within(line3, line1), false, 'A line fails that lies partially outside the other line');
+
+ t.equal(within(line1, poly1), true, 'A line within the poly passes as true');
+ t.equal(within(line3, poly1), false, 'A line that lies partially outside the poly is false');
+
+
+ const poly2 = helpers.polygon([[[1, 1], [1, 2], [1, 3], [1, 4], [1, 1]]]);
+ const poly3 = helpers.polygon([[[1, 1], [1, 20], [1, 3], [1, 4], [1, 1]]]);
+
+ t.equal(within(poly2, poly1), true, 'A poly passes that is inside although allows touching edges');
+ t.equal(within(poly3, poly1), false, 'A poly fails that has a vertice outside the poly');
+
+ t.end();
+});
diff --git a/packages/turf-boolean-within/yarn.lock b/packages/turf-boolean-within/yarn.lock
new file mode 100644
index 0000000000..47a108a86f
--- /dev/null
+++ b/packages/turf-boolean-within/yarn.lock
@@ -0,0 +1,209 @@
+# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
+# yarn lockfile v1
+
+
+"@turf/helpers@^4.2.0":
+ version "4.3.0"
+ resolved "https://registry.yarnpkg.com/@turf/helpers/-/helpers-4.3.0.tgz#7b2f733aa0eb3ea1f07d467ac02ede00cc6cde0d"
+
+balanced-match@^0.4.1:
+ version "0.4.2"
+ resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-0.4.2.tgz#cb3f3e3c732dc0f01ee70b403f302e61d7709838"
+
+benchmark@^2.1.4:
+ version "2.1.4"
+ resolved "https://registry.yarnpkg.com/benchmark/-/benchmark-2.1.4.tgz#09f3de31c916425d498cc2ee565a0ebf3c2a5629"
+ dependencies:
+ lodash "^4.17.4"
+ platform "^1.3.3"
+
+brace-expansion@^1.1.7:
+ version "1.1.7"
+ resolved "https://registry.yarnpkg.com/brace-expansion/-/brace-expansion-1.1.7.tgz#3effc3c50e000531fb720eaff80f0ae8ef23cf59"
+ dependencies:
+ balanced-match "^0.4.1"
+ concat-map "0.0.1"
+
+concat-map@0.0.1:
+ version "0.0.1"
+ resolved "https://registry.yarnpkg.com/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b"
+
+deep-equal@~1.0.1:
+ version "1.0.1"
+ resolved "https://registry.yarnpkg.com/deep-equal/-/deep-equal-1.0.1.tgz#f5d260292b660e084eff4cdbc9f08ad3247448b5"
+
+define-properties@^1.1.2:
+ version "1.1.2"
+ resolved "https://registry.yarnpkg.com/define-properties/-/define-properties-1.1.2.tgz#83a73f2fea569898fb737193c8f873caf6d45c94"
+ dependencies:
+ foreach "^2.0.5"
+ object-keys "^1.0.8"
+
+defined@~1.0.0:
+ version "1.0.0"
+ resolved "https://registry.yarnpkg.com/defined/-/defined-1.0.0.tgz#c98d9bcef75674188e110969151199e39b1fa693"
+
+es-abstract@^1.5.0:
+ version "1.7.0"
+ resolved "https://registry.yarnpkg.com/es-abstract/-/es-abstract-1.7.0.tgz#dfade774e01bfcd97f96180298c449c8623fb94c"
+ dependencies:
+ es-to-primitive "^1.1.1"
+ function-bind "^1.1.0"
+ is-callable "^1.1.3"
+ is-regex "^1.0.3"
+
+es-to-primitive@^1.1.1:
+ version "1.1.1"
+ resolved "https://registry.yarnpkg.com/es-to-primitive/-/es-to-primitive-1.1.1.tgz#45355248a88979034b6792e19bb81f2b7975dd0d"
+ dependencies:
+ is-callable "^1.1.1"
+ is-date-object "^1.0.1"
+ is-symbol "^1.0.1"
+
+for-each@~0.3.2:
+ version "0.3.2"
+ resolved "https://registry.yarnpkg.com/for-each/-/for-each-0.3.2.tgz#2c40450b9348e97f281322593ba96704b9abd4d4"
+ dependencies:
+ is-function "~1.0.0"
+
+foreach@^2.0.5:
+ version "2.0.5"
+ resolved "https://registry.yarnpkg.com/foreach/-/foreach-2.0.5.tgz#0bee005018aeb260d0a3af3ae658dd0136ec1b99"
+
+fs.realpath@^1.0.0:
+ version "1.0.0"
+ resolved "https://registry.yarnpkg.com/fs.realpath/-/fs.realpath-1.0.0.tgz#1504ad2523158caa40db4a2787cb01411994ea4f"
+
+function-bind@^1.0.2, function-bind@^1.1.0, function-bind@~1.1.0:
+ version "1.1.0"
+ resolved "https://registry.yarnpkg.com/function-bind/-/function-bind-1.1.0.tgz#16176714c801798e4e8f2cf7f7529467bb4a5771"
+
+glob@~7.1.1:
+ version "7.1.2"
+ resolved "https://registry.yarnpkg.com/glob/-/glob-7.1.2.tgz#c19c9df9a028702d678612384a6552404c636d15"
+ dependencies:
+ fs.realpath "^1.0.0"
+ inflight "^1.0.4"
+ inherits "2"
+ minimatch "^3.0.4"
+ once "^1.3.0"
+ path-is-absolute "^1.0.0"
+
+has@^1.0.1, has@~1.0.1:
+ version "1.0.1"
+ resolved "https://registry.yarnpkg.com/has/-/has-1.0.1.tgz#8461733f538b0837c9361e39a9ab9e9704dc2f28"
+ dependencies:
+ function-bind "^1.0.2"
+
+inflight@^1.0.4:
+ version "1.0.6"
+ resolved "https://registry.yarnpkg.com/inflight/-/inflight-1.0.6.tgz#49bd6331d7d02d0c09bc910a1075ba8165b56df9"
+ dependencies:
+ once "^1.3.0"
+ wrappy "1"
+
+inherits@2, inherits@~2.0.3:
+ version "2.0.3"
+ resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.3.tgz#633c2c83e3da42a502f52466022480f4208261de"
+
+is-callable@^1.1.1, is-callable@^1.1.3:
+ version "1.1.3"
+ resolved "https://registry.yarnpkg.com/is-callable/-/is-callable-1.1.3.tgz#86eb75392805ddc33af71c92a0eedf74ee7604b2"
+
+is-date-object@^1.0.1:
+ version "1.0.1"
+ resolved "https://registry.yarnpkg.com/is-date-object/-/is-date-object-1.0.1.tgz#9aa20eb6aeebbff77fbd33e74ca01b33581d3a16"
+
+is-function@~1.0.0:
+ version "1.0.1"
+ resolved "https://registry.yarnpkg.com/is-function/-/is-function-1.0.1.tgz#12cfb98b65b57dd3d193a3121f5f6e2f437602b5"
+
+is-regex@^1.0.3:
+ version "1.0.4"
+ resolved "https://registry.yarnpkg.com/is-regex/-/is-regex-1.0.4.tgz#5517489b547091b0930e095654ced25ee97e9491"
+ dependencies:
+ has "^1.0.1"
+
+is-symbol@^1.0.1:
+ version "1.0.1"
+ resolved "https://registry.yarnpkg.com/is-symbol/-/is-symbol-1.0.1.tgz#3cc59f00025194b6ab2e38dbae6689256b660572"
+
+lodash@^4.17.4:
+ version "4.17.4"
+ resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.4.tgz#78203a4d1c328ae1d86dca6460e369b57f4055ae"
+
+minimatch@^3.0.4:
+ version "3.0.4"
+ resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.0.4.tgz#5166e286457f03306064be5497e8dbb0c3d32083"
+ dependencies:
+ brace-expansion "^1.1.7"
+
+minimist@~1.2.0:
+ version "1.2.0"
+ resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.0.tgz#a35008b20f41383eec1fb914f4cd5df79a264284"
+
+object-inspect@~1.2.1:
+ version "1.2.2"
+ resolved "https://registry.yarnpkg.com/object-inspect/-/object-inspect-1.2.2.tgz#c82115e4fcc888aea14d64c22e4f17f6a70d5e5a"
+
+object-keys@^1.0.8:
+ version "1.0.11"
+ resolved "https://registry.yarnpkg.com/object-keys/-/object-keys-1.0.11.tgz#c54601778ad560f1142ce0e01bcca8b56d13426d"
+
+once@^1.3.0:
+ version "1.4.0"
+ resolved "https://registry.yarnpkg.com/once/-/once-1.4.0.tgz#583b1aa775961d4b113ac17d9c50baef9dd76bd1"
+ dependencies:
+ wrappy "1"
+
+path-is-absolute@^1.0.0:
+ version "1.0.1"
+ resolved "https://registry.yarnpkg.com/path-is-absolute/-/path-is-absolute-1.0.1.tgz#174b9268735534ffbc7ace6bf53a5a9e1b5c5f5f"
+
+platform@^1.3.3:
+ version "1.3.4"
+ resolved "https://registry.yarnpkg.com/platform/-/platform-1.3.4.tgz#6f0fb17edaaa48f21442b3a975c063130f1c3ebd"
+
+resolve@~1.1.7:
+ version "1.1.7"
+ resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.1.7.tgz#203114d82ad2c5ed9e8e0411b3932875e889e97b"
+
+resumer@~0.0.0:
+ version "0.0.0"
+ resolved "https://registry.yarnpkg.com/resumer/-/resumer-0.0.0.tgz#f1e8f461e4064ba39e82af3cdc2a8c893d076759"
+ dependencies:
+ through "~2.3.4"
+
+string.prototype.trim@~1.1.2:
+ version "1.1.2"
+ resolved "https://registry.yarnpkg.com/string.prototype.trim/-/string.prototype.trim-1.1.2.tgz#d04de2c89e137f4d7d206f086b5ed2fae6be8cea"
+ dependencies:
+ define-properties "^1.1.2"
+ es-abstract "^1.5.0"
+ function-bind "^1.0.2"
+
+tape@^4.6.3:
+ version "4.6.3"
+ resolved "https://registry.yarnpkg.com/tape/-/tape-4.6.3.tgz#637e77581e9ab2ce17577e9bd4ce4f575806d8b6"
+ dependencies:
+ deep-equal "~1.0.1"
+ defined "~1.0.0"
+ for-each "~0.3.2"
+ function-bind "~1.1.0"
+ glob "~7.1.1"
+ has "~1.0.1"
+ inherits "~2.0.3"
+ minimist "~1.2.0"
+ object-inspect "~1.2.1"
+ resolve "~1.1.7"
+ resumer "~0.0.0"
+ string.prototype.trim "~1.1.2"
+ through "~2.3.8"
+
+through@~2.3.4, through@~2.3.8:
+ version "2.3.8"
+ resolved "https://registry.yarnpkg.com/through/-/through-2.3.8.tgz#0dd4c9ffaabc357960b1b724115d7e0e86a2e1f5"
+
+wrappy@1:
+ version "1.0.2"
+ resolved "https://registry.yarnpkg.com/wrappy/-/wrappy-1.0.2.tgz#b5243d8f3ec1aa35f1364605bc0d1036e30ab69f"
diff --git a/packages/turf-buffer/bench.js b/packages/turf-buffer/bench.js
index bdce1d252b..f8d60d8511 100644
--- a/packages/turf-buffer/bench.js
+++ b/packages/turf-buffer/bench.js
@@ -16,12 +16,25 @@ const fixtures = fs.readdirSync(directory).map(filename => {
/**
* Benchmark Results
*
- * feature-collection-points x 1,205 ops/sec ±11.92% (72 runs sampled)
- * geometry-collection-points x 2,102 ops/sec ±4.49% (78 runs sampled)
- * linestring x 3,434 ops/sec ±3.17% (80 runs sampled)
- * multi-linestring x 675 ops/sec ±2.89% (85 runs sampled)
- * multi-point x 2,077 ops/sec ±5.69% (73 runs sampled)
- * multi-polygon x 1,120 ops/sec ±5.97% (80 runs sampled)
+ * feature-collection-points: 139.101ms
+ * geometry-collection-points: 20.334ms
+ * issue-#783: 33.209ms
+ * linestring: 6.371ms
+ * multi-linestring: 48.786ms
+ * multi-point: 7.627ms
+ * multi-polygon: 38.921ms
+ * negative-buffer: 5.621ms
+ * north-latitude-points: 71.144ms
+ * northern-polygon: 2.644ms
+ * point: 8.155ms
+ * polygon-with-holes: 6.965ms
+ * feature-collection-points x 722 ops/sec ±14.28% (65 runs sampled)
+ * geometry-collection-points x 1,314 ops/sec ±7.87% (66 runs sampled)
+ * issue-#783 x 1,404 ops/sec ±6.81% (64 runs sampled)
+ * linestring x 2,936 ops/sec ±6.94% (72 runs sampled)
+ * multi-linestring x 623 ops/sec ±4.35% (79 runs sampled)
+ * multi-point x 1,735 ops/sec ±8.60% (65 runs sampled)
+ * multi-polygon x 1,125 ops/sec ±3.93% (80 runs sampled)
* north-latitude-points x 1,649 ops/sec ±2.09% (86 runs sampled)
* northern-polygon x 4,658 ops/sec ±3.08% (78 runs sampled)
* point x 65,020 ops/sec ±1.29% (85 runs sampled)
@@ -29,6 +42,9 @@ const fixtures = fs.readdirSync(directory).map(filename => {
*/
const suite = new Benchmark.Suite('turf-buffer');
for (const {name, geojson} of fixtures) {
+ console.time(name);
+ buffer(geojson, 50, 'miles');
+ console.timeEnd(name);
suite.add(name, () => buffer(geojson, 50, 'miles'));
}
diff --git a/packages/turf-buffer/index.js b/packages/turf-buffer/index.js
index 79b84acdfd..7ad1fa91ec 100644
--- a/packages/turf-buffer/index.js
+++ b/packages/turf-buffer/index.js
@@ -1,7 +1,6 @@
var d3 = require('d3-geo');
var jsts = require('jsts');
var meta = require('@turf/meta');
-var circle = require('@turf/circle');
var center = require('@turf/center');
var helpers = require('@turf/helpers');
var feature = helpers.feature;
@@ -93,8 +92,6 @@ function buffer(geojson, radius, units, steps) {
// Geometry Types faster than jsts
switch (geometry.type) {
- case 'Point':
- return circle(geometry.coordinates, radius, steps, units, properties);
case 'GeometryCollection':
var results = [];
geomEach(geojson, function (geometry) {
diff --git a/packages/turf-buffer/package.json b/packages/turf-buffer/package.json
index d37fd53d4c..30440d23b2 100644
--- a/packages/turf-buffer/package.json
+++ b/packages/turf-buffer/package.json
@@ -1,6 +1,6 @@
{
"name": "@turf/buffer",
- "version": "4.3.1",
+ "version": "4.4.0",
"description": "turf buffer module",
"main": "index.js",
"types": "index.d.ts",
@@ -36,17 +36,16 @@
},
"homepage": "/~https://github.com/Turfjs/turf",
"devDependencies": {
- "@turf/truncate": "^4.3.0",
+ "@turf/truncate": "^4.4.0",
"benchmark": "^2.1.4",
"load-json-file": "^2.0.0",
"tape": "^4.6.3",
"write-json-file": "^2.0.0"
},
"dependencies": {
- "@turf/center": "^4.3.0",
- "@turf/circle": "^4.3.0",
- "@turf/helpers": "^4.3.0",
- "@turf/meta": "^4.3.0",
+ "@turf/center": "^4.4.0",
+ "@turf/helpers": "^4.4.0",
+ "@turf/meta": "^4.4.0",
"d3-geo": "^1.6.3",
"jsts": "1.3.0"
}
diff --git a/packages/turf-buffer/test/in/feature-collection-points.geojson b/packages/turf-buffer/test/in/feature-collection-points.geojson
index 0b57ac27db..4222c3badb 100644
--- a/packages/turf-buffer/test/in/feature-collection-points.geojson
+++ b/packages/turf-buffer/test/in/feature-collection-points.geojson
@@ -3,7 +3,9 @@
"features": [
{
"type": "Feature",
- "properties": {},
+ "properties": {
+ "marker-color": "#F00"
+ },
"geometry": {
"type": "MultiPoint",
"coordinates": [
@@ -28,7 +30,9 @@
},
{
"type": "Feature",
- "properties": {},
+ "properties": {
+ "marker-color": "#0F0"
+ },
"geometry": {
"type": "Point",
"coordinates": [
@@ -39,7 +43,9 @@
},
{
"type": "Feature",
- "properties": {},
+ "properties": {
+ "marker-color": "#00F"
+ },
"geometry": {
"type": "Point",
"coordinates": [
diff --git a/packages/turf-buffer/test/in/issue-#783.geojson b/packages/turf-buffer/test/in/issue-#783.geojson
new file mode 100644
index 0000000000..b9bc80c4f8
--- /dev/null
+++ b/packages/turf-buffer/test/in/issue-#783.geojson
@@ -0,0 +1,70 @@
+{
+ "type": "FeatureCollection",
+ "properties": {
+ "radius": 25,
+ "units": "meters"
+ },
+ "features": [
+ {
+ "type": "Feature",
+ "properties": {},
+ "geometry": {
+ "type": "Polygon",
+ "coordinates": [
+ [
+ [
+ 4.946893,
+ 52.509638
+ ],
+ [
+ 4.947357,
+ 52.509492
+ ],
+ [
+ 4.947427,
+ 52.509472
+ ],
+ [
+ 4.947761,
+ 52.509428
+ ],
+ [
+ 4.947331,
+ 52.509564
+ ],
+ [
+ 4.946736,
+ 52.509714
+ ],
+ [
+ 4.946893,
+ 52.509638
+ ]
+ ]
+ ]
+ }
+ },
+ {
+ "type": "Feature",
+ "properties": {},
+ "geometry": {
+ "type": "Point",
+ "coordinates": [
+ 4.946736,
+ 52.509714
+ ]
+ }
+ },
+ {
+ "type": "Feature",
+ "properties": {},
+ "geometry": {
+ "type": "Point",
+ "coordinates": [
+ 4.947761,
+ 52.509428
+ ]
+ }
+ }
+ ]
+}
\ No newline at end of file
diff --git a/packages/turf-buffer/test/out/feature-collection-points.geojson b/packages/turf-buffer/test/out/feature-collection-points.geojson
index d8b590d01f..ee059ce237 100644
--- a/packages/turf-buffer/test/out/feature-collection-points.geojson
+++ b/packages/turf-buffer/test/out/feature-collection-points.geojson
@@ -4,9 +4,9 @@
{
"type": "Feature",
"properties": {
+ "marker-color": "#F00",
"stroke": "#F00",
"fill": "#F00",
- "marker-color": "#F00",
"fill-opacity": 0.3
},
"geometry": {
@@ -498,9 +498,9 @@
{
"type": "Feature",
"properties": {
+ "marker-color": "#F00",
"stroke": "#F00",
"fill": "#F00",
- "marker-color": "#F00",
"fill-opacity": 0.3
},
"geometry": {
@@ -508,264 +508,136 @@
"coordinates": [
[
[
- 130,
- -26.776568
- ],
- [
- 130.079426,
- -26.780029
- ],
- [
- 130.158101,
- -26.79038
- ],
- [
- 130.235283,
- -26.807522
- ],
- [
- 130.31024,
- -26.831293
- ],
- [
- 130.382262,
- -26.861469
- ],
- [
- 130.450666,
- -26.897764
- ],
- [
- 130.514799,
- -26.939834
- ],
- [
- 130.574048,
- -26.98728
- ],
- [
- 130.627845,
- -27.039652
- ],
- [
- 130.67567,
- -27.096453
- ],
- [
- 130.717059,
- -27.15714
- ],
- [
- 130.751607,
- -27.221137
- ],
- [
- 130.778972,
- -27.287831
- ],
- [
- 130.798879,
- -27.356585
- ],
- [
- 130.811123,
- -27.42674
- ],
- [
- 130.815572,
- -27.497623
- ],
- [
- 130.812168,
- -27.568551
- ],
- [
- 130.80093,
- -27.638841
- ],
- [
- 130.78195,
- -27.707815
- ],
- [
- 130.755398,
- -27.774805
- ],
- [
- 130.721516,
- -27.839161
- ],
- [
- 130.680623,
- -27.90026
- ],
- [
- 130.633103,
- -27.957506
- ],
- [
- 130.579409,
- -28.010342
- ],
- [
- 130.520057,
- -28.058252
+ 129.249007,
+ -27.370428
],
[
- 130.455619,
- -28.100769
+ 129.234463,
+ -27.502623
],
[
- 130.38672,
- -28.137474
+ 129.249152,
+ -27.634828
],
[
- 130.314031,
- -28.168011
+ 129.292639,
+ -27.762017
],
[
- 130.238261,
- -28.192078
+ 129.363395,
+ -27.879322
],
[
- 130.160153,
- -28.209439
+ 129.458831,
+ -27.98222
],
[
- 130.080472,
- -28.219925
+ 129.575375,
+ -28.066711
],
[
- 130,
- -28.223432
+ 129.708598,
+ -28.129474
],
[
- 129.919528,
- -28.219925
- ],
- [
- 129.839847,
- -28.209439
- ],
- [
- 129.761739,
- -28.192078
- ],
- [
- 129.685969,
+ 129.853373,
-28.168011
],
[
- 129.61328,
- -28.137474
- ],
- [
- 129.544381,
- -28.100769
- ],
- [
- 129.479943,
- -28.058252
- ],
- [
- 129.420591,
- -28.010342
+ 130.004071,
+ -28.180753
],
[
- 129.366897,
- -27.957506
+ 130.154795,
+ -28.167136
],
[
- 129.319377,
- -27.90026
+ 130.299615,
+ -28.127634
],
[
- 129.278484,
- -27.839161
+ 130.432823,
+ -28.063748
],
[
- 129.244602,
- -27.774805
+ 130.549174,
+ -27.97795
],
[
- 129.21805,
- -27.707815
+ 130.644106,
+ -27.873586
],
[
- 129.19907,
- -27.638841
+ 130.713928,
+ -27.754739
],
[
- 129.187832,
- -27.568551
+ 130.755972,
+ -27.626061
],
[
- 129.184428,
- -27.497623
+ 130.768686,
+ -27.492581
],
[
- 129.188877,
- -27.42674
+ 130.751689,
+ -27.359499
],
[
- 129.201121,
- -27.356585
+ 130.705765,
+ -27.231978
],
[
- 129.221028,
- -27.287831
+ 130.632815,
+ -27.114934
],
[
- 129.248393,
- -27.221137
+ 130.535762,
+ -27.012851
],
[
- 129.282941,
- -27.15714
+ 130.418423,
+ -26.929606
],
[
- 129.32433,
- -27.096453
+ 130.28535,
+ -26.868329
],
[
- 129.372155,
- -27.039652
- ],
- [
- 129.425952,
- -26.98728
+ 130.141647,
+ -26.831293
],
[
- 129.485201,
- -26.939834
+ 129.992778,
+ -26.819837
],
[
- 129.549334,
- -26.897764
+ 129.844364,
+ -26.83433
],
[
- 129.617738,
- -26.861469
+ 129.701982,
+ -26.874165
],
[
- 129.68976,
- -26.831293
+ 129.570968,
+ -26.937789
],
[
- 129.764717,
- -26.807522
+ 129.456234,
+ -27.022771
],
[
- 129.841899,
- -26.79038
+ 129.362095,
+ -27.125889
],
[
- 129.920574,
- -26.780029
+ 129.292122,
+ -27.24325
],
[
- 130,
- -26.776568
+ 129.249007,
+ -27.370428
]
]
]
@@ -774,9 +646,9 @@
{
"type": "Feature",
"properties": {
+ "marker-color": "#F00",
"stroke": "#F00",
"fill": "#F00",
- "marker-color": "#F00",
"fill-opacity": 0.3
},
"geometry": {
@@ -784,264 +656,136 @@
"coordinates": [
[
[
- 126,
- -23.776568
- ],
- [
- 126.077485,
- -23.780032
- ],
- [
- 126.154237,
- -23.790391
- ],
- [
- 126.229527,
- -23.807546
- ],
- [
- 126.302643,
- -23.831336
- ],
- [
- 126.372889,
- -23.861534
- ],
- [
- 126.439597,
- -23.897854
- ],
- [
- 126.502132,
- -23.939952
- ],
- [
- 126.559893,
- -23.987427
- ],
- [
- 126.612328,
- -24.039828
- ],
- [
- 126.658929,
- -24.096656
- ],
- [
- 126.699245,
- -24.157369
- ],
- [
- 126.732882,
- -24.221388
- ],
- [
- 126.759508,
- -24.288101
- ],
- [
- 126.778857,
- -24.356869
- ],
- [
- 126.790731,
- -24.427033
- ],
- [
- 126.795005,
- -24.497919
- ],
- [
- 126.791624,
- -24.568844
+ 125.310835,
+ -24.351129
],
[
- 126.780607,
- -24.639127
+ 125.291806,
+ -24.476
],
[
- 126.762049,
- -24.708087
+ 125.299747,
+ -24.601887
],
[
- 126.736116,
- -24.775059
+ 125.334463,
+ -24.724028
],
[
- 126.703049,
- -24.839393
+ 125.394754,
+ -24.837769
],
[
- 126.663155,
- -24.900466
+ 125.478437,
+ -24.938746
],
[
- 126.616814,
- -24.957685
+ 125.582408,
+ -25.023045
],
[
- 126.564468,
- -25.010492
+ 125.702751,
+ -25.087361
],
[
- 126.506618,
- -25.058373
+ 125.834865,
+ -25.129131
],
[
- 126.443824,
- -25.100861
+ 125.973646,
+ -25.146654
],
[
- 126.376693,
- -25.137541
+ 126.113684,
+ -25.139164
],
[
- 126.305878,
- -25.168055
+ 126.24948,
+ -25.106876
],
[
- 126.232069,
- -25.192103
+ 126.375682,
+ -25.050992
],
[
- 126.155988,
- -25.209451
+ 126.487306,
+ -24.973656
],
[
- 126.078378,
- -25.219928
+ 126.579952,
+ -24.877875
],
[
- 126,
- -25.223432
+ 126.64999,
+ -24.767396
],
[
- 125.921622,
- -25.219928
+ 126.694705,
+ -24.646553
],
[
- 125.844012,
- -25.209451
+ 126.712411,
+ -24.520086
],
[
- 125.767931,
- -25.192103
+ 126.702505,
+ -24.392945
],
[
- 125.694122,
- -25.168055
+ 126.665481,
+ -24.270084
],
[
- 125.623307,
- -25.137541
+ 126.60289,
+ -24.156265
],
[
- 125.556176,
- -25.100861
+ 126.517267,
+ -24.055866
],
[
- 125.493382,
- -25.058373
+ 126.412008,
+ -23.972712
],
[
- 125.435532,
- -25.010492
+ 126.291228,
+ -23.909934
],
[
- 125.383186,
- -24.957685
+ 126.159594,
+ -23.869859
],
[
- 125.336845,
- -24.900466
+ 126.022136,
+ -23.853933
],
[
- 125.296951,
- -24.839393
+ 125.884064,
+ -23.862677
],
[
- 125.263884,
- -24.775059
+ 125.750577,
+ -23.895686
],
[
- 125.237951,
- -24.708087
+ 125.626675,
+ -23.951647
],
[
- 125.219393,
- -24.639127
+ 125.516992,
+ -24.028405
],
[
- 125.208376,
- -24.568844
+ 125.425632,
+ -24.123041
],
[
- 125.204995,
- -24.497919
+ 125.356031,
+ -24.231982
],
[
- 125.209269,
- -24.427033
- ],
- [
- 125.221143,
- -24.356869
- ],
- [
- 125.240492,
- -24.288101
- ],
- [
- 125.267118,
- -24.221388
- ],
- [
- 125.300755,
- -24.157369
- ],
- [
- 125.341071,
- -24.096656
- ],
- [
- 125.387672,
- -24.039828
- ],
- [
- 125.440107,
- -23.987427
- ],
- [
- 125.497868,
- -23.939952
- ],
- [
- 125.560403,
- -23.897854
- ],
- [
- 125.627111,
- -23.861534
- ],
- [
- 125.697357,
- -23.831336
- ],
- [
- 125.770473,
- -23.807546
- ],
- [
- 125.845763,
- -23.790391
- ],
- [
- 125.922515,
- -23.780032
- ],
- [
- 126,
- -23.776568
+ 125.310835,
+ -24.351129
]
]
]
@@ -1050,9 +794,9 @@
{
"type": "Feature",
"properties": {
+ "marker-color": "#00F",
"stroke": "#00F",
"fill": "#00F",
- "marker-color": "#00F",
"fill-opacity": 0.3
},
"geometry": {
@@ -1080,9 +824,9 @@
{
"type": "Feature",
"properties": {
+ "marker-color": "#00F",
"stroke": "#00F",
"fill": "#00F",
- "marker-color": "#00F",
"fill-opacity": 0.3
},
"geometry": {
@@ -1096,9 +840,9 @@
{
"type": "Feature",
"properties": {
+ "marker-color": "#00F",
"stroke": "#00F",
"fill": "#00F",
- "marker-color": "#00F",
"fill-opacity": 0.3
},
"geometry": {
diff --git a/packages/turf-buffer/test/out/geometry-collection-points.geojson b/packages/turf-buffer/test/out/geometry-collection-points.geojson
index 9ac12c53cf..0ca49520fd 100644
--- a/packages/turf-buffer/test/out/geometry-collection-points.geojson
+++ b/packages/turf-buffer/test/out/geometry-collection-points.geojson
@@ -436,264 +436,136 @@
"coordinates": [
[
[
- 130,
- -26.776568
+ 129.249007,
+ -27.370428
],
[
- 130.079426,
- -26.780029
+ 129.234463,
+ -27.502623
],
[
- 130.158101,
- -26.79038
+ 129.249152,
+ -27.634828
],
[
- 130.235283,
- -26.807522
+ 129.292639,
+ -27.762017
],
[
- 130.31024,
- -26.831293
- ],
- [
- 130.382262,
- -26.861469
- ],
- [
- 130.450666,
- -26.897764
- ],
- [
- 130.514799,
- -26.939834
- ],
- [
- 130.574048,
- -26.98728
- ],
- [
- 130.627845,
- -27.039652
- ],
- [
- 130.67567,
- -27.096453
- ],
- [
- 130.717059,
- -27.15714
- ],
- [
- 130.751607,
- -27.221137
- ],
- [
- 130.778972,
- -27.287831
- ],
- [
- 130.798879,
- -27.356585
- ],
- [
- 130.811123,
- -27.42674
- ],
- [
- 130.815572,
- -27.497623
- ],
- [
- 130.812168,
- -27.568551
- ],
- [
- 130.80093,
- -27.638841
- ],
- [
- 130.78195,
- -27.707815
- ],
- [
- 130.755398,
- -27.774805
- ],
- [
- 130.721516,
- -27.839161
- ],
- [
- 130.680623,
- -27.90026
- ],
- [
- 130.633103,
- -27.957506
- ],
- [
- 130.579409,
- -28.010342
- ],
- [
- 130.520057,
- -28.058252
- ],
- [
- 130.455619,
- -28.100769
- ],
- [
- 130.38672,
- -28.137474
- ],
- [
- 130.314031,
- -28.168011
- ],
- [
- 130.238261,
- -28.192078
- ],
- [
- 130.160153,
- -28.209439
- ],
- [
- 130.080472,
- -28.219925
+ 129.363395,
+ -27.879322
],
[
- 130,
- -28.223432
+ 129.458831,
+ -27.98222
],
[
- 129.919528,
- -28.219925
+ 129.575375,
+ -28.066711
],
[
- 129.839847,
- -28.209439
+ 129.708598,
+ -28.129474
],
[
- 129.761739,
- -28.192078
- ],
- [
- 129.685969,
+ 129.853373,
-28.168011
],
[
- 129.61328,
- -28.137474
- ],
- [
- 129.544381,
- -28.100769
+ 130.004071,
+ -28.180753
],
[
- 129.479943,
- -28.058252
+ 130.154795,
+ -28.167136
],
[
- 129.420591,
- -28.010342
+ 130.299615,
+ -28.127634
],
[
- 129.366897,
- -27.957506
+ 130.432823,
+ -28.063748
],
[
- 129.319377,
- -27.90026
+ 130.549174,
+ -27.97795
],
[
- 129.278484,
- -27.839161
+ 130.644106,
+ -27.873586
],
[
- 129.244602,
- -27.774805
+ 130.713928,
+ -27.754739
],
[
- 129.21805,
- -27.707815
+ 130.755972,
+ -27.626061
],
[
- 129.19907,
- -27.638841
+ 130.768686,
+ -27.492581
],
[
- 129.187832,
- -27.568551
+ 130.751689,
+ -27.359499
],
[
- 129.184428,
- -27.497623
+ 130.705765,
+ -27.231978
],
[
- 129.188877,
- -27.42674
+ 130.632815,
+ -27.114934
],
[
- 129.201121,
- -27.356585
+ 130.535762,
+ -27.012851
],
[
- 129.221028,
- -27.287831
+ 130.418423,
+ -26.929606
],
[
- 129.248393,
- -27.221137
+ 130.28535,
+ -26.868329
],
[
- 129.282941,
- -27.15714
- ],
- [
- 129.32433,
- -27.096453
- ],
- [
- 129.372155,
- -27.039652
- ],
- [
- 129.425952,
- -26.98728
+ 130.141647,
+ -26.831293
],
[
- 129.485201,
- -26.939834
+ 129.992778,
+ -26.819837
],
[
- 129.549334,
- -26.897764
+ 129.844364,
+ -26.83433
],
[
- 129.617738,
- -26.861469
+ 129.701982,
+ -26.874165
],
[
- 129.68976,
- -26.831293
+ 129.570968,
+ -26.937789
],
[
- 129.764717,
- -26.807522
+ 129.456234,
+ -27.022771
],
[
- 129.841899,
- -26.79038
+ 129.362095,
+ -27.125889
],
[
- 129.920574,
- -26.780029
+ 129.292122,
+ -27.24325
],
[
- 130,
- -26.776568
+ 129.249007,
+ -27.370428
]
]
]
diff --git a/packages/turf-buffer/test/out/issue-#783.geojson b/packages/turf-buffer/test/out/issue-#783.geojson
new file mode 100644
index 0000000000..ab28c879d4
--- /dev/null
+++ b/packages/turf-buffer/test/out/issue-#783.geojson
@@ -0,0 +1,557 @@
+{
+ "type": "FeatureCollection",
+ "features": [
+ {
+ "type": "Feature",
+ "properties": {
+ "stroke": "#F00",
+ "fill": "#F00",
+ "marker-color": "#F00",
+ "fill-opacity": 0.3
+ },
+ "geometry": {
+ "type": "Polygon",
+ "coordinates": [
+ [
+ [
+ 4.946688,
+ 52.509481
+ ],
+ [
+ 4.946741,
+ 52.50946
+ ],
+ [
+ 4.947205,
+ 52.509314
+ ],
+ [
+ 4.947217,
+ 52.50931
+ ],
+ [
+ 4.947287,
+ 52.50929
+ ],
+ [
+ 4.947357,
+ 52.509276
+ ],
+ [
+ 4.947691,
+ 52.509232
+ ],
+ [
+ 4.947754,
+ 52.509227
+ ],
+ [
+ 4.947817,
+ 52.50923
+ ],
+ [
+ 4.947878,
+ 52.50924
+ ],
+ [
+ 4.947934,
+ 52.509257
+ ],
+ [
+ 4.947985,
+ 52.50928
+ ],
+ [
+ 4.948027,
+ 52.509309
+ ],
+ [
+ 4.948059,
+ 52.509342
+ ],
+ [
+ 4.948081,
+ 52.509378
+ ],
+ [
+ 4.94809,
+ 52.509416
+ ],
+ [
+ 4.948088,
+ 52.509455
+ ],
+ [
+ 4.948074,
+ 52.509492
+ ],
+ [
+ 4.948048,
+ 52.509527
+ ],
+ [
+ 4.948012,
+ 52.509559
+ ],
+ [
+ 4.947966,
+ 52.509585
+ ],
+ [
+ 4.947913,
+ 52.509606
+ ],
+ [
+ 4.947483,
+ 52.509742
+ ],
+ [
+ 4.947457,
+ 52.50975
+ ],
+ [
+ 4.946862,
+ 52.5099
+ ],
+ [
+ 4.946802,
+ 52.509911
+ ],
+ [
+ 4.94674,
+ 52.509915
+ ],
+ [
+ 4.946677,
+ 52.509912
+ ],
+ [
+ 4.946617,
+ 52.509901
+ ],
+ [
+ 4.94656,
+ 52.509884
+ ],
+ [
+ 4.946511,
+ 52.509861
+ ],
+ [
+ 4.946469,
+ 52.509832
+ ],
+ [
+ 4.946437,
+ 52.509799
+ ],
+ [
+ 4.946416,
+ 52.509763
+ ],
+ [
+ 4.946407,
+ 52.509725
+ ],
+ [
+ 4.946409,
+ 52.509687
+ ],
+ [
+ 4.946423,
+ 52.50965
+ ],
+ [
+ 4.946449,
+ 52.509615
+ ],
+ [
+ 4.946485,
+ 52.509583
+ ],
+ [
+ 4.946531,
+ 52.509557
+ ],
+ [
+ 4.946688,
+ 52.509481
+ ]
+ ]
+ ]
+ }
+ },
+ {
+ "type": "Feature",
+ "properties": {
+ "stroke": "#F00",
+ "fill": "#F00",
+ "marker-color": "#F00",
+ "fill-opacity": 0.3
+ },
+ "geometry": {
+ "type": "Polygon",
+ "coordinates": [
+ [
+ [
+ 4.946985,
+ 52.509846
+ ],
+ [
+ 4.946938,
+ 52.509873
+ ],
+ [
+ 4.946883,
+ 52.509894
+ ],
+ [
+ 4.946823,
+ 52.509908
+ ],
+ [
+ 4.946759,
+ 52.509914
+ ],
+ [
+ 4.946695,
+ 52.509913
+ ],
+ [
+ 4.946632,
+ 52.509904
+ ],
+ [
+ 4.946573,
+ 52.509888
+ ],
+ [
+ 4.94652,
+ 52.509866
+ ],
+ [
+ 4.946475,
+ 52.509837
+ ],
+ [
+ 4.946441,
+ 52.509804
+ ],
+ [
+ 4.946418,
+ 52.509767
+ ],
+ [
+ 4.946407,
+ 52.509728
+ ],
+ [
+ 4.946409,
+ 52.509689
+ ],
+ [
+ 4.946423,
+ 52.50965
+ ],
+ [
+ 4.946449,
+ 52.509615
+ ],
+ [
+ 4.946487,
+ 52.509582
+ ],
+ [
+ 4.946534,
+ 52.509555
+ ],
+ [
+ 4.946589,
+ 52.509534
+ ],
+ [
+ 4.946649,
+ 52.50952
+ ],
+ [
+ 4.946713,
+ 52.509514
+ ],
+ [
+ 4.946777,
+ 52.509515
+ ],
+ [
+ 4.94684,
+ 52.509524
+ ],
+ [
+ 4.946899,
+ 52.50954
+ ],
+ [
+ 4.946952,
+ 52.509562
+ ],
+ [
+ 4.946997,
+ 52.509591
+ ],
+ [
+ 4.947031,
+ 52.509624
+ ],
+ [
+ 4.947054,
+ 52.509661
+ ],
+ [
+ 4.947065,
+ 52.5097
+ ],
+ [
+ 4.947063,
+ 52.509739
+ ],
+ [
+ 4.947049,
+ 52.509778
+ ],
+ [
+ 4.947023,
+ 52.509813
+ ],
+ [
+ 4.946985,
+ 52.509846
+ ]
+ ]
+ ]
+ }
+ },
+ {
+ "type": "Feature",
+ "properties": {
+ "stroke": "#F00",
+ "fill": "#F00",
+ "marker-color": "#F00",
+ "fill-opacity": 0.3
+ },
+ "geometry": {
+ "type": "Polygon",
+ "coordinates": [
+ [
+ [
+ 4.94801,
+ 52.50956
+ ],
+ [
+ 4.947963,
+ 52.509587
+ ],
+ [
+ 4.947908,
+ 52.509608
+ ],
+ [
+ 4.947848,
+ 52.509622
+ ],
+ [
+ 4.947784,
+ 52.509628
+ ],
+ [
+ 4.94772,
+ 52.509627
+ ],
+ [
+ 4.947657,
+ 52.509618
+ ],
+ [
+ 4.947598,
+ 52.509602
+ ],
+ [
+ 4.947545,
+ 52.50958
+ ],
+ [
+ 4.9475,
+ 52.509551
+ ],
+ [
+ 4.947466,
+ 52.509518
+ ],
+ [
+ 4.947443,
+ 52.509481
+ ],
+ [
+ 4.947432,
+ 52.509442
+ ],
+ [
+ 4.947434,
+ 52.509403
+ ],
+ [
+ 4.947448,
+ 52.509364
+ ],
+ [
+ 4.947474,
+ 52.509329
+ ],
+ [
+ 4.947512,
+ 52.509296
+ ],
+ [
+ 4.947559,
+ 52.509269
+ ],
+ [
+ 4.947614,
+ 52.509248
+ ],
+ [
+ 4.947674,
+ 52.509234
+ ],
+ [
+ 4.947738,
+ 52.509228
+ ],
+ [
+ 4.947802,
+ 52.509229
+ ],
+ [
+ 4.947865,
+ 52.509238
+ ],
+ [
+ 4.947924,
+ 52.509254
+ ],
+ [
+ 4.947977,
+ 52.509276
+ ],
+ [
+ 4.948022,
+ 52.509305
+ ],
+ [
+ 4.948056,
+ 52.509338
+ ],
+ [
+ 4.948079,
+ 52.509375
+ ],
+ [
+ 4.94809,
+ 52.509414
+ ],
+ [
+ 4.948088,
+ 52.509453
+ ],
+ [
+ 4.948074,
+ 52.509492
+ ],
+ [
+ 4.948048,
+ 52.509527
+ ],
+ [
+ 4.94801,
+ 52.50956
+ ]
+ ]
+ ]
+ }
+ },
+ {
+ "type": "Feature",
+ "properties": {
+ "stroke": "#00F",
+ "fill": "#00F",
+ "marker-color": "#00F",
+ "fill-opacity": 0.3
+ },
+ "geometry": {
+ "type": "Polygon",
+ "coordinates": [
+ [
+ [
+ 4.946893,
+ 52.509638
+ ],
+ [
+ 4.947357,
+ 52.509492
+ ],
+ [
+ 4.947427,
+ 52.509472
+ ],
+ [
+ 4.947761,
+ 52.509428
+ ],
+ [
+ 4.947331,
+ 52.509564
+ ],
+ [
+ 4.946736,
+ 52.509714
+ ],
+ [
+ 4.946893,
+ 52.509638
+ ]
+ ]
+ ]
+ }
+ },
+ {
+ "type": "Feature",
+ "properties": {
+ "stroke": "#00F",
+ "fill": "#00F",
+ "marker-color": "#00F",
+ "fill-opacity": 0.3
+ },
+ "geometry": {
+ "type": "Point",
+ "coordinates": [
+ 4.946736,
+ 52.509714
+ ]
+ }
+ },
+ {
+ "type": "Feature",
+ "properties": {
+ "stroke": "#00F",
+ "fill": "#00F",
+ "marker-color": "#00F",
+ "fill-opacity": 0.3
+ },
+ "geometry": {
+ "type": "Point",
+ "coordinates": [
+ 4.947761,
+ 52.509428
+ ]
+ }
+ }
+ ]
+}
diff --git a/packages/turf-buffer/test/out/point.geojson b/packages/turf-buffer/test/out/point.geojson
index cf6f71e674..411fcccd8f 100644
--- a/packages/turf-buffer/test/out/point.geojson
+++ b/packages/turf-buffer/test/out/point.geojson
@@ -14,264 +14,136 @@
"coordinates": [
[
[
- 135,
- -24.276568
+ 134.252046,
+ -24.89377
],
[
- 135.077787,
- -24.280032
+ 134.243106,
+ -25.027826
],
[
- 135.154838,
- -24.290389
+ 134.263103,
+ -25.160922
],
[
- 135.230423,
- -24.307542
+ 134.311386,
+ -25.287986
],
[
- 135.303826,
- -24.331329
+ 134.386227,
+ -25.404151
],
[
- 135.374348,
- -24.361523
+ 134.48486,
+ -25.504937
],
[
- 135.441321,
- -24.397839
+ 134.603575,
+ -25.586423
],
[
- 135.504104,
- -24.439933
+ 134.737846,
+ -25.645409
],
[
- 135.562097,
- -24.487403
+ 134.882499,
+ -25.679551
],
[
- 135.614744,
- -24.539799
+ 135.031913,
+ -25.687455
],
[
- 135.661536,
- -24.596623
+ 135.180244,
+ -25.668755
],
[
- 135.702019,
- -24.657332
+ 135.321669,
+ -25.624127
],
[
- 135.735798,
- -24.721347
+ 135.450628,
+ -25.555273
],
[
- 135.76254,
- -24.788057
+ 135.562058,
+ -25.464861
],
[
- 135.781976,
- -24.856823
+ 135.6516,
+ -25.356411
],
[
- 135.793908,
- -24.926985
+ 135.715786,
+ -25.234158
],
[
- 135.798209,
- -24.99787
+ 135.752166,
+ -25.102878
],
[
- 135.794825,
- -25.068796
+ 135.759408,
+ -24.967691
],
[
- 135.783774,
- -25.13908
+ 135.73733,
+ -24.833854
],
[
- 135.76515,
- -25.208042
+ 135.6869,
+ -24.706551
],
[
- 135.739121,
- -25.275017
+ 135.610173,
+ -24.590685
],
[
- 135.705927,
- -25.339355
+ 135.510202,
+ -24.490692
],
[
- 135.665878,
- -25.400432
+ 135.390901,
+ -24.410371
],
[
- 135.619353,
- -25.457655
+ 135.256884,
+ -24.352744
],
[
- 135.566797,
- -25.510467
+ 135.113288,
+ -24.319951
],
[
- 135.508713,
- -25.558353
+ 134.965573,
+ -24.313177
],
[
- 135.445663,
- -25.600846
+ 134.819323,
+ -24.332619
],
[
- 135.378256,
- -25.63753
+ 134.680045,
+ -24.377487
],
[
- 135.307149,
- -25.668047
+ 134.552972,
+ -24.44604
],
[
- 135.233035,
- -25.692099
+ 134.442881,
+ -24.53566
],
[
- 135.156637,
- -25.709449
+ 134.353924,
+ -24.642946
],
[
- 135.078704,
- -25.719927
+ 134.289484,
+ -24.763838
],
[
- 135,
- -25.723432
- ],
- [
- 134.921296,
- -25.719927
- ],
- [
- 134.843363,
- -25.709449
- ],
- [
- 134.766965,
- -25.692099
- ],
- [
- 134.692851,
- -25.668047
- ],
- [
- 134.621744,
- -25.63753
- ],
- [
- 134.554337,
- -25.600846
- ],
- [
- 134.491287,
- -25.558353
- ],
- [
- 134.433203,
- -25.510467
- ],
- [
- 134.380647,
- -25.457655
- ],
- [
- 134.334122,
- -25.400432
- ],
- [
- 134.294073,
- -25.339355
- ],
- [
- 134.260879,
- -25.275017
- ],
- [
- 134.23485,
- -25.208042
- ],
- [
- 134.216226,
- -25.13908
- ],
- [
- 134.205175,
- -25.068796
- ],
- [
- 134.201791,
- -24.99787
- ],
- [
- 134.206092,
- -24.926985
- ],
- [
- 134.218024,
- -24.856823
- ],
- [
- 134.23746,
- -24.788057
- ],
- [
- 134.264202,
- -24.721347
- ],
- [
- 134.297981,
- -24.657332
- ],
- [
- 134.338464,
- -24.596623
- ],
- [
- 134.385256,
- -24.539799
- ],
- [
- 134.437903,
- -24.487403
- ],
- [
- 134.495896,
- -24.439933
- ],
- [
- 134.558679,
- -24.397839
- ],
- [
- 134.625652,
- -24.361523
- ],
- [
- 134.696174,
- -24.331329
- ],
- [
- 134.769577,
- -24.307542
- ],
- [
- 134.845162,
- -24.290389
- ],
- [
- 134.922213,
- -24.280032
- ],
- [
- 135,
- -24.276568
+ 134.252046,
+ -24.89377
]
]
]
diff --git a/packages/turf-buffer/yarn.lock b/packages/turf-buffer/yarn.lock
index 7dcdece32f..a034ca2dde 100644
--- a/packages/turf-buffer/yarn.lock
+++ b/packages/turf-buffer/yarn.lock
@@ -2,6 +2,51 @@
# yarn lockfile v1
+"@turf/bbox@^4.4.0":
+ version "4.4.0"
+ resolved "https://registry.yarnpkg.com/@turf/bbox/-/bbox-4.4.0.tgz#3149458eb41404427cf786a90fb3680a0e8aab55"
+ dependencies:
+ "@turf/meta" "^4.4.0"
+
+"@turf/center@^4.4.0":
+ version "4.4.0"
+ resolved "https://registry.yarnpkg.com/@turf/center/-/center-4.4.0.tgz#5907b4d64faa8b92b6e5446b84f2a150c3e0e09b"
+ dependencies:
+ "@turf/bbox" "^4.4.0"
+ "@turf/helpers" "^4.4.0"
+
+"@turf/circle@^4.4.0":
+ version "4.4.0"
+ resolved "https://registry.yarnpkg.com/@turf/circle/-/circle-4.4.0.tgz#d0185b0c19ecf7a470bee16603d6e0c101e30ef0"
+ dependencies:
+ "@turf/destination" "^4.4.0"
+ "@turf/helpers" "^4.4.0"
+
+"@turf/destination@^4.4.0":
+ version "4.4.0"
+ resolved "https://registry.yarnpkg.com/@turf/destination/-/destination-4.4.0.tgz#22759e888f60d2fbd111b551be3a4d12e3fa46e8"
+ dependencies:
+ "@turf/helpers" "^4.4.0"
+ "@turf/invariant" "^4.4.0"
+
+"@turf/helpers@^4.4.0":
+ version "4.4.0"
+ resolved "https://registry.yarnpkg.com/@turf/helpers/-/helpers-4.4.0.tgz#c83112f7fbe6ed183c7c0c2f776481b94d1cbd01"
+
+"@turf/invariant@^4.4.0":
+ version "4.4.0"
+ resolved "https://registry.yarnpkg.com/@turf/invariant/-/invariant-4.4.0.tgz#aac0afb840ae40908f9c80393f416222dcf79c32"
+
+"@turf/meta@^4.4.0":
+ version "4.4.0"
+ resolved "https://registry.yarnpkg.com/@turf/meta/-/meta-4.4.0.tgz#4fa25d4cc0525bd4cdbaf4ff68a6f8ae81f1975f"
+
+"@turf/truncate@^4.4.0":
+ version "4.4.0"
+ resolved "https://registry.yarnpkg.com/@turf/truncate/-/truncate-4.4.0.tgz#194deef33b91d6b27cc9b33a141cacb6e7ce23a0"
+ dependencies:
+ "@turf/meta" "^4.4.0"
+
balanced-match@^0.4.1:
version "0.4.2"
resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-0.4.2.tgz#cb3f3e3c732dc0f01ee70b403f302e61d7709838"
diff --git a/packages/turf-center-of-mass/package.json b/packages/turf-center-of-mass/package.json
index 4a7b16109c..808bb2355b 100644
--- a/packages/turf-center-of-mass/package.json
+++ b/packages/turf-center-of-mass/package.json
@@ -1,6 +1,6 @@
{
"name": "@turf/center-of-mass",
- "version": "4.3.0",
+ "version": "4.4.0",
"description": "turf center-of-mass module",
"main": "index.js",
"types": "index.d.ts",
@@ -34,11 +34,11 @@
"write-json-file": "^2.2.0"
},
"dependencies": {
- "@turf/centroid": "^4.3.0",
- "@turf/convex": "^4.3.0",
- "@turf/explode": "^4.3.0",
- "@turf/helpers": "^4.3.0",
- "@turf/invariant": "^4.3.0",
- "@turf/meta": "^4.3.0"
+ "@turf/centroid": "^4.4.0",
+ "@turf/convex": "^4.4.0",
+ "@turf/explode": "^4.4.0",
+ "@turf/helpers": "^4.4.0",
+ "@turf/invariant": "^4.4.0",
+ "@turf/meta": "^4.4.0"
}
}
diff --git a/packages/turf-center/package.json b/packages/turf-center/package.json
index 1661f8ec03..86ae2bef56 100644
--- a/packages/turf-center/package.json
+++ b/packages/turf-center/package.json
@@ -1,6 +1,6 @@
{
"name": "@turf/center",
- "version": "4.3.0",
+ "version": "4.4.0",
"description": "turf center module",
"main": "index.js",
"types": "index.d.ts",
@@ -31,7 +31,7 @@
},
"homepage": "/~https://github.com/Turfjs/turf",
"devDependencies": {
- "@turf/meta": "^4.3.0",
+ "@turf/meta": "^4.4.0",
"benchmark": "^2.1.4",
"glob": "^7.1.2",
"load-json-file": "^2.0.0",
@@ -39,7 +39,7 @@
"write-json-file": "^2.2.0"
},
"dependencies": {
- "@turf/bbox": "^4.3.0",
- "@turf/helpers": "^4.3.0"
+ "@turf/bbox": "^4.4.0",
+ "@turf/helpers": "^4.4.0"
}
}
diff --git a/packages/turf-centroid/package.json b/packages/turf-centroid/package.json
index 9fbdaa0ee6..4b2f773f49 100644
--- a/packages/turf-centroid/package.json
+++ b/packages/turf-centroid/package.json
@@ -1,6 +1,6 @@
{
"name": "@turf/centroid",
- "version": "4.3.0",
+ "version": "4.4.0",
"description": "turf centroid module",
"main": "index.js",
"types": "index.d.ts",
@@ -37,7 +37,7 @@
"write-json-file": "^2.2.0"
},
"dependencies": {
- "@turf/helpers": "^4.3.0",
- "@turf/meta": "^4.3.0"
+ "@turf/helpers": "^4.4.0",
+ "@turf/meta": "^4.4.0"
}
}
diff --git a/packages/turf-circle/package.json b/packages/turf-circle/package.json
index f093f4362a..a6c29f6252 100644
--- a/packages/turf-circle/package.json
+++ b/packages/turf-circle/package.json
@@ -1,6 +1,6 @@
{
"name": "@turf/circle",
- "version": "4.3.0",
+ "version": "4.4.0",
"description": "turf circle module",
"main": "index.js",
"types": "index.d.ts",
@@ -31,14 +31,14 @@
},
"homepage": "/~https://github.com/Turfjs/turf",
"devDependencies": {
- "@turf/truncate": "^4.3.0",
+ "@turf/truncate": "^4.4.0",
"benchmark": "^2.1.4",
"load-json-file": "^2.0.0",
"tape": "^4.6.3",
"write-json-file": "^2.0.0"
},
"dependencies": {
- "@turf/destination": "^4.3.0",
- "@turf/helpers": "^4.3.0"
+ "@turf/destination": "^4.4.0",
+ "@turf/helpers": "^4.4.0"
}
}
diff --git a/packages/turf-collect/package.json b/packages/turf-collect/package.json
index 04c8eb6fae..df8b83c6b0 100644
--- a/packages/turf-collect/package.json
+++ b/packages/turf-collect/package.json
@@ -1,6 +1,6 @@
{
"name": "@turf/collect",
- "version": "4.3.0",
+ "version": "4.4.0",
"description": "turf collect module",
"main": "index.js",
"types": "index.d.ts",
@@ -34,13 +34,13 @@
],
"license": "MIT",
"devDependencies": {
- "@turf/helpers": "^4.3.0",
+ "@turf/helpers": "^4.4.0",
"benchmark": "^2.1.4",
"tape": "^4.6.3"
},
"dependencies": {
- "@turf/bbox": "^4.3.0",
- "@turf/inside": "^4.3.0",
+ "@turf/bbox": "^4.4.0",
+ "@turf/inside": "^4.4.0",
"rbush": "^2.0.1"
}
}
diff --git a/packages/turf-combine/package.json b/packages/turf-combine/package.json
index aca31a831f..5456f4c630 100644
--- a/packages/turf-combine/package.json
+++ b/packages/turf-combine/package.json
@@ -1,6 +1,6 @@
{
"name": "@turf/combine",
- "version": "4.3.0",
+ "version": "4.4.0",
"description": "turf combine module",
"main": "index.js",
"types": "index.d.ts",
@@ -30,11 +30,11 @@
},
"homepage": "/~https://github.com/Turfjs/turf",
"devDependencies": {
- "@turf/helpers": "^4.3.0",
+ "@turf/helpers": "^4.4.0",
"benchmark": "^2.1.4",
"tape": "^4.6.3"
},
"dependencies": {
- "@turf/meta": "^4.3.0"
+ "@turf/meta": "^4.4.0"
}
}
diff --git a/packages/turf-concave/package.json b/packages/turf-concave/package.json
index 6665446c43..c7d26f27f0 100644
--- a/packages/turf-concave/package.json
+++ b/packages/turf-concave/package.json
@@ -1,6 +1,6 @@
{
"name": "@turf/concave",
- "version": "4.3.0",
+ "version": "4.4.0",
"description": "turf concave module",
"main": "index.js",
"types": "index.d.ts",
@@ -28,14 +28,14 @@
},
"homepage": "/~https://github.com/Turfjs/turf",
"devDependencies": {
- "@turf/helpers": "^4.3.0",
+ "@turf/helpers": "^4.4.0",
"benchmark": "^2.1.4",
"glob": "~4.3.5",
"tape": "^4.6.3"
},
"dependencies": {
- "@turf/distance": "^4.3.0",
- "@turf/tin": "^4.3.0",
- "@turf/union": "^4.3.0"
+ "@turf/distance": "^4.4.0",
+ "@turf/tin": "^4.4.0",
+ "@turf/union": "^4.4.0"
}
}
diff --git a/packages/turf-convex/package.json b/packages/turf-convex/package.json
index f4ad3edae7..7e4b5ec8fa 100644
--- a/packages/turf-convex/package.json
+++ b/packages/turf-convex/package.json
@@ -1,6 +1,6 @@
{
"name": "@turf/convex",
- "version": "4.3.0",
+ "version": "4.4.0",
"description": "turf convex module",
"main": "index.js",
"types": "index.d.ts",
@@ -32,8 +32,8 @@
"tape": "^4.6.3"
},
"dependencies": {
- "@turf/helpers": "^4.3.0",
- "@turf/meta": "^4.3.0",
+ "@turf/helpers": "^4.4.0",
+ "@turf/meta": "^4.4.0",
"convex-hull": "^1.0.3"
}
}
diff --git a/packages/turf-destination/package.json b/packages/turf-destination/package.json
index 02a6695d68..20b7f400f3 100644
--- a/packages/turf-destination/package.json
+++ b/packages/turf-destination/package.json
@@ -1,6 +1,6 @@
{
"name": "@turf/destination",
- "version": "4.3.0",
+ "version": "4.4.0",
"description": "turf destination module",
"main": "index.js",
"types": "index.d.ts",
@@ -38,7 +38,7 @@
"write-json-file": "^2.0.0"
},
"dependencies": {
- "@turf/helpers": "^4.3.0",
- "@turf/invariant": "^4.3.0"
+ "@turf/helpers": "^4.4.0",
+ "@turf/invariant": "^4.4.0"
}
}
diff --git a/packages/turf-difference/package.json b/packages/turf-difference/package.json
index 4ec530c67b..eb6bc99529 100644
--- a/packages/turf-difference/package.json
+++ b/packages/turf-difference/package.json
@@ -1,6 +1,6 @@
{
"name": "@turf/difference",
- "version": "4.3.0",
+ "version": "4.4.0",
"description": "turf difference module",
"main": "index.js",
"types": "index.d.ts",
@@ -34,10 +34,10 @@
"write-json-file": "^2.0.0"
},
"dependencies": {
- "@turf/area": "^4.3.0",
- "@turf/helpers": "^4.3.0",
- "@turf/invariant": "^4.3.0",
- "@turf/meta": "^4.3.0",
+ "@turf/area": "^4.4.0",
+ "@turf/helpers": "^4.4.0",
+ "@turf/invariant": "^4.4.0",
+ "@turf/meta": "^4.4.0",
"jsts": "1.3.0"
}
}
diff --git a/packages/turf-dissolve/package.json b/packages/turf-dissolve/package.json
index c6c798ae74..a8e54b9404 100644
--- a/packages/turf-dissolve/package.json
+++ b/packages/turf-dissolve/package.json
@@ -1,6 +1,6 @@
{
"name": "@turf/dissolve",
- "version": "4.3.0",
+ "version": "4.4.0",
"description": "turf dissolve module",
"main": "index.js",
"types": "index.d.ts",
@@ -35,8 +35,8 @@
"tape": "^4.6.3"
},
"dependencies": {
- "@turf/bbox": "^4.3.0",
- "@turf/union": "^4.3.0",
+ "@turf/bbox": "^4.4.0",
+ "@turf/union": "^4.4.0",
"geojson-utils": "^1.1.0",
"get-closest": "^0.0.4",
"rbush": "^2.0.1",
diff --git a/packages/turf-distance/package.json b/packages/turf-distance/package.json
index 2bda815f57..57d1948485 100644
--- a/packages/turf-distance/package.json
+++ b/packages/turf-distance/package.json
@@ -1,6 +1,6 @@
{
"name": "@turf/distance",
- "version": "4.3.0",
+ "version": "4.4.0",
"description": "turf distance module",
"main": "index.js",
"types": "index.d.ts",
@@ -30,12 +30,12 @@
"homepage": "/~https://github.com/Turfjs/turf",
"devDependencies": {
"benchmark": "^2.1.4",
- "tape": "^4.6.3",
"load-json-file": "^2.0.0",
+ "tape": "^4.6.3",
"write-json-file": "^2.0.0"
},
"dependencies": {
- "@turf/helpers": "^4.3.0",
- "@turf/invariant": "^4.3.0"
+ "@turf/helpers": "^4.4.0",
+ "@turf/invariant": "^4.4.0"
}
}
diff --git a/packages/turf-envelope/package.json b/packages/turf-envelope/package.json
index 7608209440..14ae4ff961 100644
--- a/packages/turf-envelope/package.json
+++ b/packages/turf-envelope/package.json
@@ -1,6 +1,6 @@
{
"name": "@turf/envelope",
- "version": "4.3.0",
+ "version": "4.4.0",
"description": "turf envelope module",
"main": "index.js",
"types": "index.d.ts",
@@ -34,7 +34,7 @@
"tape": "^4.6.3"
},
"dependencies": {
- "@turf/bbox": "^4.3.0",
- "@turf/bbox-polygon": "^4.3.0"
+ "@turf/bbox": "^4.4.0",
+ "@turf/bbox-polygon": "^4.4.0"
}
}
diff --git a/packages/turf-explode/package.json b/packages/turf-explode/package.json
index f8e4620953..024bf08e2f 100644
--- a/packages/turf-explode/package.json
+++ b/packages/turf-explode/package.json
@@ -1,6 +1,6 @@
{
"name": "@turf/explode",
- "version": "4.3.0",
+ "version": "4.4.0",
"description": "turf explode module",
"main": "index.js",
"types": "index.d.ts",
@@ -36,7 +36,7 @@
"write-json-file": "^2.0.0"
},
"dependencies": {
- "@turf/helpers": "^4.3.0",
- "@turf/meta": "^4.3.0"
+ "@turf/helpers": "^4.4.0",
+ "@turf/meta": "^4.4.0"
}
}
diff --git a/packages/turf-flatten/package.json b/packages/turf-flatten/package.json
index ab2bfba83a..57c30c5891 100644
--- a/packages/turf-flatten/package.json
+++ b/packages/turf-flatten/package.json
@@ -1,6 +1,6 @@
{
"name": "@turf/flatten",
- "version": "4.3.0",
+ "version": "4.4.0",
"description": "turf flatten module",
"main": "index.js",
"types": "index.d.ts",
@@ -40,7 +40,7 @@
"write-json-file": "^2.0.0"
},
"dependencies": {
- "@turf/helpers": "^4.3.0",
- "@turf/meta": "^4.3.0"
+ "@turf/helpers": "^4.4.0",
+ "@turf/meta": "^4.4.0"
}
}
diff --git a/packages/turf-flip/package.json b/packages/turf-flip/package.json
index 7ef8c72663..903b0565ed 100644
--- a/packages/turf-flip/package.json
+++ b/packages/turf-flip/package.json
@@ -1,6 +1,6 @@
{
"name": "@turf/flip",
- "version": "4.3.0",
+ "version": "4.4.0",
"description": "turf flip module",
"main": "index.js",
"types": "index.d.ts",
@@ -29,13 +29,13 @@
},
"homepage": "/~https://github.com/Turfjs/turf",
"devDependencies": {
- "@turf/helpers": "^4.3.0",
+ "@turf/helpers": "^4.4.0",
"benchmark": "^2.1.4",
"load-json-file": "^2.0.0",
"tape": "^4.6.3",
"write-json-file": "^2.0.0"
},
"dependencies": {
- "@turf/meta": "^4.3.0"
+ "@turf/meta": "^4.4.0"
}
}
diff --git a/packages/turf-great-circle/package.json b/packages/turf-great-circle/package.json
index 90d610bbcd..f3f54f160b 100644
--- a/packages/turf-great-circle/package.json
+++ b/packages/turf-great-circle/package.json
@@ -1,6 +1,6 @@
{
"name": "@turf/great-circle",
- "version": "4.3.0",
+ "version": "4.4.0",
"description": "turf great-circle module",
"main": "index.js",
"types": "index.d.ts",
@@ -36,14 +36,14 @@
},
"homepage": "/~https://github.com/Turfjs/turf",
"devDependencies": {
- "@turf/helpers": "^4.3.0",
- "@turf/truncate": "^4.3.0",
+ "@turf/helpers": "^4.4.0",
+ "@turf/truncate": "^4.4.0",
"benchmark": "^2.1.4",
"load-json-file": "^2.0.0",
"tape": "^4.6.3",
"write-json-file": "^2.0.0"
},
"dependencies": {
- "@turf/invariant": "^4.3.0"
+ "@turf/invariant": "^4.4.0"
}
}
diff --git a/packages/turf-helpers/package.json b/packages/turf-helpers/package.json
index e70127595e..39a10d7c8b 100644
--- a/packages/turf-helpers/package.json
+++ b/packages/turf-helpers/package.json
@@ -1,6 +1,6 @@
{
"name": "@turf/helpers",
- "version": "4.3.0",
+ "version": "4.4.0",
"description": "turf helpers module",
"main": "index.js",
"types": "index.d.ts",
@@ -36,6 +36,5 @@
"devDependencies": {
"benchmark": "^2.1.4",
"tape": "^4.6.3"
- },
- "dependencies": {}
+ }
}
diff --git a/packages/turf-hex-grid/package.json b/packages/turf-hex-grid/package.json
index 565d520372..56f48581fe 100644
--- a/packages/turf-hex-grid/package.json
+++ b/packages/turf-hex-grid/package.json
@@ -1,6 +1,6 @@
{
"name": "@turf/hex-grid",
- "version": "4.3.1",
+ "version": "4.4.0",
"description": "turf hex-grid module",
"main": "index.js",
"types": "index.d.ts",
@@ -39,14 +39,14 @@
},
"homepage": "/~https://github.com/Turfjs/turf",
"devDependencies": {
- "@turf/truncate": "^4.3.0",
+ "@turf/truncate": "^4.4.0",
"benchmark": "^2.1.4",
"load-json-file": "^2.0.0",
"tape": "^4.6.3",
"write-json-file": "^2.0.0"
},
"dependencies": {
- "@turf/distance": "^4.3.0",
- "@turf/helpers": "^4.3.0"
+ "@turf/distance": "^4.4.0",
+ "@turf/helpers": "^4.4.0"
}
}
diff --git a/packages/turf-idw/package.json b/packages/turf-idw/package.json
index 7caa582be8..f3f62a6215 100644
--- a/packages/turf-idw/package.json
+++ b/packages/turf-idw/package.json
@@ -1,6 +1,6 @@
{
"name": "@turf/idw",
- "version": "4.3.0",
+ "version": "4.4.0",
"description": "turf idw module",
"main": "index.js",
"types": "index.d.ts",
@@ -29,9 +29,9 @@
"write-json-file": "^2.2.0"
},
"dependencies": {
- "@turf/bbox": "^4.3.0",
- "@turf/centroid": "^4.3.0",
- "@turf/distance": "^4.3.0",
- "@turf/square-grid": "^4.3.0"
+ "@turf/bbox": "^4.4.0",
+ "@turf/centroid": "^4.4.0",
+ "@turf/distance": "^4.4.0",
+ "@turf/square-grid": "^4.4.0"
}
}
diff --git a/packages/turf-inside/package.json b/packages/turf-inside/package.json
index 9729e5a635..d606fc721f 100644
--- a/packages/turf-inside/package.json
+++ b/packages/turf-inside/package.json
@@ -1,6 +1,6 @@
{
"name": "@turf/inside",
- "version": "4.3.0",
+ "version": "4.4.0",
"description": "turf inside module",
"main": "index.js",
"types": "index.d.ts",
@@ -31,11 +31,11 @@
},
"homepage": "/~https://github.com/Turfjs/turf",
"devDependencies": {
- "@turf/helpers": "^4.3.0",
+ "@turf/helpers": "^4.4.0",
"benchmark": "^2.1.4",
"tape": "^4.6.3"
},
"dependencies": {
- "@turf/invariant": "^4.3.0"
+ "@turf/invariant": "^4.4.0"
}
}
diff --git a/packages/turf-inside/test.js b/packages/turf-inside/test.js
index 4969384d59..cf01b9dc8f 100644
--- a/packages/turf-inside/test.js
+++ b/packages/turf-inside/test.js
@@ -74,7 +74,7 @@ test('Boundary test', function (t) {
[ 50, 0 ],
[ 30, -20 ],
[ 10, 0 ]
- ]]);
+ ]]);
var poly4 = polygon([[
[ 0, 0 ],
[ 0, 20 ],
@@ -153,3 +153,18 @@ test('Boundary test', function (t) {
runTest(t, true);
t.end();
});
+
+// /~https://github.com/Turfjs/turf-inside/issues/15
+test(t => {
+ var pt1 = point([-9.9964077, 53.8040989]);
+ var poly = polygon([[
+ [5.080336744095521, 67.89398938540765],
+ [0.35070899909145403, 69.32470003971179],
+ [-24.453622256504122, 41.146696777884564],
+ [-21.6445524714804, 40.43225902006474],
+ [5.080336744095521, 67.89398938540765]
+ ]]);
+
+ t.true(inside(pt1, poly));
+ t.end();
+});
diff --git a/packages/turf-intersect/package.json b/packages/turf-intersect/package.json
index c4e42956c2..1cbed0b2e3 100644
--- a/packages/turf-intersect/package.json
+++ b/packages/turf-intersect/package.json
@@ -1,6 +1,6 @@
{
"name": "@turf/intersect",
- "version": "4.3.0",
+ "version": "4.4.0",
"description": "turf intersect module",
"main": "index.js",
"types": "index.d.ts",
diff --git a/packages/turf-invariant/package.json b/packages/turf-invariant/package.json
index ca760fdeee..8c01743a3a 100644
--- a/packages/turf-invariant/package.json
+++ b/packages/turf-invariant/package.json
@@ -1,6 +1,6 @@
{
"name": "@turf/invariant",
- "version": "4.3.0",
+ "version": "4.4.0",
"description": "turf invariant module",
"main": "index.js",
"types": "index.d.ts",
@@ -28,9 +28,8 @@
"url": "/~https://github.com/Turfjs/turf/issues"
},
"devDependencies": {
- "@turf/helpers": "^4.3.0",
+ "@turf/helpers": "^4.4.0",
"benchmark": "^2.1.4",
"tape": "^4.6.3"
- },
- "dependencies": {}
+ }
}
diff --git a/packages/turf-isobands/package.json b/packages/turf-isobands/package.json
index f37e739e03..c16b65a487 100644
--- a/packages/turf-isobands/package.json
+++ b/packages/turf-isobands/package.json
@@ -1,6 +1,6 @@
{
"name": "@turf/isobands",
- "version": "4.3.0",
+ "version": "4.4.0",
"description": "turf isobands module",
"main": "index.js",
"types": "index.d.ts",
@@ -35,7 +35,7 @@
},
"homepage": "/~https://github.com/Turfjs/turf",
"devDependencies": {
- "@turf/envelope": "^4.3.0",
+ "@turf/envelope": "^4.4.0",
"@turf/point-grid": "^3.14.0",
"@turf/random": "^3.13.0",
"benchmark": "^2.1.4",
diff --git a/packages/turf-isolines/README.md b/packages/turf-isolines/README.md
index 72f5757aa8..a16d481355 100644
--- a/packages/turf-isolines/README.md
+++ b/packages/turf-isolines/README.md
@@ -8,15 +8,16 @@ value breaks and generates [isolines](http://en.wikipedia.org/wiki/Isoline).
**Parameters**
- `points` **[FeatureCollection](http://geojson.org/geojson-spec.html#feature-collection-objects)<[Point](http://geojson.org/geojson-spec.html#point)>** input points
-- `z` **[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** the property name in `points` from which z-values will be pulled
-- `resolution` **[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)** resolution of the underlying grid
-- `breaks` **[Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)<[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)>** where to draw contours
+- `breaks` **[Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)<[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)>** values of `zProperty` where to draw isolines
+- `zProperty` **\[[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)]** the property name in `points` from which z-values will be pulled (optional, default `'elevation'`)
+- `propertiesToAllIsolines` **\[[Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)]** GeoJSON properties passed to ALL isolines (optional, default `{}`)
+- `propertiesPerIsoline` **\[[Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)<[Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)>]** GeoJSON properties passed, in order, to the correspondent
+ isoline; the breaks array will define the order in which the isolines are created (optional, default `[]`)
**Examples**
```javascript
-// create random points with random
-// z-values in their properties
+// create random points with random z-values in their properties
var points = turf.random('point', 100, {
bbox: [0, 30, 20, 50]
});
@@ -24,11 +25,13 @@ for (var i = 0; i < points.features.length; i++) {
points.features[i].properties.z = Math.random() * 10;
}
var breaks = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
-var isolined = turf.isolines(points, 'z', 15, breaks);
-//=isolined
+var isolines = turf.isolines(points, breaks, 'temperature');
+
+//addToMap
+var addToMap = [isolines];
```
-Returns **[FeatureCollection](http://geojson.org/geojson-spec.html#feature-collection-objects)<[LineString](http://geojson.org/geojson-spec.html#linestring)>** isolines
+Returns **[FeatureCollection](http://geojson.org/geojson-spec.html#feature-collection-objects)<[MultiLineString](http://geojson.org/geojson-spec.html#multilinestring)>** a FeatureCollection of [MultiLineString](http://geojson.org/geojson-spec.html#multilinestring) features representing isolines