@turf/line-split 6.4.0 → 7.0.0-alpha.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 CHANGED
@@ -6,12 +6,12 @@
6
6
 
7
7
  Split a LineString by another GeoJSON Feature.
8
8
 
9
- **Parameters**
9
+ ### Parameters
10
10
 
11
- - `line` **[Feature][1]<[LineString][2]>** LineString Feature to split
12
- - `splitter` **[Feature][1]<any>** Feature used to split line
11
+ * `line` **[Feature][1]<[LineString][2]>** LineString Feature to split
12
+ * `splitter` **[Feature][1]\<any>** Feature used to split line
13
13
 
14
- **Examples**
14
+ ### Examples
15
15
 
16
16
  ```javascript
17
17
  var line = turf.lineString([[120, -25], [145, -25]]);
@@ -23,7 +23,7 @@ var split = turf.lineSplit(line, splitter);
23
23
  var addToMap = [line, splitter]
24
24
  ```
25
25
 
26
- Returns **[FeatureCollection][3]&lt;[LineString][2]>** Split LineStrings
26
+ Returns **[FeatureCollection][3]<[LineString][2]>** Split LineStrings
27
27
 
28
28
  [1]: https://tools.ietf.org/html/rfc7946#section-3.2
29
29
 
package/dist/es/index.js CHANGED
@@ -1,13 +1,13 @@
1
- import rbush from 'geojson-rbush';
1
+ import rbush from '@turf/geojson-rbush';
2
2
  import square from '@turf/square';
3
3
  import bbox from '@turf/bbox';
4
4
  import truncate from '@turf/truncate';
5
5
  import lineSegment from '@turf/line-segment';
6
6
  import lineIntersect from '@turf/line-intersect';
7
7
  import nearestPointOnLine from '@turf/nearest-point-on-line';
8
- import { getCoords, getCoord, getType } from '@turf/invariant';
9
- import { featureEach, featureReduce, flattenEach } from '@turf/meta';
10
- import { lineString, featureCollection } from '@turf/helpers';
8
+ import { getType, getCoords, getCoord } from '@turf/invariant';
9
+ import { flattenEach, featureEach, featureReduce } from '@turf/meta';
10
+ import { featureCollection, lineString } from '@turf/helpers';
11
11
 
12
12
  /**
13
13
  * Split a LineString by another GeoJSON Feature.
@@ -51,7 +51,12 @@ function lineSplit(line, splitter) {
51
51
  case "MultiLineString":
52
52
  case "Polygon":
53
53
  case "MultiPolygon":
54
- return splitLineWithPoints(line, lineIntersect(line, truncatedSplitter));
54
+ return splitLineWithPoints(
55
+ line,
56
+ lineIntersect(line, truncatedSplitter, {
57
+ ignoreSelfIntersections: true,
58
+ })
59
+ );
55
60
  }
56
61
  }
57
62
 
package/dist/js/index.js CHANGED
@@ -1,18 +1,26 @@
1
1
  'use strict';
2
2
 
3
- function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
4
-
5
- var rbush = _interopDefault(require('geojson-rbush'));
6
- var square = _interopDefault(require('@turf/square'));
7
- var bbox = _interopDefault(require('@turf/bbox'));
8
- var truncate = _interopDefault(require('@turf/truncate'));
9
- var lineSegment = _interopDefault(require('@turf/line-segment'));
10
- var lineIntersect = _interopDefault(require('@turf/line-intersect'));
11
- var nearestPointOnLine = _interopDefault(require('@turf/nearest-point-on-line'));
3
+ var rbush = require('@turf/geojson-rbush');
4
+ var square = require('@turf/square');
5
+ var bbox = require('@turf/bbox');
6
+ var truncate = require('@turf/truncate');
7
+ var lineSegment = require('@turf/line-segment');
8
+ var lineIntersect = require('@turf/line-intersect');
9
+ var nearestPointOnLine = require('@turf/nearest-point-on-line');
12
10
  var invariant = require('@turf/invariant');
13
11
  var meta = require('@turf/meta');
14
12
  var helpers = require('@turf/helpers');
15
13
 
14
+ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
15
+
16
+ var rbush__default = /*#__PURE__*/_interopDefaultLegacy(rbush);
17
+ var square__default = /*#__PURE__*/_interopDefaultLegacy(square);
18
+ var bbox__default = /*#__PURE__*/_interopDefaultLegacy(bbox);
19
+ var truncate__default = /*#__PURE__*/_interopDefaultLegacy(truncate);
20
+ var lineSegment__default = /*#__PURE__*/_interopDefaultLegacy(lineSegment);
21
+ var lineIntersect__default = /*#__PURE__*/_interopDefaultLegacy(lineIntersect);
22
+ var nearestPointOnLine__default = /*#__PURE__*/_interopDefaultLegacy(nearestPointOnLine);
23
+
16
24
  /**
17
25
  * Split a LineString by another GeoJSON Feature.
18
26
  *
@@ -44,7 +52,7 @@ function lineSplit(line, splitter) {
44
52
 
45
53
  // remove excessive decimals from splitter
46
54
  // to avoid possible approximation issues in rbush
47
- var truncatedSplitter = truncate(splitter, { precision: 7 });
55
+ var truncatedSplitter = truncate__default['default'](splitter, { precision: 7 });
48
56
 
49
57
  switch (splitterType) {
50
58
  case "Point":
@@ -55,7 +63,12 @@ function lineSplit(line, splitter) {
55
63
  case "MultiLineString":
56
64
  case "Polygon":
57
65
  case "MultiPolygon":
58
- return splitLineWithPoints(line, lineIntersect(line, truncatedSplitter));
66
+ return splitLineWithPoints(
67
+ line,
68
+ lineIntersect__default['default'](line, truncatedSplitter, {
69
+ ignoreSelfIntersections: true,
70
+ })
71
+ );
59
72
  }
60
73
  }
61
74
 
@@ -69,7 +82,7 @@ function lineSplit(line, splitter) {
69
82
  */
