@turf/polygon-to-linestring
Advanced tools
Comparing version 4.7.3 to 5.0.0
@@ -1,17 +0,30 @@ | ||
/// <reference types="geojson" /> | ||
import { | ||
Polygon, | ||
MultiPolygon, | ||
Feature, | ||
FeatureCollection, | ||
LineString, | ||
MultiLineString, | ||
GeometryCollection, | ||
FeatureGeometryCollection | ||
} from '@turf/helpers'; | ||
type Polygon = GeoJSON.Feature<GeoJSON.Polygon> | GeoJSON.Polygon; | ||
type MultiPolygon = GeoJSON.Feature<GeoJSON.MultiPolygon> | GeoJSON.MultiPolygon; | ||
type Feature = GeoJSON.Feature<GeoJSON.LineString | GeoJSON.MultiLineString>; | ||
type FeatureCollection = GeoJSON.FeatureCollection<GeoJSON.LineString | GeoJSON.MultiLineString>; | ||
/** | ||
* http://turfjs.org/docs/#polygontolinestring | ||
* | ||
* Feature => LineString | ||
*/ | ||
declare function polygonToLineString<T extends Polygon | MultiPolygon>( | ||
polygon: Feature<T> | T | ||
): Feature<LineString>; | ||
interface PolygonToLineString { | ||
/** | ||
* http://turfjs.org/docs/#polygontolinestring | ||
*/ | ||
(polygon: Polygon): Feature; | ||
(polygon: MultiPolygon): FeatureCollection; | ||
} | ||
/** | ||
* http://turfjs.org/docs/#polygontolinestring | ||
* | ||
* FeatureCollection => MultiLineString | ||
*/ | ||
declare function polygonToLineString<T extends Polygon | MultiPolygon>( | ||
polygon: FeatureCollection<T> | GeometryCollection | FeatureGeometryCollection | ||
): Feature<MultiLineString>; | ||
declare const polygonToLineString: PolygonToLineString | ||
export = polygonToLineString; | ||
export default polygonToLineString; |
19
index.js
@@ -1,6 +0,3 @@ | ||
var getCoords = require('@turf/invariant').getCoords; | ||
var helpers = require('@turf/helpers'); | ||
var lineString = helpers.lineString; | ||
var multiLineString = helpers.multiLineString; | ||
var featureCollection = helpers.featureCollection; | ||
import { getCoords, getType } from '@turf/invariant'; | ||
import { lineString, multiLineString, featureCollection } from '@turf/helpers'; | ||
@@ -12,3 +9,3 @@ /** | ||
* @param {Feature<Polygon|MultiPolygon>} polygon Feature to convert | ||
* @param {Object} [properties] translates GeoJSON properties to Feature | ||
* @param {Object} [properties={}] translates GeoJSON properties to Feature | ||
* @returns {FeatureCollection|Feature<LineString|MultiLinestring>} converted (Multi)Polygon to (Multi)LineString | ||
@@ -23,4 +20,4 @@ * @example | ||
*/ | ||
module.exports = function (polygon, properties) { | ||
var geom = getGeomType(polygon); | ||
function polygonToLinestring(polygon, properties) { | ||
var geom = getType(polygon); | ||
var coords = getCoords(polygon); | ||
@@ -43,3 +40,3 @@ properties = properties || polygon.properties || {}; | ||
} | ||
}; | ||
} | ||
@@ -51,4 +48,2 @@ function coordsToLine(coords, properties) { | ||
function getGeomType(feature) { | ||
return (feature.geometry) ? feature.geometry.type : feature.type; | ||
} | ||
export default polygonToLinestring; |
{ | ||
"name": "@turf/polygon-to-linestring", | ||
"version": "4.7.3", | ||
"version": "5.0.0", | ||
"description": "turf polygon-to-linestring module", | ||
"main": "index.js", | ||
"main": "main", | ||
"module": "index", | ||
"jsnext:main": "index", | ||
"types": "index.d.ts", | ||
"files": [ | ||
"index.js", | ||
"index.d.ts" | ||
"index.d.ts", | ||
"main.js" | ||
], | ||
"scripts": { | ||
"test": "node test.js", | ||
"bench": "node bench.js" | ||
"pretest": "rollup -c ../../rollup.config.js", | ||
"test": "node -r @std/esm test.js", | ||
"posttest": "uglifyjs main.js -o main.min.js", | ||
"bench": "node -r @std/esm bench.js" | ||
}, | ||
@@ -30,11 +35,18 @@ "repository": { | ||
"devDependencies": { | ||
"benchmark": "^2.1.4", | ||
"load-json-file": "^2.0.0", | ||
"tape": "^4.6.3", | ||
"write-json-file": "^2.0.0" | ||
"benchmark": "*", | ||
"load-json-file": "*", | ||
"tape": "*", | ||
"write-json-file": "*", | ||
"rollup": "*", | ||
"@std/esm": "*", | ||
"uglify-js": "*" | ||
}, | ||
"dependencies": { | ||
"@turf/helpers": "^4.7.3", | ||
"@turf/invariant": "^4.7.3" | ||
"@turf/helpers": "5.0.0", | ||
"@turf/invariant": "5.0.0" | ||
}, | ||
"@std/esm": { | ||
"esm": "js", | ||
"cjs": true | ||
} | ||
} |
# @turf/polygon-to-linestring | ||
# polygonToLineString | ||
<!-- Generated by documentation.js. Update this documentation by updating the source code. --> | ||
## polygonToLineString | ||
Converts a [Polygon](http://geojson.org/geojson-spec.html#polygon) to [(Multi)LineString](http://geojson.org/geojson-spec.html#linestring) or [MultiPolygon](http://geojson.org/geojson-spec.html#multipolygon) to a [FeatureCollection](http://geojson.org/geojson-spec.html#feature-collection-objects) of [(Multi)LineString](http://geojson.org/geojson-spec.html#linestring). | ||
@@ -10,3 +12,3 @@ | ||
- `polygon` **[Feature](http://geojson.org/geojson-spec.html#feature-objects)<([Polygon](http://geojson.org/geojson-spec.html#polygon) \| [MultiPolygon](http://geojson.org/geojson-spec.html#multipolygon))>** Feature to convert | ||
- `properties` **\[[Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)]** translates GeoJSON properties to Feature | ||
- `properties` **[Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)** translates GeoJSON properties to Feature (optional, default `{}`) | ||
@@ -13,0 +15,0 @@ **Examples** |
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
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
8315
6
109
51
7
+ Added@turf/helpers@5.0.0(transitive)
+ Added@turf/invariant@5.0.0(transitive)
- Removed@turf/helpers@4.7.3(transitive)
- Removed@turf/invariant@4.7.3(transitive)
Updated@turf/helpers@5.0.0
Updated@turf/invariant@5.0.0