@turf/difference
Advanced tools
Comparing version 5.0.5 to 5.1.0
12
main.js
@@ -53,4 +53,4 @@ 'use strict'; | ||
geom2 = removeEmptyPolygon(geom2); | ||
if (!geom1) return null; | ||
if (!geom2) return helpers.feature(geom1, properties); | ||
if (!geom1) { return null; } | ||
if (!geom2) { return helpers.feature(geom1, properties); } | ||
@@ -62,3 +62,3 @@ // JSTS difference operation | ||
var differenced = turfJsts.OverlayOp.difference(a, b); | ||
if (differenced.isEmpty()) return null; | ||
if (differenced.isEmpty()) { return null; } | ||
var writer = new turfJsts.GeoJSONWriter(); | ||
@@ -80,3 +80,3 @@ var geom = writer.write(differenced); | ||
case 'Polygon': | ||
if (area(geom) > 1) return geom; | ||
if (area(geom) > 1) { return geom; } | ||
return null; | ||
@@ -86,5 +86,5 @@ case 'MultiPolygon': | ||
meta.flattenEach(geom, function (feature$$1) { | ||
if (area(feature$$1) > 1) coordinates.push(feature$$1.geometry.coordinates); | ||
if (area(feature$$1) > 1) { coordinates.push(feature$$1.geometry.coordinates); } | ||
}); | ||
if (coordinates.length) return {type: 'MultiPolygon', coordinates: coordinates}; | ||
if (coordinates.length) { return {type: 'MultiPolygon', coordinates: coordinates}; } | ||
} | ||
@@ -91,0 +91,0 @@ } |
{ | ||
"name": "@turf/difference", | ||
"version": "5.0.5", | ||
"version": "5.1.0", | ||
"description": "turf difference module", | ||
"main": "main", | ||
"module": "index", | ||
"jsnext:main": "index", | ||
"main": "main.js", | ||
"module": "main.mjs", | ||
"types": "index.d.ts", | ||
@@ -12,3 +11,4 @@ "files": [ | ||
"index.d.ts", | ||
"main.js" | ||
"main.js", | ||
"main.mjs" | ||
], | ||
@@ -41,2 +41,3 @@ "scripts": { | ||
"rollup": "*", | ||
"rollup-plugin-buble": "*", | ||
"tape": "*", | ||
@@ -46,6 +47,6 @@ "write-json-file": "*" | ||
"dependencies": { | ||
"@turf/area": "^5.0.4", | ||
"@turf/helpers": "^5.0.4", | ||
"@turf/invariant": "^5.0.4", | ||
"@turf/meta": "^5.0.4", | ||
"@turf/area": "^5.1.0", | ||
"@turf/helpers": "^5.1.0", | ||
"@turf/invariant": "^5.1.0", | ||
"@turf/meta": "^5.1.0", | ||
"turf-jsts": "*" | ||
@@ -52,0 +53,0 @@ }, |
@@ -7,8 +7,8 @@ # @turf/difference | ||
Finds the difference between two [polygons](http://geojson.org/geojson-spec.html#polygon) by clipping the second polygon from the first. | ||
Finds the difference between two [polygons](https://tools.ietf.org/html/rfc7946#section-3.1.6) by clipping the second polygon from the first. | ||
**Parameters** | ||
- `polygon1` **[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))>** input Polygon feature | ||
- `polygon2` **[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))>** Polygon feature to difference from polygon1 | ||
- `polygon1` **[Feature](https://tools.ietf.org/html/rfc7946#section-3.2)<([Polygon](https://tools.ietf.org/html/rfc7946#section-3.1.6) \| [MultiPolygon](https://tools.ietf.org/html/rfc7946#section-3.1.7))>** input Polygon feature | ||
- `polygon2` **[Feature](https://tools.ietf.org/html/rfc7946#section-3.2)<([Polygon](https://tools.ietf.org/html/rfc7946#section-3.1.6) \| [MultiPolygon](https://tools.ietf.org/html/rfc7946#section-3.1.7))>** Polygon feature to difference from polygon1 | ||
@@ -45,3 +45,3 @@ **Examples** | ||
Returns **([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))> | null)** a Polygon or MultiPolygon feature showing the area of `polygon1` excluding the area of `polygon2` (if empty returns `null`) | ||
Returns **([Feature](https://tools.ietf.org/html/rfc7946#section-3.2)<([Polygon](https://tools.ietf.org/html/rfc7946#section-3.1.6) \| [MultiPolygon](https://tools.ietf.org/html/rfc7946#section-3.1.7))> | null)** a Polygon or MultiPolygon feature showing the area of `polygon1` excluding the area of `polygon2` (if empty returns `null`) | ||
@@ -48,0 +48,0 @@ <!-- This file is automatically generated. Please don't edit it directly: |
12847
7
248
8
Updated@turf/area@^5.1.0
Updated@turf/helpers@^5.1.0
Updated@turf/invariant@^5.1.0
Updated@turf/meta@^5.1.0