@turf/length
Advanced tools
Comparing version 6.5.0 to 7.0.0-alpha.0
@@ -19,9 +19,8 @@ import distance from "@turf/distance"; | ||
*/ | ||
export default function length(geojson, options) { | ||
if (options === void 0) { options = {}; } | ||
export default function length(geojson, options = {}) { | ||
// Calculate distance from 2-vertex line segments | ||
return segmentReduce(geojson, function (previousValue, segment) { | ||
var coords = segment.geometry.coordinates; | ||
return segmentReduce(geojson, (previousValue, segment) => { | ||
const coords = segment.geometry.coordinates; | ||
return previousValue + distance(coords[0], coords[1], options); | ||
}, 0); | ||
} |
@@ -1,2 +0,3 @@ | ||
import { Feature, FeatureCollection, GeometryCollection, Units } from "@turf/helpers"; | ||
import { Feature, FeatureCollection, GeometryCollection } from "geojson"; | ||
import { Units } from "@turf/helpers"; | ||
/** | ||
@@ -3,0 +4,0 @@ * Takes a {@link GeoJSON} and measures its length in the specified units, {@link (Multi)Point}'s distance are ignored. |
"use strict"; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var distance_1 = __importDefault(require("@turf/distance")); | ||
var meta_1 = require("@turf/meta"); | ||
const tslib_1 = require("tslib"); | ||
const distance_1 = tslib_1.__importDefault(require("@turf/distance")); | ||
const meta_1 = require("@turf/meta"); | ||
/** | ||
@@ -24,7 +22,6 @@ * Takes a {@link GeoJSON} and measures its length in the specified units, {@link (Multi)Point}'s distance are ignored. | ||
*/ | ||
function length(geojson, options) { | ||
if (options === void 0) { options = {}; } | ||
function length(geojson, options = {}) { | ||
// Calculate distance from 2-vertex line segments | ||
return meta_1.segmentReduce(geojson, function (previousValue, segment) { | ||
var coords = segment.geometry.coordinates; | ||
return meta_1.segmentReduce(geojson, (previousValue, segment) => { | ||
const coords = segment.geometry.coordinates; | ||
return previousValue + distance_1.default(coords[0], coords[1], options); | ||
@@ -31,0 +28,0 @@ }, 0); |
{ | ||
"name": "@turf/length", | ||
"version": "6.5.0", | ||
"version": "7.0.0-alpha.0", | ||
"description": "turf length module", | ||
@@ -66,7 +66,8 @@ "author": "Turf Authors", | ||
"dependencies": { | ||
"@turf/distance": "^6.5.0", | ||
"@turf/helpers": "^6.5.0", | ||
"@turf/meta": "^6.5.0" | ||
"@turf/distance": "^7.0.0-alpha.0", | ||
"@turf/helpers": "^7.0.0-alpha.0", | ||
"@turf/meta": "^7.0.0-alpha.0", | ||
"tslib": "^2.3.0" | ||
}, | ||
"gitHead": "5375941072b90d489389db22b43bfe809d5e451e" | ||
"gitHead": "0edc4c491b999e5ace770a61e1cf549f7c004189" | ||
} |
@@ -9,10 +9,11 @@ # @turf/length | ||
**Parameters** | ||
### Parameters | ||
- `geojson` **[Feature][3]<([LineString][4] \| [MultiLineString][5])>** GeoJSON to measure | ||
- `options` **[Object][6]** Optional parameters (optional, default `{}`) | ||
- `options.units` **[string][7]** can be degrees, radians, miles, or kilometers (optional, default `kilometers`) | ||
* `geojson` **[Feature][3]<([LineString][4] | [MultiLineString][5])>** GeoJSON to measure | ||
* `options` **[Object][6]** Optional parameters (optional, default `{}`) | ||
**Examples** | ||
* `options.units` **[string][7]** can be degrees, radians, miles, or kilometers (optional, default `kilometers`) | ||
### Examples | ||
```javascript | ||
@@ -19,0 +20,0 @@ var line = turf.lineString([[115, -32], [131, -22], [143, -25], [150, -34]]); |
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
69
7958
4
75
1
+ Addedtslib@^2.3.0
+ Added@turf/distance@7.2.0(transitive)
+ Added@turf/helpers@7.2.0(transitive)
+ Added@turf/invariant@7.2.0(transitive)
+ Added@turf/meta@7.2.0(transitive)
+ Added@types/geojson@7946.0.16(transitive)
+ Addedtslib@2.8.1(transitive)
- Removed@turf/distance@6.5.0(transitive)
- Removed@turf/helpers@6.5.0(transitive)
- Removed@turf/invariant@6.5.0(transitive)
- Removed@turf/meta@6.5.0(transitive)
Updated@turf/helpers@^7.0.0-alpha.0
Updated@turf/meta@^7.0.0-alpha.0