@turf/boolean-parallel 7.0.0-alpha.1 → 7.0.0-alpha.111
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -9
- package/dist/cjs/index.cjs +52 -0
- package/dist/cjs/index.cjs.map +1 -0
- package/dist/{js → cjs}/index.d.ts +4 -2
- package/dist/esm/index.d.mts +19 -0
- package/dist/esm/index.mjs +52 -0
- package/dist/esm/index.mjs.map +1 -0
- package/package.json +34 -29
- package/dist/es/index.js +0 -71
- package/dist/es/package.json +0 -1
- package/dist/js/index.js +0 -74
package/README.md
CHANGED
|
@@ -31,26 +31,21 @@ Returns **[boolean][4]** true/false if the lines are parallel
|
|
|
31
31
|
|
|
32
32
|
[4]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean
|
|
33
33
|
|
|
34
|
-
<!-- This file is automatically generated. Please don't edit it directly
|
|
35
|
-
if you find an error, edit the source file (likely index.js), and re-run
|
|
36
|
-
./scripts/generate-readmes in the turf project. -->
|
|
34
|
+
<!-- This file is automatically generated. Please don't edit it directly. If you find an error, edit the source file of the module in question (likely index.js or index.ts), and re-run "yarn docs" from the root of the turf project. -->
|
|
37
35
|
|
|
38
36
|
---
|
|
39
37
|
|
|
40
|
-
This module is part of the [Turfjs project](
|
|
41
|
-
module collection dedicated to geographic algorithms. It is maintained in the
|
|
42
|
-
[Turfjs/turf](https://github.com/Turfjs/turf) repository, where you can create
|
|
43
|
-
PRs and issues.
|
|
38
|
+
This module is part of the [Turfjs project](https://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.
|
|
44
39
|
|
|
45
40
|
### Installation
|
|
46
41
|
|
|
47
|
-
Install this module individually:
|
|
42
|
+
Install this single module individually:
|
|
48
43
|
|
|
49
44
|
```sh
|
|
50
45
|
$ npm install @turf/boolean-parallel
|
|
51
46
|
```
|
|
52
47
|
|
|
53
|
-
Or install the
|
|
48
|
+
Or install the all-encompassing @turf/turf module that includes all modules as functions:
|
|
54
49
|
|
|
55
50
|
```sh
|
|
56
51
|
$ npm install @turf/turf
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var __defProp = Object.defineProperty;
|
|
2
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
+
|
|
4
|
+
// index.ts
|
|
5
|
+
var _cleancoords = require('@turf/clean-coords');
|
|
6
|
+
var _linesegment = require('@turf/line-segment');
|
|
7
|
+
var _rhumbbearing = require('@turf/rhumb-bearing');
|
|
8
|
+
var _helpers = require('@turf/helpers');
|
|
9
|
+
function booleanParallel(line1, line2) {
|
|
10
|
+
if (!line1)
|
|
11
|
+
throw new Error("line1 is required");
|
|
12
|
+
if (!line2)
|
|
13
|
+
throw new Error("line2 is required");
|
|
14
|
+
var type1 = getType(line1, "line1");
|
|
15
|
+
if (type1 !== "LineString")
|
|
16
|
+
throw new Error("line1 must be a LineString");
|
|
17
|
+
var type2 = getType(line2, "line2");
|
|
18
|
+
if (type2 !== "LineString")
|
|
19
|
+
throw new Error("line2 must be a LineString");
|
|
20
|
+
var segments1 = _linesegment.lineSegment.call(void 0, _cleancoords.cleanCoords.call(void 0, line1)).features;
|
|
21
|
+
var segments2 = _linesegment.lineSegment.call(void 0, _cleancoords.cleanCoords.call(void 0, line2)).features;
|
|
22
|
+
for (var i = 0; i < segments1.length; i++) {
|
|
23
|
+
var segment1 = segments1[i].geometry.coordinates;
|
|
24
|
+
if (!segments2[i])
|
|
25
|
+
break;
|
|
26
|
+
var segment2 = segments2[i].geometry.coordinates;
|
|
27
|
+
if (!isParallel(segment1, segment2))
|
|
28
|
+
return false;
|
|
29
|
+
}
|
|
30
|
+
return true;
|
|
31
|
+
}
|
|
32
|
+
__name(booleanParallel, "booleanParallel");
|
|
33
|
+
function isParallel(segment1, segment2) {
|
|
34
|
+
var slope1 = _helpers.bearingToAzimuth.call(void 0, _rhumbbearing.rhumbBearing.call(void 0, segment1[0], segment1[1]));
|
|
35
|
+
var slope2 = _helpers.bearingToAzimuth.call(void 0, _rhumbbearing.rhumbBearing.call(void 0, segment2[0], segment2[1]));
|
|
36
|
+
return slope1 === slope2 || (slope2 - slope1) % 180 === 0;
|
|
37
|
+
}
|
|
38
|
+
__name(isParallel, "isParallel");
|
|
39
|
+
function getType(geojson, name) {
|
|
40
|
+
if (geojson.geometry && geojson.geometry.type)
|
|
41
|
+
return geojson.geometry.type;
|
|
42
|
+
if (geojson.type)
|
|
43
|
+
return geojson.type;
|
|
44
|
+
throw new Error("Invalid GeoJSON object for " + name);
|
|
45
|
+
}
|
|
46
|
+
__name(getType, "getType");
|
|
47
|
+
var turf_boolean_parallel_default = booleanParallel;
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
exports.booleanParallel = booleanParallel; exports.default = turf_boolean_parallel_default;
|
|
52
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../index.ts"],"names":[],"mappings":";;;;AACA,SAAS,mBAAmB;AAC5B,SAAS,mBAAmB;AAC5B,SAAS,oBAAoB;AAC7B,SAAS,wBAAwB;AAgBjC,SAAS,gBACP,OACA,OACS;AAET,MAAI,CAAC;AAAO,UAAM,IAAI,MAAM,mBAAmB;AAC/C,MAAI,CAAC;AAAO,UAAM,IAAI,MAAM,mBAAmB;AAC/C,MAAI,QAAQ,QAAQ,OAAO,OAAO;AAClC,MAAI,UAAU;AAAc,UAAM,IAAI,MAAM,4BAA4B;AACxE,MAAI,QAAQ,QAAQ,OAAO,OAAO;AAClC,MAAI,UAAU;AAAc,UAAM,IAAI,MAAM,4BAA4B;AAExE,MAAI,YAAY,YAAY,YAAY,KAAK,CAAC,EAAE;AAChD,MAAI,YAAY,YAAY,YAAY,KAAK,CAAC,EAAE;AAEhD,WAAS,IAAI,GAAG,IAAI,UAAU,QAAQ,KAAK;AACzC,QAAI,WAAW,UAAU,CAAC,EAAE,SAAS;AACrC,QAAI,CAAC,UAAU,CAAC;AAAG;AACnB,QAAI,WAAW,UAAU,CAAC,EAAE,SAAS;AACrC,QAAI,CAAC,WAAW,UAAU,QAAQ;AAAG,aAAO;AAAA,EAC9C;AACA,SAAO;AACT;AAtBS;AAgCT,SAAS,WAAW,UAAsB,UAAsB;AAC9D,MAAI,SAAS,iBAAiB,aAAa,SAAS,CAAC,GAAG,SAAS,CAAC,CAAC,CAAC;AACpE,MAAI,SAAS,iBAAiB,aAAa,SAAS,CAAC,GAAG,SAAS,CAAC,CAAC,CAAC;AACpE,SAAO,WAAW,WAAW,SAAS,UAAU,QAAQ;AAC1D;AAJS;AAcT,SAAS,QAAQ,SAAkC,MAAc;AAC/D,MAAK,QAAoB,YAAa,QAAoB,SAAS;AACjE,WAAQ,QAAoB,SAAS;AACvC,MAAI,QAAQ;AAAM,WAAO,QAAQ;AACjC,QAAM,IAAI,MAAM,gCAAgC,IAAI;AACtD;AALS;AAQT,IAAO,gCAAQ","sourcesContent":["import { Feature, Geometry, LineString, Position } from \"geojson\";\nimport { cleanCoords } from \"@turf/clean-coords\";\nimport { lineSegment } from \"@turf/line-segment\";\nimport { rhumbBearing } from \"@turf/rhumb-bearing\";\nimport { bearingToAzimuth } from \"@turf/helpers\";\n\n/**\n * Boolean-Parallel returns True if each segment of `line1` is parallel to the correspondent segment of `line2`\n *\n * @name booleanParallel\n * @param {Geometry|Feature<LineString>} line1 GeoJSON Feature or Geometry\n * @param {Geometry|Feature<LineString>} line2 GeoJSON Feature or Geometry\n * @returns {boolean} true/false if the lines are parallel\n * @example\n * var line1 = turf.lineString([[0, 0], [0, 1]]);\n * var line2 = turf.lineString([[1, 0], [1, 1]]);\n *\n * turf.booleanParallel(line1, line2);\n * //=true\n */\nfunction booleanParallel(\n line1: Feature<LineString> | LineString,\n line2: Feature<LineString> | LineString\n): boolean {\n // validation\n if (!line1) throw new Error(\"line1 is required\");\n if (!line2) throw new Error(\"line2 is required\");\n var type1 = getType(line1, \"line1\");\n if (type1 !== \"LineString\") throw new Error(\"line1 must be a LineString\");\n var type2 = getType(line2, \"line2\");\n if (type2 !== \"LineString\") throw new Error(\"line2 must be a LineString\");\n\n var segments1 = lineSegment(cleanCoords(line1)).features;\n var segments2 = lineSegment(cleanCoords(line2)).features;\n\n for (var i = 0; i < segments1.length; i++) {\n var segment1 = segments1[i].geometry.coordinates;\n if (!segments2[i]) break;\n var segment2 = segments2[i].geometry.coordinates;\n if (!isParallel(segment1, segment2)) return false;\n }\n return true;\n}\n\n/**\n * Compares slopes and return result\n *\n * @private\n * @param {Geometry|Feature<LineString>} segment1 Geometry or Feature\n * @param {Geometry|Feature<LineString>} segment2 Geometry or Feature\n * @returns {boolean} if slopes are equal\n */\nfunction isParallel(segment1: Position[], segment2: Position[]) {\n var slope1 = bearingToAzimuth(rhumbBearing(segment1[0], segment1[1]));\n var slope2 = bearingToAzimuth(rhumbBearing(segment2[0], segment2[1]));\n return slope1 === slope2 || (slope2 - slope1) % 180 === 0;\n}\n\n/**\n * Returns Feature's type\n *\n * @private\n * @param {Geometry|Feature<any>} geojson Geometry or Feature\n * @param {string} name of the variable\n * @returns {string} Feature's type\n */\nfunction getType(geojson: Geometry | Feature<any>, name: string) {\n if ((geojson as Feature).geometry && (geojson as Feature).geometry.type)\n return (geojson as Feature).geometry.type;\n if (geojson.type) return geojson.type; // if GeoJSON geometry\n throw new Error(\"Invalid GeoJSON object for \" + name);\n}\n\nexport { booleanParallel };\nexport default booleanParallel;\n"]}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { Feature, LineString } from
|
|
1
|
+
import { Feature, LineString } from 'geojson';
|
|
2
|
+
|
|
2
3
|
/**
|
|
3
4
|
* Boolean-Parallel returns True if each segment of `line1` is parallel to the correspondent segment of `line2`
|
|
4
5
|
*
|
|
@@ -14,4 +15,5 @@ import { Feature, LineString } from "geojson";
|
|
|
14
15
|
* //=true
|
|
15
16
|
*/
|
|
16
17
|
declare function booleanParallel(line1: Feature<LineString> | LineString, line2: Feature<LineString> | LineString): boolean;
|
|
17
|
-
|
|
18
|
+
|
|
19
|
+
export { booleanParallel, booleanParallel as default };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Feature, LineString } from 'geojson';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Boolean-Parallel returns True if each segment of `line1` is parallel to the correspondent segment of `line2`
|
|
5
|
+
*
|
|
6
|
+
* @name booleanParallel
|
|
7
|
+
* @param {Geometry|Feature<LineString>} line1 GeoJSON Feature or Geometry
|
|
8
|
+
* @param {Geometry|Feature<LineString>} line2 GeoJSON Feature or Geometry
|
|
9
|
+
* @returns {boolean} true/false if the lines are parallel
|
|
10
|
+
* @example
|
|
11
|
+
* var line1 = turf.lineString([[0, 0], [0, 1]]);
|
|
12
|
+
* var line2 = turf.lineString([[1, 0], [1, 1]]);
|
|
13
|
+
*
|
|
14
|
+
* turf.booleanParallel(line1, line2);
|
|
15
|
+
* //=true
|
|
16
|
+
*/
|
|
17
|
+
declare function booleanParallel(line1: Feature<LineString> | LineString, line2: Feature<LineString> | LineString): boolean;
|
|
18
|
+
|
|
19
|
+
export { booleanParallel, booleanParallel as default };
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
+
|
|
4
|
+
// index.ts
|
|
5
|
+
import { cleanCoords } from "@turf/clean-coords";
|
|
6
|
+
import { lineSegment } from "@turf/line-segment";
|
|
7
|
+
import { rhumbBearing } from "@turf/rhumb-bearing";
|
|
8
|
+
import { bearingToAzimuth } from "@turf/helpers";
|
|
9
|
+
function booleanParallel(line1, line2) {
|
|
10
|
+
if (!line1)
|
|
11
|
+
throw new Error("line1 is required");
|
|
12
|
+
if (!line2)
|
|
13
|
+
throw new Error("line2 is required");
|
|
14
|
+
var type1 = getType(line1, "line1");
|
|
15
|
+
if (type1 !== "LineString")
|
|
16
|
+
throw new Error("line1 must be a LineString");
|
|
17
|
+
var type2 = getType(line2, "line2");
|
|
18
|
+
if (type2 !== "LineString")
|
|
19
|
+
throw new Error("line2 must be a LineString");
|
|
20
|
+
var segments1 = lineSegment(cleanCoords(line1)).features;
|
|
21
|
+
var segments2 = lineSegment(cleanCoords(line2)).features;
|
|
22
|
+
for (var i = 0; i < segments1.length; i++) {
|
|
23
|
+
var segment1 = segments1[i].geometry.coordinates;
|
|
24
|
+
if (!segments2[i])
|
|
25
|
+
break;
|
|
26
|
+
var segment2 = segments2[i].geometry.coordinates;
|
|
27
|
+
if (!isParallel(segment1, segment2))
|
|
28
|
+
return false;
|
|
29
|
+
}
|
|
30
|
+
return true;
|
|
31
|
+
}
|
|
32
|
+
__name(booleanParallel, "booleanParallel");
|
|
33
|
+
function isParallel(segment1, segment2) {
|
|
34
|
+
var slope1 = bearingToAzimuth(rhumbBearing(segment1[0], segment1[1]));
|
|
35
|
+
var slope2 = bearingToAzimuth(rhumbBearing(segment2[0], segment2[1]));
|
|
36
|
+
return slope1 === slope2 || (slope2 - slope1) % 180 === 0;
|
|
37
|
+
}
|
|
38
|
+
__name(isParallel, "isParallel");
|
|
39
|
+
function getType(geojson, name) {
|
|
40
|
+
if (geojson.geometry && geojson.geometry.type)
|
|
41
|
+
return geojson.geometry.type;
|
|
42
|
+
if (geojson.type)
|
|
43
|
+
return geojson.type;
|
|
44
|
+
throw new Error("Invalid GeoJSON object for " + name);
|
|
45
|
+
}
|
|
46
|
+
__name(getType, "getType");
|
|
47
|
+
var turf_boolean_parallel_default = booleanParallel;
|
|
48
|
+
export {
|
|
49
|
+
booleanParallel,
|
|
50
|
+
turf_boolean_parallel_default as default
|
|
51
|
+
};
|
|
52
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../index.ts"],"sourcesContent":["import { Feature, Geometry, LineString, Position } from \"geojson\";\nimport { cleanCoords } from \"@turf/clean-coords\";\nimport { lineSegment } from \"@turf/line-segment\";\nimport { rhumbBearing } from \"@turf/rhumb-bearing\";\nimport { bearingToAzimuth } from \"@turf/helpers\";\n\n/**\n * Boolean-Parallel returns True if each segment of `line1` is parallel to the correspondent segment of `line2`\n *\n * @name booleanParallel\n * @param {Geometry|Feature<LineString>} line1 GeoJSON Feature or Geometry\n * @param {Geometry|Feature<LineString>} line2 GeoJSON Feature or Geometry\n * @returns {boolean} true/false if the lines are parallel\n * @example\n * var line1 = turf.lineString([[0, 0], [0, 1]]);\n * var line2 = turf.lineString([[1, 0], [1, 1]]);\n *\n * turf.booleanParallel(line1, line2);\n * //=true\n */\nfunction booleanParallel(\n line1: Feature<LineString> | LineString,\n line2: Feature<LineString> | LineString\n): boolean {\n // validation\n if (!line1) throw new Error(\"line1 is required\");\n if (!line2) throw new Error(\"line2 is required\");\n var type1 = getType(line1, \"line1\");\n if (type1 !== \"LineString\") throw new Error(\"line1 must be a LineString\");\n var type2 = getType(line2, \"line2\");\n if (type2 !== \"LineString\") throw new Error(\"line2 must be a LineString\");\n\n var segments1 = lineSegment(cleanCoords(line1)).features;\n var segments2 = lineSegment(cleanCoords(line2)).features;\n\n for (var i = 0; i < segments1.length; i++) {\n var segment1 = segments1[i].geometry.coordinates;\n if (!segments2[i]) break;\n var segment2 = segments2[i].geometry.coordinates;\n if (!isParallel(segment1, segment2)) return false;\n }\n return true;\n}\n\n/**\n * Compares slopes and return result\n *\n * @private\n * @param {Geometry|Feature<LineString>} segment1 Geometry or Feature\n * @param {Geometry|Feature<LineString>} segment2 Geometry or Feature\n * @returns {boolean} if slopes are equal\n */\nfunction isParallel(segment1: Position[], segment2: Position[]) {\n var slope1 = bearingToAzimuth(rhumbBearing(segment1[0], segment1[1]));\n var slope2 = bearingToAzimuth(rhumbBearing(segment2[0], segment2[1]));\n return slope1 === slope2 || (slope2 - slope1) % 180 === 0;\n}\n\n/**\n * Returns Feature's type\n *\n * @private\n * @param {Geometry|Feature<any>} geojson Geometry or Feature\n * @param {string} name of the variable\n * @returns {string} Feature's type\n */\nfunction getType(geojson: Geometry | Feature<any>, name: string) {\n if ((geojson as Feature).geometry && (geojson as Feature).geometry.type)\n return (geojson as Feature).geometry.type;\n if (geojson.type) return geojson.type; // if GeoJSON geometry\n throw new Error(\"Invalid GeoJSON object for \" + name);\n}\n\nexport { booleanParallel };\nexport default booleanParallel;\n"],"mappings":";;;;AACA,SAAS,mBAAmB;AAC5B,SAAS,mBAAmB;AAC5B,SAAS,oBAAoB;AAC7B,SAAS,wBAAwB;AAgBjC,SAAS,gBACP,OACA,OACS;AAET,MAAI,CAAC;AAAO,UAAM,IAAI,MAAM,mBAAmB;AAC/C,MAAI,CAAC;AAAO,UAAM,IAAI,MAAM,mBAAmB;AAC/C,MAAI,QAAQ,QAAQ,OAAO,OAAO;AAClC,MAAI,UAAU;AAAc,UAAM,IAAI,MAAM,4BAA4B;AACxE,MAAI,QAAQ,QAAQ,OAAO,OAAO;AAClC,MAAI,UAAU;AAAc,UAAM,IAAI,MAAM,4BAA4B;AAExE,MAAI,YAAY,YAAY,YAAY,KAAK,CAAC,EAAE;AAChD,MAAI,YAAY,YAAY,YAAY,KAAK,CAAC,EAAE;AAEhD,WAAS,IAAI,GAAG,IAAI,UAAU,QAAQ,KAAK;AACzC,QAAI,WAAW,UAAU,CAAC,EAAE,SAAS;AACrC,QAAI,CAAC,UAAU,CAAC;AAAG;AACnB,QAAI,WAAW,UAAU,CAAC,EAAE,SAAS;AACrC,QAAI,CAAC,WAAW,UAAU,QAAQ;AAAG,aAAO;AAAA,EAC9C;AACA,SAAO;AACT;AAtBS;AAgCT,SAAS,WAAW,UAAsB,UAAsB;AAC9D,MAAI,SAAS,iBAAiB,aAAa,SAAS,CAAC,GAAG,SAAS,CAAC,CAAC,CAAC;AACpE,MAAI,SAAS,iBAAiB,aAAa,SAAS,CAAC,GAAG,SAAS,CAAC,CAAC,CAAC;AACpE,SAAO,WAAW,WAAW,SAAS,UAAU,QAAQ;AAC1D;AAJS;AAcT,SAAS,QAAQ,SAAkC,MAAc;AAC/D,MAAK,QAAoB,YAAa,QAAoB,SAAS;AACjE,WAAQ,QAAoB,SAAS;AACvC,MAAI,QAAQ;AAAM,WAAO,QAAQ;AACjC,QAAM,IAAI,MAAM,gCAAgC,IAAI;AACtD;AALS;AAQT,IAAO,gCAAQ;","names":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@turf/boolean-parallel",
|
|
3
|
-
"version": "7.0.0-alpha.
|
|
3
|
+
"version": "7.0.0-alpha.111+08576cb50",
|
|
4
4
|
"description": "turf boolean-parallel module",
|
|
5
5
|
"author": "Turf Authors",
|
|
6
6
|
"contributors": [
|
|
@@ -25,47 +25,52 @@
|
|
|
25
25
|
"boolean",
|
|
26
26
|
"boolean-parallel"
|
|
27
27
|
],
|
|
28
|
-
"
|
|
29
|
-
"
|
|
28
|
+
"type": "commonjs",
|
|
29
|
+
"main": "dist/cjs/index.cjs",
|
|
30
|
+
"module": "dist/esm/index.mjs",
|
|
31
|
+
"types": "dist/cjs/index.d.ts",
|
|
30
32
|
"exports": {
|
|
31
33
|
"./package.json": "./package.json",
|
|
32
34
|
".": {
|
|
33
|
-
"
|
|
34
|
-
|
|
35
|
-
|
|
35
|
+
"import": {
|
|
36
|
+
"types": "./dist/esm/index.d.mts",
|
|
37
|
+
"default": "./dist/esm/index.mjs"
|
|
38
|
+
},
|
|
39
|
+
"require": {
|
|
40
|
+
"types": "./dist/cjs/index.d.ts",
|
|
41
|
+
"default": "./dist/cjs/index.cjs"
|
|
42
|
+
}
|
|
36
43
|
}
|
|
37
44
|
},
|
|
38
|
-
"types": "dist/js/index.d.ts",
|
|
39
45
|
"sideEffects": false,
|
|
40
46
|
"files": [
|
|
41
47
|
"dist"
|
|
42
48
|
],
|
|
43
49
|
"scripts": {
|
|
44
|
-
"bench": "tsx bench.
|
|
45
|
-
"build": "
|
|
46
|
-
"
|
|
47
|
-
"
|
|
48
|
-
"
|
|
49
|
-
"test": "npm-run-all test:*",
|
|
50
|
-
"test:tape": "tsx test.js"
|
|
50
|
+
"bench": "tsx bench.ts",
|
|
51
|
+
"build": "tsup --config ../../tsup.config.ts",
|
|
52
|
+
"docs": "tsx ../../scripts/generate-readmes.ts",
|
|
53
|
+
"test": "npm-run-all --npm-path npm test:*",
|
|
54
|
+
"test:tape": "tsx test.ts"
|
|
51
55
|
},
|
|
52
56
|
"devDependencies": {
|
|
53
|
-
"@types/
|
|
54
|
-
"
|
|
55
|
-
"
|
|
56
|
-
"
|
|
57
|
-
"
|
|
58
|
-
"
|
|
59
|
-
"
|
|
60
|
-
"
|
|
61
|
-
"
|
|
57
|
+
"@types/benchmark": "^2.1.5",
|
|
58
|
+
"@types/tape": "^4.2.32",
|
|
59
|
+
"benchmark": "^2.1.4",
|
|
60
|
+
"load-json-file": "^7.0.1",
|
|
61
|
+
"npm-run-all": "^4.1.5",
|
|
62
|
+
"tape": "^5.7.2",
|
|
63
|
+
"tsup": "^8.0.1",
|
|
64
|
+
"tsx": "^4.6.2",
|
|
65
|
+
"typescript": "^5.2.2",
|
|
66
|
+
"write-json-file": "^5.0.0"
|
|
62
67
|
},
|
|
63
68
|
"dependencies": {
|
|
64
|
-
"@turf/clean-coords": "^7.0.0-alpha.
|
|
65
|
-
"@turf/helpers": "^7.0.0-alpha.
|
|
66
|
-
"@turf/line-segment": "^7.0.0-alpha.
|
|
67
|
-
"@turf/rhumb-bearing": "^7.0.0-alpha.
|
|
68
|
-
"tslib": "^2.
|
|
69
|
+
"@turf/clean-coords": "^7.0.0-alpha.111+08576cb50",
|
|
70
|
+
"@turf/helpers": "^7.0.0-alpha.111+08576cb50",
|
|
71
|
+
"@turf/line-segment": "^7.0.0-alpha.111+08576cb50",
|
|
72
|
+
"@turf/rhumb-bearing": "^7.0.0-alpha.111+08576cb50",
|
|
73
|
+
"tslib": "^2.6.2"
|
|
69
74
|
},
|
|
70
|
-
"gitHead": "
|
|
75
|
+
"gitHead": "08576cb50376e0199aea02dbd887e3af83672246"
|
|
71
76
|
}
|
package/dist/es/index.js
DELETED
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
import cleanCoords from "@turf/clean-coords";
|
|
2
|
-
import lineSegment from "@turf/line-segment";
|
|
3
|
-
import rhumbBearing from "@turf/rhumb-bearing";
|
|
4
|
-
import { bearingToAzimuth } from "@turf/helpers";
|
|
5
|
-
/**
|
|
6
|
-
* Boolean-Parallel returns True if each segment of `line1` is parallel to the correspondent segment of `line2`
|
|
7
|
-
*
|
|
8
|
-
* @name booleanParallel
|
|
9
|
-
* @param {Geometry|Feature<LineString>} line1 GeoJSON Feature or Geometry
|
|
10
|
-
* @param {Geometry|Feature<LineString>} line2 GeoJSON Feature or Geometry
|
|
11
|
-
* @returns {boolean} true/false if the lines are parallel
|
|
12
|
-
* @example
|
|
13
|
-
* var line1 = turf.lineString([[0, 0], [0, 1]]);
|
|
14
|
-
* var line2 = turf.lineString([[1, 0], [1, 1]]);
|
|
15
|
-
*
|
|
16
|
-
* turf.booleanParallel(line1, line2);
|
|
17
|
-
* //=true
|
|
18
|
-
*/
|
|
19
|
-
function booleanParallel(line1, line2) {
|
|
20
|
-
// validation
|
|
21
|
-
if (!line1)
|
|
22
|
-
throw new Error("line1 is required");
|
|
23
|
-
if (!line2)
|
|
24
|
-
throw new Error("line2 is required");
|
|
25
|
-
var type1 = getType(line1, "line1");
|
|
26
|
-
if (type1 !== "LineString")
|
|
27
|
-
throw new Error("line1 must be a LineString");
|
|
28
|
-
var type2 = getType(line2, "line2");
|
|
29
|
-
if (type2 !== "LineString")
|
|
30
|
-
throw new Error("line2 must be a LineString");
|
|
31
|
-
var segments1 = lineSegment(cleanCoords(line1)).features;
|
|
32
|
-
var segments2 = lineSegment(cleanCoords(line2)).features;
|
|
33
|
-
for (var i = 0; i < segments1.length; i++) {
|
|
34
|
-
var segment1 = segments1[i].geometry.coordinates;
|
|
35
|
-
if (!segments2[i])
|
|
36
|
-
break;
|
|
37
|
-
var segment2 = segments2[i].geometry.coordinates;
|
|
38
|
-
if (!isParallel(segment1, segment2))
|
|
39
|
-
return false;
|
|
40
|
-
}
|
|
41
|
-
return true;
|
|
42
|
-
}
|
|
43
|
-
/**
|
|
44
|
-
* Compares slopes and return result
|
|
45
|
-
*
|
|
46
|
-
* @private
|
|
47
|
-
* @param {Geometry|Feature<LineString>} segment1 Geometry or Feature
|
|
48
|
-
* @param {Geometry|Feature<LineString>} segment2 Geometry or Feature
|
|
49
|
-
* @returns {boolean} if slopes are equal
|
|
50
|
-
*/
|
|
51
|
-
function isParallel(segment1, segment2) {
|
|
52
|
-
var slope1 = bearingToAzimuth(rhumbBearing(segment1[0], segment1[1]));
|
|
53
|
-
var slope2 = bearingToAzimuth(rhumbBearing(segment2[0], segment2[1]));
|
|
54
|
-
return slope1 === slope2;
|
|
55
|
-
}
|
|
56
|
-
/**
|
|
57
|
-
* Returns Feature's type
|
|
58
|
-
*
|
|
59
|
-
* @private
|
|
60
|
-
* @param {Geometry|Feature<any>} geojson Geometry or Feature
|
|
61
|
-
* @param {string} name of the variable
|
|
62
|
-
* @returns {string} Feature's type
|
|
63
|
-
*/
|
|
64
|
-
function getType(geojson, name) {
|
|
65
|
-
if (geojson.geometry && geojson.geometry.type)
|
|
66
|
-
return geojson.geometry.type;
|
|
67
|
-
if (geojson.type)
|
|
68
|
-
return geojson.type; // if GeoJSON geometry
|
|
69
|
-
throw new Error("Invalid GeoJSON object for " + name);
|
|
70
|
-
}
|
|
71
|
-
export default booleanParallel;
|
package/dist/es/package.json
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"type":"module"}
|
package/dist/js/index.js
DELETED
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const tslib_1 = require("tslib");
|
|
4
|
-
const clean_coords_1 = tslib_1.__importDefault(require("@turf/clean-coords"));
|
|
5
|
-
const line_segment_1 = tslib_1.__importDefault(require("@turf/line-segment"));
|
|
6
|
-
const rhumb_bearing_1 = tslib_1.__importDefault(require("@turf/rhumb-bearing"));
|
|
7
|
-
const helpers_1 = require("@turf/helpers");
|
|
8
|
-
/**
|
|
9
|
-
* Boolean-Parallel returns True if each segment of `line1` is parallel to the correspondent segment of `line2`
|
|
10
|
-
*
|
|
11
|
-
* @name booleanParallel
|
|
12
|
-
* @param {Geometry|Feature<LineString>} line1 GeoJSON Feature or Geometry
|
|
13
|
-
* @param {Geometry|Feature<LineString>} line2 GeoJSON Feature or Geometry
|
|
14
|
-
* @returns {boolean} true/false if the lines are parallel
|
|
15
|
-
* @example
|
|
16
|
-
* var line1 = turf.lineString([[0, 0], [0, 1]]);
|
|
17
|
-
* var line2 = turf.lineString([[1, 0], [1, 1]]);
|
|
18
|
-
*
|
|
19
|
-
* turf.booleanParallel(line1, line2);
|
|
20
|
-
* //=true
|
|
21
|
-
*/
|
|
22
|
-
function booleanParallel(line1, line2) {
|
|
23
|
-
// validation
|
|
24
|
-
if (!line1)
|
|
25
|
-
throw new Error("line1 is required");
|
|
26
|
-
if (!line2)
|
|
27
|
-
throw new Error("line2 is required");
|
|
28
|
-
var type1 = getType(line1, "line1");
|
|
29
|
-
if (type1 !== "LineString")
|
|
30
|
-
throw new Error("line1 must be a LineString");
|
|
31
|
-
var type2 = getType(line2, "line2");
|
|
32
|
-
if (type2 !== "LineString")
|
|
33
|
-
throw new Error("line2 must be a LineString");
|
|
34
|
-
var segments1 = line_segment_1.default(clean_coords_1.default(line1)).features;
|
|
35
|
-
var segments2 = line_segment_1.default(clean_coords_1.default(line2)).features;
|
|
36
|
-
for (var i = 0; i < segments1.length; i++) {
|
|
37
|
-
var segment1 = segments1[i].geometry.coordinates;
|
|
38
|
-
if (!segments2[i])
|
|
39
|
-
break;
|
|
40
|
-
var segment2 = segments2[i].geometry.coordinates;
|
|
41
|
-
if (!isParallel(segment1, segment2))
|
|
42
|
-
return false;
|
|
43
|
-
}
|
|
44
|
-
return true;
|
|
45
|
-
}
|
|
46
|
-
/**
|
|
47
|
-
* Compares slopes and return result
|
|
48
|
-
*
|
|
49
|
-
* @private
|
|
50
|
-
* @param {Geometry|Feature<LineString>} segment1 Geometry or Feature
|
|
51
|
-
* @param {Geometry|Feature<LineString>} segment2 Geometry or Feature
|
|
52
|
-
* @returns {boolean} if slopes are equal
|
|
53
|
-
*/
|
|
54
|
-
function isParallel(segment1, segment2) {
|
|
55
|
-
var slope1 = helpers_1.bearingToAzimuth(rhumb_bearing_1.default(segment1[0], segment1[1]));
|
|
56
|
-
var slope2 = helpers_1.bearingToAzimuth(rhumb_bearing_1.default(segment2[0], segment2[1]));
|
|
57
|
-
return slope1 === slope2;
|
|
58
|
-
}
|
|
59
|
-
/**
|
|
60
|
-
* Returns Feature's type
|
|
61
|
-
*
|
|
62
|
-
* @private
|
|
63
|
-
* @param {Geometry|Feature<any>} geojson Geometry or Feature
|
|
64
|
-
* @param {string} name of the variable
|
|
65
|
-
* @returns {string} Feature's type
|
|
66
|
-
*/
|
|
67
|
-
function getType(geojson, name) {
|
|
68
|
-
if (geojson.geometry && geojson.geometry.type)
|
|
69
|
-
return geojson.geometry.type;
|
|
70
|
-
if (geojson.type)
|
|
71
|
-
return geojson.type; // if GeoJSON geometry
|
|
72
|
-
throw new Error("Invalid GeoJSON object for " + name);
|
|
73
|
-
}
|
|
74
|
-
exports.default = booleanParallel;
|