@turf/kinks 7.0.0-alpha.2 → 7.0.0
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 +24 -20
- package/dist/cjs/index.cjs +35 -0
- package/dist/cjs/index.cjs.map +1 -0
- package/dist/cjs/index.d.cts +27 -0
- package/dist/{js → esm}/index.d.ts +5 -2
- package/dist/esm/index.js +35 -0
- package/dist/esm/index.js.map +1 -0
- package/package.json +33 -26
- package/dist/es/index.js +0 -42
- package/dist/es/package.json +0 -1
- package/dist/js/index.js +0 -46
package/README.md
CHANGED
|
@@ -10,62 +10,66 @@ returns [points][5] at all self-intersections.
|
|
|
10
10
|
|
|
11
11
|
### Parameters
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
* `featureIn` **[Feature][6]<([LineString][7] | [MultiLineString][8] | [MultiPolygon][9] | [Polygon][10])>** input feature
|
|
14
14
|
|
|
15
15
|
### Examples
|
|
16
16
|
|
|
17
17
|
```javascript
|
|
18
|
-
var poly = turf.polygon([
|
|
19
|
-
[
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
],
|
|
26
|
-
]);
|
|
18
|
+
var poly = turf.polygon([[
|
|
19
|
+
[-12.034835, 8.901183],
|
|
20
|
+
[-12.060413, 8.899826],
|
|
21
|
+
[-12.03638, 8.873199],
|
|
22
|
+
[-12.059383, 8.871418],
|
|
23
|
+
[-12.034835, 8.901183]
|
|
24
|
+
]]);
|
|
27
25
|
|
|
28
26
|
var kinks = turf.kinks(poly);
|
|
29
27
|
|
|
30
28
|
//addToMap
|
|
31
|
-
var addToMap = [poly, kinks]
|
|
29
|
+
var addToMap = [poly, kinks]
|
|
32
30
|
```
|
|
33
31
|
|
|
34
32
|
Returns **[FeatureCollection][11]<[Point][12]>** self-intersections
|
|
35
33
|
|
|
36
34
|
[1]: https://tools.ietf.org/html/rfc7946#section-3.1.4
|
|
35
|
+
|
|
37
36
|
[2]: https://tools.ietf.org/html/rfc7946#section-3.1.5
|
|
37
|
+
|
|
38
38
|
[3]: https://tools.ietf.org/html/rfc7946#section-3.1.7
|
|
39
|
+
|
|
39
40
|
[4]: https://tools.ietf.org/html/rfc7946#section-3.1.6
|
|
41
|
+
|
|
40
42
|
[5]: https://tools.ietf.org/html/rfc7946#section-3.1.2
|
|
43
|
+
|
|
41
44
|
[6]: https://tools.ietf.org/html/rfc7946#section-3.2
|
|
45
|
+
|
|
42
46
|
[7]: https://tools.ietf.org/html/rfc7946#section-3.1.4
|
|
47
|
+
|
|
43
48
|
[8]: https://tools.ietf.org/html/rfc7946#section-3.1.5
|
|
49
|
+
|
|
44
50
|
[9]: https://tools.ietf.org/html/rfc7946#section-3.1.7
|
|
51
|
+
|
|
45
52
|
[10]: https://tools.ietf.org/html/rfc7946#section-3.1.6
|
|
53
|
+
|
|
46
54
|
[11]: https://tools.ietf.org/html/rfc7946#section-3.3
|
|
55
|
+
|
|
47
56
|
[12]: https://tools.ietf.org/html/rfc7946#section-3.1.2
|
|
48
57
|
|
|
49
|
-
<!-- This file is automatically generated. Please don't edit it directly
|
|
50
|
-
if you find an error, edit the source file (likely index.js), and re-run
|
|
51
|
-
./scripts/generate-readmes in the turf project. -->
|
|
58
|
+
<!-- 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. -->
|
|
52
59
|
|
|
53
60
|
---
|
|
54
61
|
|
|
55
|
-
This module is part of the [Turfjs project](
|
|
56
|
-
module collection dedicated to geographic algorithms. It is maintained in the
|
|
57
|
-
[Turfjs/turf](https://github.com/Turfjs/turf) repository, where you can create
|
|
58
|
-
PRs and issues.
|
|
62
|
+
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.
|
|
59
63
|
|
|
60
64
|
### Installation
|
|
61
65
|
|
|
62
|
-
Install this module individually:
|
|
66
|
+
Install this single module individually:
|
|
63
67
|
|
|
64
68
|
```sh
|
|
65
69
|
$ npm install @turf/kinks
|
|
66
70
|
```
|
|
67
71
|
|
|
68
|
-
Or install the
|
|
72
|
+
Or install the all-encompassing @turf/turf module that includes all modules as functions:
|
|
69
73
|
|
|
70
74
|
```sh
|
|
71
75
|
$ npm install @turf/turf
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }var __defProp = Object.defineProperty;
|
|
2
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
+
|
|
4
|
+
// index.ts
|
|
5
|
+
var _helpers = require('@turf/helpers');
|
|
6
|
+
|
|
7
|
+
// lib/sweepline-intersections-export.ts
|
|
8
|
+
var _sweeplineintersections = require('sweepline-intersections'); var _sweeplineintersections2 = _interopRequireDefault(_sweeplineintersections);
|
|
9
|
+
var sweeplineIntersections = _sweeplineintersections2.default;
|
|
10
|
+
|
|
11
|
+
// index.ts
|
|
12
|
+
function kinks(featureIn) {
|
|
13
|
+
const results = {
|
|
14
|
+
type: "FeatureCollection",
|
|
15
|
+
features: []
|
|
16
|
+
};
|
|
17
|
+
if (featureIn.type === "Feature" && (featureIn.geometry.type === "Point" || featureIn.geometry.type === "MultiPoint")) {
|
|
18
|
+
throw new Error(
|
|
19
|
+
"Input must be a LineString, MultiLineString, Polygon, or MultiPolygon Feature or Geometry"
|
|
20
|
+
);
|
|
21
|
+
}
|
|
22
|
+
const intersections = sweeplineIntersections(featureIn, false);
|
|
23
|
+
for (let i = 0; i < intersections.length; ++i) {
|
|
24
|
+
const intersection = intersections[i];
|
|
25
|
+
results.features.push(_helpers.point.call(void 0, [intersection[0], intersection[1]]));
|
|
26
|
+
}
|
|
27
|
+
return results;
|
|
28
|
+
}
|
|
29
|
+
__name(kinks, "kinks");
|
|
30
|
+
var turf_kinks_default = kinks;
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
exports.default = turf_kinks_default; exports.kinks = kinks;
|
|
35
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../index.ts","../../lib/sweepline-intersections-export.ts"],"names":[],"mappings":";;;;AASA,SAAS,aAAa;;;ACLtB,OAAO,SAAS;AAET,IAAM,yBAAyB;;;AD4BtC,SAAS,MACP,WAC0B;AAC1B,QAAM,UAAoC;AAAA,IACxC,MAAM;AAAA,IACN,UAAU,CAAC;AAAA,EACb;AACA,MACE,UAAU,SAAS,cACjB,UAAsB,SAAS,SAAS,WACvC,UAAsB,SAAS,SAAS,eAC3C;AACA,UAAM,IAAI;AAAA,MACR;AAAA,IAEF;AAAA,EACF;AACA,QAAM,gBAAgB,uBAAkB,WAAW,KAAK;AACxD,WAAS,IAAI,GAAG,IAAI,cAAc,QAAQ,EAAE,GAAG;AAC7C,UAAM,eAAe,cAAc,CAAC;AACpC,YAAQ,SAAS,KAAK,MAAM,CAAC,aAAa,CAAC,GAAG,aAAa,CAAC,CAAC,CAAC,CAAC;AAAA,EACjE;AACA,SAAO;AACT;AAvBS;AA0BT,IAAO,qBAAQ","sourcesContent":["import {\n Feature,\n FeatureCollection,\n LineString,\n MultiLineString,\n MultiPolygon,\n Point,\n Polygon,\n} from \"geojson\";\nimport { point } from \"@turf/helpers\";\nimport { sweeplineIntersections as findIntersections } from \"./lib/sweepline-intersections-export.js\";\n\n/**\n * Takes a {@link LineString|linestring}, {@link MultiLineString|multi-linestring},\n * {@link MultiPolygon|multi-polygon} or {@link Polygon|polygon} and\n * returns {@link Point|points} at all self-intersections.\n *\n * @name kinks\n * @param {Feature<LineString|MultiLineString|MultiPolygon|Polygon>} featureIn input feature\n * @returns {FeatureCollection<Point>} self-intersections\n * @example\n * var poly = turf.polygon([[\n * [-12.034835, 8.901183],\n * [-12.060413, 8.899826],\n * [-12.03638, 8.873199],\n * [-12.059383, 8.871418],\n * [-12.034835, 8.901183]\n * ]]);\n *\n * var kinks = turf.kinks(poly);\n *\n * //addToMap\n * var addToMap = [poly, kinks]\n */\nfunction kinks<T extends LineString | MultiLineString | Polygon | MultiPolygon>(\n featureIn: Feature<T>\n): FeatureCollection<Point> {\n const results: FeatureCollection<Point> = {\n type: \"FeatureCollection\",\n features: [],\n };\n if (\n featureIn.type === \"Feature\" &&\n ((featureIn as Feature).geometry.type === \"Point\" ||\n (featureIn as Feature).geometry.type === \"MultiPoint\")\n ) {\n throw new Error(\n \"Input must be a LineString, MultiLineString, \" +\n \"Polygon, or MultiPolygon Feature or Geometry\"\n );\n }\n const intersections = findIntersections(featureIn, false);\n for (let i = 0; i < intersections.length; ++i) {\n const intersection = intersections[i];\n results.features.push(point([intersection[0], intersection[1]]));\n }\n return results;\n}\n\nexport { kinks };\nexport default kinks;\n","// Get around problems with moduleResolution node16 and some older libraries.\n// Manifests as \"This expression is not callable ... has no call signatures\"\n// https://stackoverflow.com/a/74709714\n\nimport lib from \"sweepline-intersections\";\n\nexport const sweeplineIntersections = lib as unknown as typeof lib.default;\n"]}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { LineString, MultiLineString, Polygon, MultiPolygon, Feature, FeatureCollection, Point } from 'geojson';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Takes a {@link LineString|linestring}, {@link MultiLineString|multi-linestring},
|
|
5
|
+
* {@link MultiPolygon|multi-polygon} or {@link Polygon|polygon} and
|
|
6
|
+
* returns {@link Point|points} at all self-intersections.
|
|
7
|
+
*
|
|
8
|
+
* @name kinks
|
|
9
|
+
* @param {Feature<LineString|MultiLineString|MultiPolygon|Polygon>} featureIn input feature
|
|
10
|
+
* @returns {FeatureCollection<Point>} self-intersections
|
|
11
|
+
* @example
|
|
12
|
+
* var poly = turf.polygon([[
|
|
13
|
+
* [-12.034835, 8.901183],
|
|
14
|
+
* [-12.060413, 8.899826],
|
|
15
|
+
* [-12.03638, 8.873199],
|
|
16
|
+
* [-12.059383, 8.871418],
|
|
17
|
+
* [-12.034835, 8.901183]
|
|
18
|
+
* ]]);
|
|
19
|
+
*
|
|
20
|
+
* var kinks = turf.kinks(poly);
|
|
21
|
+
*
|
|
22
|
+
* //addToMap
|
|
23
|
+
* var addToMap = [poly, kinks]
|
|
24
|
+
*/
|
|
25
|
+
declare function kinks<T extends LineString | MultiLineString | Polygon | MultiPolygon>(featureIn: Feature<T>): FeatureCollection<Point>;
|
|
26
|
+
|
|
27
|
+
export { kinks as default, kinks };
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { LineString, MultiLineString, Polygon, MultiPolygon, Feature, FeatureCollection, Point } from 'geojson';
|
|
2
|
+
|
|
2
3
|
/**
|
|
3
4
|
* Takes a {@link LineString|linestring}, {@link MultiLineString|multi-linestring},
|
|
4
5
|
* {@link MultiPolygon|multi-polygon} or {@link Polygon|polygon} and
|
|
@@ -21,4 +22,6 @@ import { Feature, FeatureCollection, LineString, MultiLineString, MultiPolygon,
|
|
|
21
22
|
* //addToMap
|
|
22
23
|
* var addToMap = [poly, kinks]
|
|
23
24
|
*/
|
|
24
|
-
|
|
25
|
+
declare function kinks<T extends LineString | MultiLineString | Polygon | MultiPolygon>(featureIn: Feature<T>): FeatureCollection<Point>;
|
|
26
|
+
|
|
27
|
+
export { kinks as default, kinks };
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
+
|
|
4
|
+
// index.ts
|
|
5
|
+
import { point } from "@turf/helpers";
|
|
6
|
+
|
|
7
|
+
// lib/sweepline-intersections-export.ts
|
|
8
|
+
import lib from "sweepline-intersections";
|
|
9
|
+
var sweeplineIntersections = lib;
|
|
10
|
+
|
|
11
|
+
// index.ts
|
|
12
|
+
function kinks(featureIn) {
|
|
13
|
+
const results = {
|
|
14
|
+
type: "FeatureCollection",
|
|
15
|
+
features: []
|
|
16
|
+
};
|
|
17
|
+
if (featureIn.type === "Feature" && (featureIn.geometry.type === "Point" || featureIn.geometry.type === "MultiPoint")) {
|
|
18
|
+
throw new Error(
|
|
19
|
+
"Input must be a LineString, MultiLineString, Polygon, or MultiPolygon Feature or Geometry"
|
|
20
|
+
);
|
|
21
|
+
}
|
|
22
|
+
const intersections = sweeplineIntersections(featureIn, false);
|
|
23
|
+
for (let i = 0; i < intersections.length; ++i) {
|
|
24
|
+
const intersection = intersections[i];
|
|
25
|
+
results.features.push(point([intersection[0], intersection[1]]));
|
|
26
|
+
}
|
|
27
|
+
return results;
|
|
28
|
+
}
|
|
29
|
+
__name(kinks, "kinks");
|
|
30
|
+
var turf_kinks_default = kinks;
|
|
31
|
+
export {
|
|
32
|
+
turf_kinks_default as default,
|
|
33
|
+
kinks
|
|
34
|
+
};
|
|
35
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../index.ts","../../lib/sweepline-intersections-export.ts"],"sourcesContent":["import {\n Feature,\n FeatureCollection,\n LineString,\n MultiLineString,\n MultiPolygon,\n Point,\n Polygon,\n} from \"geojson\";\nimport { point } from \"@turf/helpers\";\nimport { sweeplineIntersections as findIntersections } from \"./lib/sweepline-intersections-export.js\";\n\n/**\n * Takes a {@link LineString|linestring}, {@link MultiLineString|multi-linestring},\n * {@link MultiPolygon|multi-polygon} or {@link Polygon|polygon} and\n * returns {@link Point|points} at all self-intersections.\n *\n * @name kinks\n * @param {Feature<LineString|MultiLineString|MultiPolygon|Polygon>} featureIn input feature\n * @returns {FeatureCollection<Point>} self-intersections\n * @example\n * var poly = turf.polygon([[\n * [-12.034835, 8.901183],\n * [-12.060413, 8.899826],\n * [-12.03638, 8.873199],\n * [-12.059383, 8.871418],\n * [-12.034835, 8.901183]\n * ]]);\n *\n * var kinks = turf.kinks(poly);\n *\n * //addToMap\n * var addToMap = [poly, kinks]\n */\nfunction kinks<T extends LineString | MultiLineString | Polygon | MultiPolygon>(\n featureIn: Feature<T>\n): FeatureCollection<Point> {\n const results: FeatureCollection<Point> = {\n type: \"FeatureCollection\",\n features: [],\n };\n if (\n featureIn.type === \"Feature\" &&\n ((featureIn as Feature).geometry.type === \"Point\" ||\n (featureIn as Feature).geometry.type === \"MultiPoint\")\n ) {\n throw new Error(\n \"Input must be a LineString, MultiLineString, \" +\n \"Polygon, or MultiPolygon Feature or Geometry\"\n );\n }\n const intersections = findIntersections(featureIn, false);\n for (let i = 0; i < intersections.length; ++i) {\n const intersection = intersections[i];\n results.features.push(point([intersection[0], intersection[1]]));\n }\n return results;\n}\n\nexport { kinks };\nexport default kinks;\n","// Get around problems with moduleResolution node16 and some older libraries.\n// Manifests as \"This expression is not callable ... has no call signatures\"\n// https://stackoverflow.com/a/74709714\n\nimport lib from \"sweepline-intersections\";\n\nexport const sweeplineIntersections = lib as unknown as typeof lib.default;\n"],"mappings":";;;;AASA,SAAS,aAAa;;;ACLtB,OAAO,SAAS;AAET,IAAM,yBAAyB;;;AD4BtC,SAAS,MACP,WAC0B;AAC1B,QAAM,UAAoC;AAAA,IACxC,MAAM;AAAA,IACN,UAAU,CAAC;AAAA,EACb;AACA,MACE,UAAU,SAAS,cACjB,UAAsB,SAAS,SAAS,WACvC,UAAsB,SAAS,SAAS,eAC3C;AACA,UAAM,IAAI;AAAA,MACR;AAAA,IAEF;AAAA,EACF;AACA,QAAM,gBAAgB,uBAAkB,WAAW,KAAK;AACxD,WAAS,IAAI,GAAG,IAAI,cAAc,QAAQ,EAAE,GAAG;AAC7C,UAAM,eAAe,cAAc,CAAC;AACpC,YAAQ,SAAS,KAAK,MAAM,CAAC,aAAa,CAAC,GAAG,aAAa,CAAC,CAAC,CAAC,CAAC;AAAA,EACjE;AACA,SAAO;AACT;AAvBS;AA0BT,IAAO,qBAAQ;","names":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@turf/kinks",
|
|
3
|
-
"version": "7.0.0
|
|
3
|
+
"version": "7.0.0",
|
|
4
4
|
"description": "turf kinks module",
|
|
5
5
|
"author": "Turf Authors",
|
|
6
6
|
"license": "MIT",
|
|
@@ -21,45 +21,52 @@
|
|
|
21
21
|
"kinks",
|
|
22
22
|
"self-intersection"
|
|
23
23
|
],
|
|
24
|
-
"
|
|
25
|
-
"
|
|
24
|
+
"type": "module",
|
|
25
|
+
"main": "dist/cjs/index.cjs",
|
|
26
|
+
"module": "dist/esm/index.js",
|
|
27
|
+
"types": "dist/esm/index.d.ts",
|
|
26
28
|
"exports": {
|
|
27
29
|
"./package.json": "./package.json",
|
|
28
30
|
".": {
|
|
29
|
-
"
|
|
30
|
-
|
|
31
|
-
|
|
31
|
+
"import": {
|
|
32
|
+
"types": "./dist/esm/index.d.ts",
|
|
33
|
+
"default": "./dist/esm/index.js"
|
|
34
|
+
},
|
|
35
|
+
"require": {
|
|
36
|
+
"types": "./dist/cjs/index.d.cts",
|
|
37
|
+
"default": "./dist/cjs/index.cjs"
|
|
38
|
+
}
|
|
32
39
|
}
|
|
33
40
|
},
|
|
34
|
-
"types": "dist/js/index.d.ts",
|
|
35
41
|
"sideEffects": false,
|
|
36
42
|
"files": [
|
|
37
43
|
"dist"
|
|
38
44
|
],
|
|
39
45
|
"scripts": {
|
|
40
|
-
"bench": "tsx bench.
|
|
41
|
-
"build": "
|
|
42
|
-
"
|
|
43
|
-
"
|
|
44
|
-
"
|
|
45
|
-
"test": "
|
|
46
|
-
"test:tape": "tsx test.js",
|
|
47
|
-
"test:types": "tsc --esModuleInterop --noEmit --strict types.ts"
|
|
46
|
+
"bench": "tsx bench.ts",
|
|
47
|
+
"build": "tsup --config ../../tsup.config.ts",
|
|
48
|
+
"docs": "tsx ../../scripts/generate-readmes.ts",
|
|
49
|
+
"test": "npm-run-all --npm-path npm test:*",
|
|
50
|
+
"test:tape": "tsx test.ts",
|
|
51
|
+
"test:types": "tsc --esModuleInterop --module node16 --moduleResolution node16 --noEmit --strict types.ts"
|
|
48
52
|
},
|
|
49
53
|
"devDependencies": {
|
|
50
|
-
"@turf/meta": "^7.0.0
|
|
51
|
-
"benchmark": "
|
|
52
|
-
"
|
|
53
|
-
"
|
|
54
|
-
"
|
|
55
|
-
"
|
|
56
|
-
"
|
|
57
|
-
"
|
|
54
|
+
"@turf/meta": "^7.0.0",
|
|
55
|
+
"@types/benchmark": "^2.1.5",
|
|
56
|
+
"@types/tape": "^4.2.32",
|
|
57
|
+
"benchmark": "^2.1.4",
|
|
58
|
+
"load-json-file": "^7.0.1",
|
|
59
|
+
"npm-run-all": "^4.1.5",
|
|
60
|
+
"tape": "^5.7.2",
|
|
61
|
+
"tsup": "^8.0.1",
|
|
62
|
+
"tsx": "^4.6.2",
|
|
63
|
+
"typescript": "^5.2.2",
|
|
64
|
+
"write-json-file": "^5.0.0"
|
|
58
65
|
},
|
|
59
66
|
"dependencies": {
|
|
60
|
-
"@turf/helpers": "^7.0.0
|
|
67
|
+
"@turf/helpers": "^7.0.0",
|
|
61
68
|
"sweepline-intersections": "^1.5.0",
|
|
62
|
-
"tslib": "^2.
|
|
69
|
+
"tslib": "^2.6.2"
|
|
63
70
|
},
|
|
64
|
-
"gitHead": "
|
|
71
|
+
"gitHead": "3d3a7917025fbabe191dbddbc89754b86f9c7739"
|
|
65
72
|
}
|
package/dist/es/index.js
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import findIntersections from "sweepline-intersections";
|
|
2
|
-
import { point } from "@turf/helpers";
|
|
3
|
-
/**
|
|
4
|
-
* Takes a {@link LineString|linestring}, {@link MultiLineString|multi-linestring},
|
|
5
|
-
* {@link MultiPolygon|multi-polygon} or {@link Polygon|polygon} and
|
|
6
|
-
* returns {@link Point|points} at all self-intersections.
|
|
7
|
-
*
|
|
8
|
-
* @name kinks
|
|
9
|
-
* @param {Feature<LineString|MultiLineString|MultiPolygon|Polygon>} featureIn input feature
|
|
10
|
-
* @returns {FeatureCollection<Point>} self-intersections
|
|
11
|
-
* @example
|
|
12
|
-
* var poly = turf.polygon([[
|
|
13
|
-
* [-12.034835, 8.901183],
|
|
14
|
-
* [-12.060413, 8.899826],
|
|
15
|
-
* [-12.03638, 8.873199],
|
|
16
|
-
* [-12.059383, 8.871418],
|
|
17
|
-
* [-12.034835, 8.901183]
|
|
18
|
-
* ]]);
|
|
19
|
-
*
|
|
20
|
-
* var kinks = turf.kinks(poly);
|
|
21
|
-
*
|
|
22
|
-
* //addToMap
|
|
23
|
-
* var addToMap = [poly, kinks]
|
|
24
|
-
*/
|
|
25
|
-
export default function kinks(featureIn) {
|
|
26
|
-
const results = {
|
|
27
|
-
type: "FeatureCollection",
|
|
28
|
-
features: [],
|
|
29
|
-
};
|
|
30
|
-
if (featureIn.type === "Feature" &&
|
|
31
|
-
(featureIn.geometry.type === "Point" ||
|
|
32
|
-
featureIn.geometry.type === "MultiPoint")) {
|
|
33
|
-
throw new Error("Input must be a LineString, MultiLineString, " +
|
|
34
|
-
"Polygon, or MultiPolygon Feature or Geometry");
|
|
35
|
-
}
|
|
36
|
-
const intersections = findIntersections(featureIn, false);
|
|
37
|
-
for (let i = 0; i < intersections.length; ++i) {
|
|
38
|
-
const intersection = intersections[i];
|
|
39
|
-
results.features.push(point([intersection[0], intersection[1]]));
|
|
40
|
-
}
|
|
41
|
-
return results;
|
|
42
|
-
}
|
package/dist/es/package.json
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"type":"module"}
|
package/dist/js/index.js
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const tslib_1 = require("tslib");
|
|
4
|
-
const sweepline_intersections_1 = tslib_1.__importDefault(require("sweepline-intersections"));
|
|
5
|
-
const helpers_1 = require("@turf/helpers");
|
|
6
|
-
/**
|
|
7
|
-
* Takes a {@link LineString|linestring}, {@link MultiLineString|multi-linestring},
|
|
8
|
-
* {@link MultiPolygon|multi-polygon} or {@link Polygon|polygon} and
|
|
9
|
-
* returns {@link Point|points} at all self-intersections.
|
|
10
|
-
*
|
|
11
|
-
* @name kinks
|
|
12
|
-
* @param {Feature<LineString|MultiLineString|MultiPolygon|Polygon>} featureIn input feature
|
|
13
|
-
* @returns {FeatureCollection<Point>} self-intersections
|
|
14
|
-
* @example
|
|
15
|
-
* var poly = turf.polygon([[
|
|
16
|
-
* [-12.034835, 8.901183],
|
|
17
|
-
* [-12.060413, 8.899826],
|
|
18
|
-
* [-12.03638, 8.873199],
|
|
19
|
-
* [-12.059383, 8.871418],
|
|
20
|
-
* [-12.034835, 8.901183]
|
|
21
|
-
* ]]);
|
|
22
|
-
*
|
|
23
|
-
* var kinks = turf.kinks(poly);
|
|
24
|
-
*
|
|
25
|
-
* //addToMap
|
|
26
|
-
* var addToMap = [poly, kinks]
|
|
27
|
-
*/
|
|
28
|
-
function kinks(featureIn) {
|
|
29
|
-
const results = {
|
|
30
|
-
type: "FeatureCollection",
|
|
31
|
-
features: [],
|
|
32
|
-
};
|
|
33
|
-
if (featureIn.type === "Feature" &&
|
|
34
|
-
(featureIn.geometry.type === "Point" ||
|
|
35
|
-
featureIn.geometry.type === "MultiPoint")) {
|
|
36
|
-
throw new Error("Input must be a LineString, MultiLineString, " +
|
|
37
|
-
"Polygon, or MultiPolygon Feature or Geometry");
|
|
38
|
-
}
|
|
39
|
-
const intersections = sweepline_intersections_1.default(featureIn, false);
|
|
40
|
-
for (let i = 0; i < intersections.length; ++i) {
|
|
41
|
-
const intersection = intersections[i];
|
|
42
|
-
results.features.push(helpers_1.point([intersection[0], intersection[1]]));
|
|
43
|
-
}
|
|
44
|
-
return results;
|
|
45
|
-
}
|
|
46
|
-
exports.default = kinks;
|