70
83
  function splitLineWithPoints(line, splitter) {
71
84
  var results = [];
72
- var tree = rbush();
85
+ var tree = rbush__default['default']();
73
86
 
74
87
  meta.flattenEach(splitter, function (point) {
75
88
  // Add index/id to features (needed for filter)
@@ -82,7 +95,7 @@ function splitLineWithPoints(line, splitter) {
82
95
 
83
96
  // Add Square BBox to each feature for GeoJSON-RBush
84
97
  results.forEach(function (feature) {
85
- if (!feature.bbox) feature.bbox = square(bbox(feature));
98
+ if (!feature.bbox) feature.bbox = square__default['default'](bbox__default['default'](feature));
86
99
  });
87
100
  tree.load(helpers.featureCollection(results));
88
101
  // Split with remaining points - lines might needed to be split multiple times
@@ -133,8 +146,8 @@ function splitLineWithPoint(line, splitter) {
133
146
  return helpers.featureCollection([line]);
134
147
 
135
148
  // Create spatial index
136
- var tree = rbush();
137
- var segments = lineSegment(line);
149
+ var tree = rbush__default['default']();
150
+ var segments = lineSegment__default['default'](line);
138
151
  tree.load(segments);
139
152
 
140
153
  // Find all segments that are within bbox of splitter
@@ -194,7 +207,7 @@ function findClosestFeature(point, lines) {
194
207
  var closestFeature;
195
208
  var closestDistance = Infinity;
196
209
  meta.featureEach(lines, function (segment) {
197
- var pt = nearestPointOnLine(segment, point);
210
+ var pt = nearestPointOnLine__default['default'](segment, point);
198
211
  var dist = pt.properties.dist;
199
212
  if (dist < closestDistance) {
200
213
  closestFeature = segment;
@@ -217,3 +230,4 @@ function pointsEquals(pt1, pt2) {
217
230
  }
218
231
 
219
232
  module.exports = lineSplit;
233
+ module.exports.default = lineSplit;
package/index.d.ts CHANGED
@@ -7,7 +7,7 @@ import {
7
7
  MultiLineString,
8
8
  Polygon,
9
9
  MultiPolygon,
10
- } from "@turf/helpers";
10
+ } from "geojson";
11
11
 
12
12
  export type Splitter = Feature<
13
13
  Point | MultiPoint | LineString | MultiLineString | Polygon | MultiPolygon
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@turf/line-split",
3
- "version": "6.4.0",
3
+ "version": "7.0.0-alpha.0",
4
4
  "description": "turf line-split module",
5
5
  "author": "Turf Authors",
6
6
  "contributors": [
@@ -15,6 +15,7 @@
15
15
  "type": "git",
16
16
  "url": "git://github.com/Turfjs/turf.git"
17
17
  },
18
+ "funding": "https://opencollective.com/turf",
18
19
  "publishConfig": {
19
20
  "access": "public"
20
21
  },
@@ -56,16 +57,16 @@
56
57
  "write-json-file": "*"
57
58
  },
58
59
  "dependencies": {
59
- "@turf/bbox": "^6.4.0",
60
- "@turf/helpers": "^6.4.0",
61
- "@turf/invariant": "^6.4.0",
62
- "@turf/line-intersect": "^6.4.0",
63
- "@turf/line-segment": "^6.4.0",
64
- "@turf/meta": "^6.4.0",
65
- "@turf/nearest-point-on-line": "^6.4.0",
66
- "@turf/square": "^6.4.0",
67
- "@turf/truncate": "^6.4.0",
68
- "geojson-rbush": "3.x"
60
+ "@turf/bbox": "^7.0.0-alpha.0",
61
+ "@turf/geojson-rbush": "^3.2.0",
62
+ "@turf/helpers": "^7.0.0-alpha.0",
63
+ "@turf/invariant": "^7.0.0-alpha.0",
64
+ "@turf/line-intersect": "^7.0.0-alpha.0",
65
+ "@turf/line-segment": "^7.0.0-alpha.0",
66
+ "@turf/meta": "^7.0.0-alpha.0",
67
+ "@turf/nearest-point-on-line": "^7.0.0-alpha.0",
68
+ "@turf/square": "^7.0.0-alpha.0",
69
+ "@turf/truncate": "^7.0.0-alpha.0"
69
70
  },
70
- "gitHead": "1e62773cfc88c627cca8effcb5c14cfb65a905ac"
71
+ "gitHead": "0edc4c491b999e5ace770a61e1cf549f7c004189"
71
72
  }