@turf/shortest-path 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
@@ -7,17 +7,18 @@
7
7
  Returns the shortest [path][1] from [start][2] to [end][2] without colliding with
8
8
  any [Feature][3] in [ obstacles][4]
9
9
 
10
- **Parameters**
10
+ ### Parameters
11
11
 
12
- - `start` **[Coord][5]** point
13
- - `end` **[Coord][5]** point
14
- - `options` **[Object][6]** optional parameters (optional, default `{}`)
15
- - `options.obstacles` **([Geometry][7] \| [Feature][8] \| [FeatureCollection][9]<[Polygon][10]>)?** areas which path cannot travel
16
- - `options.minDistance` **[number][11]?** minimum distance between shortest path and obstacles
17
- - `options.units` **[string][12]** unit in which resolution & minimum distance will be expressed in; it can be degrees, radians, miles, kilometers, ... (optional, default `'kilometers'`)
18
- - `options.resolution` **[number][11]** distance between matrix points on which the path will be calculated (optional, default `100`)
12
+ * `start` **[Coord][5]** point
13
+ * `end` **[Coord][5]** point
14
+ * `options` **[Object][6]** optional parameters (optional, default `{}`)
19
15
 
20
- **Examples**
16
+ * `options.obstacles` **([Geometry][7] | [Feature][8] | [FeatureCollection][9]<[Polygon][10]>)?** areas which path cannot travel
17
+ * `options.minDistance` **[number][11]?** minimum distance between shortest path and obstacles
18
+ * `options.units` **[string][12]** unit in which resolution & minimum distance will be expressed in; it can be degrees, radians, miles, kilometers, ... (optional, default `'kilometers'`)
19
+ * `options.resolution` **[number][11]** distance between matrix points on which the path will be calculated (optional, default `100`)
20
+
21
+ ### Examples
21
22
 
22
23
  ```javascript
23
24
  var start = [-5, -6];
@@ -32,7 +33,7 @@ var path = turf.shortestPath(start, end, options);
32
33
  var addToMap = [start, end, options.obstacles, path];
33
34
  ```
34
35
 
35
- Returns **[Feature][8]&lt;[LineString][13]>** shortest path between start and end
36
+ Returns **[Feature][8]<[LineString][13]>** shortest path between start and end
36
37
 
37
38
  [1]: https://tools.ietf.org/html/rfc7946#section-3.1.4
38
39
 
package/dist/es/index.js CHANGED
@@ -5,7 +5,7 @@ import scale from '@turf/transform-scale';
5
5
  import cleanCoords from '@turf/clean-coords';
6
6
  import bboxPolygon from '@turf/bbox-polygon';
7
7
  import { getCoord, getType, getGeom } from '@turf/invariant';
8
- import { point, isNumber, lineString, isObject, featureCollection, feature } from '@turf/helpers';
8
+ import { isObject, featureCollection, isNumber, point, feature, lineString } from '@turf/helpers';
9
9
 
10
10
  // javascript-astar 0.4.1
11
11
  // http://github.com/bgrins/javascript-astar
package/dist/js/index.js CHANGED
@@ -1,16 +1,23 @@
1
1
  'use strict';
2
2
 
3
- function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
4
-
5
- var bbox = _interopDefault(require('@turf/bbox'));
6
- var booleanPointInPolygon = _interopDefault(require('@turf/boolean-point-in-polygon'));
7
- var distance = _interopDefault(require('@turf/distance'));
8
- var scale = _interopDefault(require('@turf/transform-scale'));
9
- var cleanCoords = _interopDefault(require('@turf/clean-coords'));
10
- var bboxPolygon = _interopDefault(require('@turf/bbox-polygon'));
3
+ var bbox = require('@turf/bbox');
4
+ var booleanPointInPolygon = require('@turf/boolean-point-in-polygon');
5
+ var distance = require('@turf/distance');
6
+ var scale = require('@turf/transform-scale');
7
+ var cleanCoords = require('@turf/clean-coords');
8
+ var bboxPolygon = require('@turf/bbox-polygon');
11
9
  var invariant = require('@turf/invariant');
12
10
  var helpers = require('@turf/helpers');
13
11
 
12
+ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
13
+
14
+ var bbox__default = /*#__PURE__*/_interopDefaultLegacy(bbox);
15
+ var booleanPointInPolygon__default = /*#__PURE__*/_interopDefaultLegacy(booleanPointInPolygon);
16
+ var distance__default = /*#__PURE__*/_interopDefaultLegacy(distance);
17
+ var scale__default = /*#__PURE__*/_interopDefaultLegacy(scale);
18
+ var cleanCoords__default = /*#__PURE__*/_interopDefaultLegacy(cleanCoords);
19
+ var bboxPolygon__default = /*#__PURE__*/_interopDefaultLegacy(bboxPolygon);
20
+
14
21
  // javascript-astar 0.4.1
15
22
  // http://github.com/bgrins/javascript-astar
16
23
  // Freely distributable under the MIT License.
