@turf/along
Advanced tools
Comparing version 6.0.0 to 6.0.1
32
index.js
"use strict"; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
} | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var bearing_1 = require("@turf/bearing"); | ||
var destination_1 = require("@turf/destination"); | ||
var distance_1 = require("@turf/distance"); | ||
var bearing_1 = __importDefault(require("@turf/bearing")); | ||
var destination_1 = __importDefault(require("@turf/destination")); | ||
var distance_1 = __importDefault(require("@turf/distance")); | ||
var helpers_1 = require("@turf/helpers"); | ||
var invariant_1 = require("@turf/invariant"); | ||
/** | ||
@@ -27,23 +31,15 @@ * Takes a {@link LineString} and returns a {@link Point} at a specified distance along the line. | ||
if (options === void 0) { options = {}; } | ||
// Optional parameters | ||
if (!helpers_1.isObject(options)) | ||
throw new Error('options is invalid'); | ||
// Validation | ||
var coords; | ||
if (line.type === 'Feature') | ||
coords = line.geometry.coordinates; | ||
else if (line.type === 'LineString') | ||
coords = line.coordinates; | ||
else | ||
throw new Error('input must be a LineString Feature or Geometry'); | ||
if (!helpers_1.isNumber(distance)) | ||
throw new Error('distance must be a number'); | ||
// Get Coords | ||
var geom = invariant_1.getGeom(line); | ||
var coords = geom.coordinates; | ||
var travelled = 0; | ||
for (var i = 0; i < coords.length; i++) { | ||
if (distance >= travelled && i === coords.length - 1) | ||
if (distance >= travelled && i === coords.length - 1) { | ||
break; | ||
} | ||
else if (travelled >= distance) { | ||
var overshot = distance - travelled; | ||
if (!overshot) | ||
if (!overshot) { | ||
return helpers_1.point(coords[i]); | ||
} | ||
else { | ||
@@ -50,0 +46,0 @@ var direction = bearing_1.default(coords[i], coords[i - 1]) - 180; |
{ | ||
"name": "@turf/along", | ||
"version": "6.0.0", | ||
"version": "6.0.1", | ||
"description": "turf along module", | ||
"main": "index", | ||
"types": "index.d.ts", | ||
"files": [ | ||
"index.js", | ||
"index.ts" | ||
"index.d.ts" | ||
], | ||
@@ -35,6 +36,8 @@ "scripts": { | ||
"devDependencies": { | ||
"@types/tape": "*", | ||
"benchmark": "*", | ||
"load-json-file": "*", | ||
"typescript": "*", | ||
"tape": "*" | ||
"tape": "*", | ||
"tslint": "*", | ||
"typescript": "*" | ||
}, | ||
@@ -45,4 +48,5 @@ "dependencies": { | ||
"@turf/distance": "6.x", | ||
"@turf/helpers": "6.x" | ||
"@turf/helpers": "6.x", | ||
"@turf/invariant": "6.x" | ||
} | ||
} |
@@ -7,10 +7,10 @@ # @turf/along | ||
Takes a [LineString](https://tools.ietf.org/html/rfc7946#section-3.1.4) and returns a [Point](https://tools.ietf.org/html/rfc7946#section-3.1.2) at a specified distance along the line. | ||
Takes a [LineString][1] and returns a [Point][2] at a specified distance along the line. | ||
**Parameters** | ||
- `line` **[Feature](https://tools.ietf.org/html/rfc7946#section-3.2)<[LineString](https://tools.ietf.org/html/rfc7946#section-3.1.4)>** input line | ||
- `distance` **[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)** distance along the line | ||
- `options` **[Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)?** Optional parameters | ||
- `options.units` **[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** can be degrees, radians, miles, or kilometers (optional, default `"kilometers"`) | ||
- `line` **[Feature][3]<[LineString][4]>** input line | ||
- `distance` **[number][5]** distance along the line | ||
- `options` **[Object][6]?** Optional parameters | ||
- `options.units` **[string][7]** can be degrees, radians, miles, or kilometers (optional, default `"kilometers"`) | ||
@@ -29,4 +29,20 @@ **Examples** | ||
Returns **[Feature](https://tools.ietf.org/html/rfc7946#section-3.2)<[Point](https://tools.ietf.org/html/rfc7946#section-3.1.2)>** Point `distance` `units` along the line | ||
Returns **[Feature][3]<[Point][8]>** Point `distance` `units` along the line | ||
[1]: https://tools.ietf.org/html/rfc7946#section-3.1.4 | ||
[2]: https://tools.ietf.org/html/rfc7946#section-3.1.2 | ||
[3]: https://tools.ietf.org/html/rfc7946#section-3.2 | ||
[4]: https://tools.ietf.org/html/rfc7946#section-3.1.4 | ||
[5]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number | ||
[6]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object | ||
[7]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String | ||
[8]: https://tools.ietf.org/html/rfc7946#section-3.1.2 | ||
<!-- This file is automatically generated. Please don't edit it directly: | ||
@@ -33,0 +49,0 @@ if you find an error, edit the source file (likely index.js), and re-run |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
70
0
7073
5
6
78
+ Added@turf/invariant@6.x