@turf/polygon-to-line
Advanced tools
Comparing version 6.5.0 to 7.0.0-alpha.0
@@ -20,5 +20,4 @@ import { featureCollection, lineString, multiLineString } from "@turf/helpers"; | ||
*/ | ||
export default function (poly, options) { | ||
if (options === void 0) { options = {}; } | ||
var geom = getGeom(poly); | ||
export default function (poly, options = {}) { | ||
const geom = getGeom(poly); | ||
if (!options.properties && poly.type === "Feature") { | ||
@@ -39,7 +38,6 @@ options.properties = poly.properties; | ||
*/ | ||
export function polygonToLine(poly, options) { | ||
if (options === void 0) { options = {}; } | ||
var geom = getGeom(poly); | ||
var coords = geom.coordinates; | ||
var properties = options.properties | ||
export function polygonToLine(poly, options = {}) { | ||
const geom = getGeom(poly); | ||
const coords = geom.coordinates; | ||
const properties = options.properties | ||
? options.properties | ||
@@ -54,7 +52,6 @@ : poly.type === "Feature" | ||
*/ | ||
export function multiPolygonToLine(multiPoly, options) { | ||
if (options === void 0) { options = {}; } | ||
var geom = getGeom(multiPoly); | ||
var coords = geom.coordinates; | ||
var properties = options.properties | ||
export function multiPolygonToLine(multiPoly, options = {}) { | ||
const geom = getGeom(multiPoly); | ||
const coords = geom.coordinates; | ||
const properties = options.properties | ||
? options.properties | ||
@@ -64,4 +61,4 @@ : multiPoly.type === "Feature" | ||
: {}; | ||
var lines = []; | ||
coords.forEach(function (coord) { | ||
const lines = []; | ||
coords.forEach((coord) => { | ||
lines.push(coordsToLine(coord, properties)); | ||
@@ -68,0 +65,0 @@ }); |
@@ -1,2 +0,2 @@ | ||
import { Feature, FeatureCollection, LineString, MultiLineString, MultiPolygon, Polygon, Properties } from "@turf/helpers"; | ||
import { Feature, FeatureCollection, LineString, MultiLineString, MultiPolygon, Polygon, GeoJsonProperties } from "geojson"; | ||
/** | ||
@@ -19,3 +19,3 @@ * Converts a {@link Polygon} to {@link LineString|(Multi)LineString} or {@link MultiPolygon} to a | ||
*/ | ||
export default function <G extends Polygon | MultiPolygon, P = Properties>(poly: Feature<G, P> | G, options?: { | ||
export default function <G extends Polygon | MultiPolygon, P = GeoJsonProperties>(poly: Feature<G, P> | G, options?: { | ||
properties?: any; | ||
@@ -26,3 +26,3 @@ }): Feature<LineString | MultiLineString, P> | FeatureCollection<LineString | MultiLineString, P>; | ||
*/ | ||
export declare function polygonToLine<G extends Polygon, P = Properties>(poly: Feature<G, P> | G, options?: { | ||
export declare function polygonToLine<G extends Polygon, P = GeoJsonProperties>(poly: Feature<G, P> | G, options?: { | ||
properties?: any; | ||
@@ -33,3 +33,3 @@ }): Feature<LineString | MultiLineString, P>; | ||
*/ | ||
export declare function multiPolygonToLine<G extends MultiPolygon, P = Properties>(multiPoly: Feature<G, P> | G, options?: { | ||
export declare function multiPolygonToLine<G extends MultiPolygon, P = GeoJsonProperties>(multiPoly: Feature<G, P> | G, options?: { | ||
properties?: P; | ||
@@ -40,2 +40,2 @@ }): FeatureCollection<LineString | MultiLineString, P>; | ||
*/ | ||
export declare function coordsToLine<P = Properties>(coords: number[][][], properties: P): Feature<LineString | MultiLineString, P>; | ||
export declare function coordsToLine<P = GeoJsonProperties>(coords: number[][][], properties: P): Feature<LineString | MultiLineString, P>; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var helpers_1 = require("@turf/helpers"); | ||
var invariant_1 = require("@turf/invariant"); | ||
const helpers_1 = require("@turf/helpers"); | ||
const invariant_1 = require("@turf/invariant"); | ||
/** | ||
@@ -22,5 +22,4 @@ * Converts a {@link Polygon} to {@link LineString|(Multi)LineString} or {@link MultiPolygon} to a | ||
*/ | ||
function default_1(poly, options) { | ||
if (options === void 0) { options = {}; } | ||
var geom = invariant_1.getGeom(poly); | ||
function default_1(poly, options = {}) { | ||
const geom = invariant_1.getGeom(poly); | ||
if (!options.properties && poly.type === "Feature") { | ||
@@ -42,7 +41,6 @@ options.properties = poly.properties; | ||
*/ | ||
function polygonToLine(poly, options) { | ||
if (options === void 0) { options = {}; } | ||
var geom = invariant_1.getGeom(poly); | ||
var coords = geom.coordinates; | ||
var properties = options.properties | ||
function polygonToLine(poly, options = {}) { | ||
const geom = invariant_1.getGeom(poly); | ||
const coords = geom.coordinates; | ||
const properties = options.properties | ||
? options.properties | ||
@@ -58,7 +56,6 @@ : poly.type === "Feature" | ||
*/ | ||
function multiPolygonToLine(multiPoly, options) { | ||
if (options === void 0) { options = {}; } | ||
var geom = invariant_1.getGeom(multiPoly); | ||
var coords = geom.coordinates; | ||
var properties = options.properties | ||
function multiPolygonToLine(multiPoly, options = {}) { | ||
const geom = invariant_1.getGeom(multiPoly); | ||
const coords = geom.coordinates; | ||
const properties = options.properties | ||
? options.properties | ||
@@ -68,4 +65,4 @@ : multiPoly.type === "Feature" | ||
: {}; | ||
var lines = []; | ||
coords.forEach(function (coord) { | ||
const lines = []; | ||
coords.forEach((coord) => { | ||
lines.push(coordsToLine(coord, properties)); | ||
@@ -72,0 +69,0 @@ }); |
{ | ||
"name": "@turf/polygon-to-line", | ||
"version": "6.5.0", | ||
"version": "7.0.0-alpha.0", | ||
"description": "turf polygon-to-line module", | ||
@@ -61,6 +61,7 @@ "author": "Turf Authors", | ||
"dependencies": { | ||
"@turf/helpers": "^6.5.0", | ||
"@turf/invariant": "^6.5.0" | ||
"@turf/helpers": "^7.0.0-alpha.0", | ||
"@turf/invariant": "^7.0.0-alpha.0", | ||
"tslib": "^2.3.0" | ||
}, | ||
"gitHead": "5375941072b90d489389db22b43bfe809d5e451e" | ||
"gitHead": "0edc4c491b999e5ace770a61e1cf549f7c004189" | ||
} |
@@ -7,12 +7,14 @@ # @turf/polygon-to-line | ||
Converts a [Polygon][1] to [(Multi)LineString][2] or [MultiPolygon][3] to a [FeatureCollection][4] of [(Multi)LineString][2]. | ||
Converts a [Polygon][1] to [(Multi)LineString][2] or [MultiPolygon][3] to a | ||
[FeatureCollection][4] of [(Multi)LineString][2]. | ||
**Parameters** | ||
### Parameters | ||
- `poly` **[Feature][5]<([Polygon][6] \| [MultiPolygon][7])>** Feature to convert | ||
- `options` **[Object][8]** Optional parameters (optional, default `{}`) | ||
- `options.properties` **[Object][8]** translates GeoJSON properties to Feature (optional, default `{}`) | ||
* `poly` **[Feature][5]<([Polygon][6] | [MultiPolygon][7])>** Feature to convert | ||
* `options` **[Object][8]** Optional parameters (optional, default `{}`) | ||
**Examples** | ||
* `options.properties` **[Object][8]** translates GeoJSON properties to Feature (optional, default `{}`) | ||
### Examples | ||
```javascript | ||
@@ -27,3 +29,3 @@ var poly = turf.polygon([[[125, -30], [145, -30], [145, -20], [125, -20], [125, -30]]]); | ||
Returns **([FeatureCollection][9] \| [Feature][5]<([LineString][10] | MultiLinestring)>)** converted (Multi)Polygon to (Multi)LineString | ||
Returns **([FeatureCollection][9] | [Feature][5]<([LineString][10] | MultiLinestring)>)** converted (Multi)Polygon to (Multi)LineString | ||
@@ -30,0 +32,0 @@ [1]: https://tools.ietf.org/html/rfc7946#section-3.1.6 |
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
74
11346
3
187
1
+ Addedtslib@^2.3.0
+ Added@turf/helpers@7.2.0(transitive)
+ Added@turf/invariant@7.2.0(transitive)
+ Added@types/geojson@7946.0.15(transitive)
+ Addedtslib@2.8.1(transitive)
- Removed@turf/helpers@6.5.0(transitive)
- Removed@turf/invariant@6.5.0(transitive)
Updated@turf/helpers@^7.0.0-alpha.0