@@ -471,9 +478,9 @@ function shortestPath(start, end, options) {
471
478
  var collection = obstacles;
472
479
  collection.features.push(start);
473
480
  collection.features.push(end);
474
- var box = bbox(scale(bboxPolygon(bbox(collection)), 1.15)); // extend 15%
481
+ var box = bbox__default['default'](scale__default['default'](bboxPolygon__default['default'](bbox__default['default'](collection)), 1.15)); // extend 15%
475
482
  if (!resolution) {
476
- var width = distance([box[0], box[1]], [box[2], box[1]], options);
483
+ var width = distance__default['default']([box[0], box[1]], [box[2], box[1]], options);
477
484
  resolution = width / 100;
478
485
  }
479
486
  collection.features.pop();
@@ -484,9 +491,9 @@ function shortestPath(start, end, options) {
484
491
  var east = box[2];
485
492
  var north = box[3];
486
493
 
487
- var xFraction = resolution / distance([west, south], [east, south], options);
494
+ var xFraction = resolution / distance__default['default']([west, south], [east, south], options);
488
495
  var cellWidth = xFraction * (east - west);
489
- var yFraction = resolution / distance([west, south], [west, north], options);
496
+ var yFraction = resolution / distance__default['default']([west, south], [west, north], options);
490
497
  var cellHeight = yFraction * (north - south);
491
498
 
492
499
  var bboxHorizontalSide = east - west;
@@ -523,13 +530,13 @@ function shortestPath(start, end, options) {
523
530
  // map point's coords
524
531
  pointMatrixRow.push(currentX + "|" + currentY);
525
532
  // set closest points
526
- var distStart = distance(pt, start);
533
+ var distStart = distance__default['default'](pt, start);
527
534
  // if (distStart < minDistStart) {
528
535
  if (!isInsideObstacle && distStart < minDistStart) {
529
536
  minDistStart = distStart;
530
537
  closestToStart = { x: c, y: r };
531
538
  }
532
- var distEnd = distance(pt, end);
539
+ var distEnd = distance__default['default'](pt, end);
533
540
  // if (distEnd < minDistEnd) {
534
541
  if (!isInsideObstacle && distEnd < minDistEnd) {
535
542
  minDistEnd = distEnd;
@@ -570,7 +577,7 @@ function shortestPath(start, end, options) {
570
577
  // path.push(end.geometry.coordinates);
571
578
  // ---------------------------------------
572
579
 
573
- return cleanCoords(helpers.lineString(path));
580
+ return cleanCoords__default['default'](helpers.lineString(path));
574
581
  }
575
582
 
576
583
  /**
@@ -583,7 +590,7 @@ function shortestPath(start, end, options) {
583
590
  */
584
591
  function isInside(pt, polygons) {
585
592
  for (var i = 0; i < polygons.features.length; i++) {
586
- if (booleanPointInPolygon(pt, polygons.features[i])) {
593
+ if (booleanPointInPolygon__default['default'](pt, polygons.features[i])) {
587
594
  return true;
588
595
  }
589
596
  }
@@ -591,3 +598,4 @@ function isInside(pt, polygons) {
591
598
  }
592
599
 
593
600
  module.exports = shortestPath;
601
+ module.exports.default = shortestPath;
package/index.d.ts CHANGED
@@ -1,11 +1,5 @@
1
- import {
2
- Polygon,
3
- Feature,
4
- FeatureCollection,
5
- Coord,
6
- LineString,
7
- Units,
8
- } from "@turf/helpers";
1
+ import { Polygon, Feature, FeatureCollection, LineString } from "geojson";
2
+ import { Coord, Units } from "@turf/helpers";
9
3
 
10
4
  /**
11
5
  * http://turfjs.org/docs/#shortestpath
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@turf/shortest-path",
3
- "version": "6.4.0",
3
+ "version": "7.0.0-alpha.0",
4
4
  "description": "turf shortest-path module",
5
5
  "author": "Turf Authors",
6
6
  "contributors": [
@@ -16,6 +16,7 @@
16
16
  "type": "git",
17
17
  "url": "git://github.com/Turfjs/turf.git"
18
18
  },
19
+ "funding": "https://opencollective.com/turf",
19
20
  "publishConfig": {
20
21
  "access": "public"
21
22
  },
@@ -45,10 +46,10 @@
45
46
  "docs": "node ../../scripts/generate-readmes",
46
47
  "test": "npm-run-all test:*",
47
48
  "test:tape": "node -r esm test.js",
48
- "test:types": "tsc --esModuleInterop --noEmit types.ts"
49
+ "test:types": "tsc --esModuleInterop --noEmit --strict types.ts"
49
50
  },
50
51
  "devDependencies": {
51
- "@turf/truncate": "^6.4.0",
52
+ "@turf/truncate": "^7.0.0-alpha.0",
52
53
  "benchmark": "*",
53
54
  "load-json-file": "*",
54
55
  "npm-run-all": "*",
@@ -57,15 +58,15 @@
57
58
  "write-json-file": "*"
58
59
  },
59
60
  "dependencies": {
60
- "@turf/bbox": "^6.4.0",
61
- "@turf/bbox-polygon": "^6.4.0",
62
- "@turf/boolean-point-in-polygon": "^6.4.0",
63
- "@turf/clean-coords": "^6.4.0",
64
- "@turf/distance": "^6.4.0",
65
- "@turf/helpers": "^6.4.0",
66
- "@turf/invariant": "^6.4.0",
67
- "@turf/meta": "^6.4.0",
68
- "@turf/transform-scale": "^6.4.0"
61
+ "@turf/bbox": "^7.0.0-alpha.0",
62
+ "@turf/bbox-polygon": "^7.0.0-alpha.0",
63
+ "@turf/boolean-point-in-polygon": "^7.0.0-alpha.0",
64
+ "@turf/clean-coords": "^7.0.0-alpha.0",
65
+ "@turf/distance": "^7.0.0-alpha.0",
66
+ "@turf/helpers": "^7.0.0-alpha.0",
67
+ "@turf/invariant": "^7.0.0-alpha.0",
68
+ "@turf/meta": "^7.0.0-alpha.0",
69
+ "@turf/transform-scale": "^7.0.0-alpha.0"
69
70
  },
70
- "gitHead": "1e62773cfc88c627cca8effcb5c14cfb65a905ac"
71
+ "gitHead": "0edc4c491b999e5ace770a61e1cf549f7c004189"
71
72
  }