@turf/line-segment
Advanced tools
Comparing version 6.5.0 to 7.0.0-alpha.0
@@ -1,2 +0,2 @@ | ||
import { featureCollection, lineString, } from "@turf/helpers"; | ||
import { featureCollection, lineString } from "@turf/helpers"; | ||
import { getCoords } from "@turf/invariant"; | ||
@@ -22,4 +22,4 @@ import { flattenEach } from "@turf/meta"; | ||
} | ||
var results = []; | ||
flattenEach(geojson, function (feature) { | ||
const results = []; | ||
flattenEach(geojson, (feature) => { | ||
lineSegmentFeature(feature, results); | ||
@@ -38,4 +38,4 @@ }); | ||
function lineSegmentFeature(geojson, results) { | ||
var coords = []; | ||
var geometry = geojson.geometry; | ||
let coords = []; | ||
const geometry = geojson.geometry; | ||
if (geometry !== null) { | ||
@@ -49,5 +49,5 @@ switch (geometry.type) { | ||
} | ||
coords.forEach(function (coord) { | ||
var segments = createSegments(coord, geojson.properties); | ||
segments.forEach(function (segment) { | ||
coords.forEach((coord) => { | ||
const segments = createSegments(coord, geojson.properties); | ||
segments.forEach((segment) => { | ||
segment.id = results.length; | ||
@@ -68,5 +68,5 @@ results.push(segment); | ||
function createSegments(coords, properties) { | ||
var segments = []; | ||
coords.reduce(function (previousCoords, currentCoords) { | ||
var segment = lineString([previousCoords, currentCoords], properties); | ||
const segments = []; | ||
coords.reduce((previousCoords, currentCoords) => { | ||
const segment = lineString([previousCoords, currentCoords], properties); | ||
segment.bbox = bbox(previousCoords, currentCoords); | ||
@@ -87,12 +87,12 @@ segments.push(segment); | ||
function bbox(coords1, coords2) { | ||
var x1 = coords1[0]; | ||
var y1 = coords1[1]; | ||
var x2 = coords2[0]; | ||
var y2 = coords2[1]; | ||
var west = x1 < x2 ? x1 : x2; | ||
var south = y1 < y2 ? y1 : y2; | ||
var east = x1 > x2 ? x1 : x2; | ||
var north = y1 > y2 ? y1 : y2; | ||
const x1 = coords1[0]; | ||
const y1 = coords1[1]; | ||
const x2 = coords2[0]; | ||
const y2 = coords2[1]; | ||
const west = x1 < x2 ? x1 : x2; | ||
const south = y1 < y2 ? y1 : y2; | ||
const east = x1 > x2 ? x1 : x2; | ||
const north = y1 > y2 ? y1 : y2; | ||
return [west, south, east, north]; | ||
} | ||
export default lineSegment; |
@@ -1,2 +0,2 @@ | ||
import { Feature, FeatureCollection, LineString, MultiLineString, MultiPolygon, Polygon } from "@turf/helpers"; | ||
import { Feature, FeatureCollection, LineString, MultiLineString, MultiPolygon, Polygon } from "geojson"; | ||
/** | ||
@@ -3,0 +3,0 @@ * Creates a {@link FeatureCollection} of 2-vertex {@link LineString} segments from a |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var helpers_1 = require("@turf/helpers"); | ||
var invariant_1 = require("@turf/invariant"); | ||
var meta_1 = require("@turf/meta"); | ||
const helpers_1 = require("@turf/helpers"); | ||
const invariant_1 = require("@turf/invariant"); | ||
const meta_1 = require("@turf/meta"); | ||
/** | ||
@@ -24,4 +24,4 @@ * Creates a {@link FeatureCollection} of 2-vertex {@link LineString} segments from a | ||
} | ||
var results = []; | ||
meta_1.flattenEach(geojson, function (feature) { | ||
const results = []; | ||
meta_1.flattenEach(geojson, (feature) => { | ||
lineSegmentFeature(feature, results); | ||
@@ -40,4 +40,4 @@ }); | ||
function lineSegmentFeature(geojson, results) { | ||
var coords = []; | ||
var geometry = geojson.geometry; | ||
let coords = []; | ||
const geometry = geojson.geometry; | ||
if (geometry !== null) { | ||
@@ -51,5 +51,5 @@ switch (geometry.type) { | ||
} | ||
coords.forEach(function (coord) { | ||
var segments = createSegments(coord, geojson.properties); | ||
segments.forEach(function (segment) { | ||
coords.forEach((coord) => { | ||
const segments = createSegments(coord, geojson.properties); | ||
segments.forEach((segment) => { | ||
segment.id = results.length; | ||
@@ -70,5 +70,5 @@ results.push(segment); | ||
function createSegments(coords, properties) { | ||
var segments = []; | ||
coords.reduce(function (previousCoords, currentCoords) { | ||
var segment = helpers_1.lineString([previousCoords, currentCoords], properties); | ||
const segments = []; | ||
coords.reduce((previousCoords, currentCoords) => { | ||
const segment = helpers_1.lineString([previousCoords, currentCoords], properties); | ||
segment.bbox = bbox(previousCoords, currentCoords); | ||
@@ -89,12 +89,12 @@ segments.push(segment); | ||
function bbox(coords1, coords2) { | ||
var x1 = coords1[0]; | ||
var y1 = coords1[1]; | ||
var x2 = coords2[0]; | ||
var y2 = coords2[1]; | ||
var west = x1 < x2 ? x1 : x2; | ||
var south = y1 < y2 ? y1 : y2; | ||
var east = x1 > x2 ? x1 : x2; | ||
var north = y1 > y2 ? y1 : y2; | ||
const x1 = coords1[0]; | ||
const y1 = coords1[1]; | ||
const x2 = coords2[0]; | ||
const y2 = coords2[1]; | ||
const west = x1 < x2 ? x1 : x2; | ||
const south = y1 < y2 ? y1 : y2; | ||
const east = x1 > x2 ? x1 : x2; | ||
const north = y1 > y2 ? y1 : y2; | ||
return [west, south, east, north]; | ||
} | ||
exports.default = lineSegment; |
{ | ||
"name": "@turf/line-segment", | ||
"version": "6.5.0", | ||
"version": "7.0.0-alpha.0", | ||
"description": "turf line-segment module", | ||
@@ -59,7 +59,8 @@ "author": "Turf Authors", | ||
"dependencies": { | ||
"@turf/helpers": "^6.5.0", | ||
"@turf/invariant": "^6.5.0", | ||
"@turf/meta": "^6.5.0" | ||
"@turf/helpers": "^7.0.0-alpha.0", | ||
"@turf/invariant": "^7.0.0-alpha.0", | ||
"@turf/meta": "^7.0.0-alpha.0", | ||
"tslib": "^2.3.0" | ||
}, | ||
"gitHead": "5375941072b90d489389db22b43bfe809d5e451e" | ||
"gitHead": "0edc4c491b999e5ace770a61e1cf549f7c004189" | ||
} |
@@ -7,9 +7,10 @@ # @turf/line-segment | ||
Creates a [FeatureCollection][1] of 2-vertex [LineString][2] segments from a [(Multi)LineString][2] or [(Multi)Polygon][3]. | ||
Creates a [FeatureCollection][1] of 2-vertex [LineString][2] segments from a | ||
[(Multi)LineString][2] or [(Multi)Polygon][3]. | ||
**Parameters** | ||
### Parameters | ||
- `geojson` **([Geometry][4] \| [FeatureCollection][5] \| [Feature][6]<([LineString][7] \| [MultiLineString][8] \| [MultiPolygon][9] \| [Polygon][10])>)** GeoJSON Polygon or LineString | ||
* `geojson` **[GeoJSON][4]** GeoJSON Polygon or LineString | ||
**Examples** | ||
### Examples | ||
@@ -24,3 +25,3 @@ ```javascript | ||
Returns **[FeatureCollection][5]<[LineString][7]>** 2-vertex line segments | ||
Returns **[FeatureCollection][5]<[LineString][6]>** 2-vertex line segments | ||
@@ -33,16 +34,8 @@ [1]: https://tools.ietf.org/html/rfc7946#section-3.3 | ||
[4]: https://tools.ietf.org/html/rfc7946#section-3.1 | ||
[4]: https://tools.ietf.org/html/rfc7946#section-3 | ||
[5]: https://tools.ietf.org/html/rfc7946#section-3.3 | ||
[6]: https://tools.ietf.org/html/rfc7946#section-3.2 | ||
[6]: https://tools.ietf.org/html/rfc7946#section-3.1.4 | ||
[7]: https://tools.ietf.org/html/rfc7946#section-3.1.4 | ||
[8]: https://tools.ietf.org/html/rfc7946#section-3.1.5 | ||
[9]: https://tools.ietf.org/html/rfc7946#section-3.1.7 | ||
[10]: https://tools.ietf.org/html/rfc7946#section-3.1.6 | ||
<!-- This file is automatically generated. Please don't edit it directly: | ||
@@ -49,0 +42,0 @@ if you find an error, edit the source file (likely index.js), and re-run |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
11105
4
1
62
+ Addedtslib@^2.3.0
+ Added@turf/helpers@7.1.0(transitive)
+ Added@turf/invariant@7.1.0(transitive)
+ Added@turf/meta@7.1.0(transitive)
+ Added@types/geojson@7946.0.14(transitive)
+ Addedtslib@2.8.1(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