@terraformer/spatial
Advanced tools
Comparing version 2.0.2 to 2.0.5
/* @preserve | ||
* @terraformer/spatial - v2.0.2 - MIT | ||
* @terraformer/spatial - v2.0.4 - MIT | ||
* Copyright (c) 2012-2020 Environmental Systems Research Institute, Inc. | ||
* Thu Apr 16 2020 00:21:36 GMT-0700 (Pacific Daylight Time) | ||
* Sun May 17 2020 12:38:50 GMT-0700 (Pacific Daylight Time) | ||
*/ | ||
@@ -82,6 +82,6 @@ /* Copyright (c) 2012-2019 Environmental Systems Research Institute, Inc. | ||
const MercatorCRS = { | ||
'type': 'link', | ||
'properties': { | ||
'href': 'http://spatialreference.org/ref/sr-org/6928/ogcwkt/', | ||
'type': 'ogcwkt' | ||
type: 'link', | ||
properties: { | ||
href: 'http://spatialreference.org/ref/sr-org/6928/ogcwkt/', | ||
type: 'ogcwkt' | ||
} | ||
@@ -91,6 +91,6 @@ }; | ||
const GeographicCRS = { | ||
'type': 'link', | ||
'properties': { | ||
'href': 'http://spatialreference.org/ref/epsg/4326/ogcwkt/', | ||
'type': 'ogcwkt' | ||
type: 'link', | ||
properties: { | ||
href: 'http://spatialreference.org/ref/epsg/4326/ogcwkt/', | ||
type: 'ogcwkt' | ||
} | ||
@@ -173,3 +173,3 @@ }; | ||
let q = p; | ||
for (let r in points) { | ||
for (const r in points) { | ||
const t = turn(p, q, points[r]); | ||
@@ -194,3 +194,3 @@ if (t === -1 || (t === 0 && euclideanDistance(p, points[r]) > euclideanDistance(p, q))) { | ||
// Returns the points on the convex hull of points in CCW order. | ||
let hull = [points.sort(compSort)[0]]; | ||
const hull = [points.sort(compSort)[0]]; | ||
@@ -212,6 +212,6 @@ for (var p = 0; p < hull.length; p++) { | ||
const closedPolygon = (coordinates) => { | ||
let outer = []; | ||
const outer = []; | ||
for (let i = 0; i < coordinates.length; i++) { | ||
let inner = coordinates[i].slice(); | ||
const inner = coordinates[i].slice(); | ||
if (pointsEqual(inner[0], inner[inner.length - 1]) === false) { | ||
@@ -465,3 +465,3 @@ inner.push(inner[0]); | ||
const calculateBoundsForFeatureCollection = (featureCollection) => { | ||
let extents = []; | ||
const extents = []; | ||
for (let i = featureCollection.features.length - 1; i >= 0; i--) { | ||
@@ -480,3 +480,3 @@ const extent = calculateBounds(featureCollection.features[i].geometry); | ||
const calculateBoundsForGeometryCollection = (geometryCollection) => { | ||
let extents = []; | ||
const extents = []; | ||
@@ -705,4 +705,4 @@ for (let i = geometryCollection.geometries.length - 1; i >= 0; i--) { | ||
const ls = { | ||
'type': 'LineString', | ||
'coordinates': geoJSON.coordinates[i] | ||
type: 'LineString', | ||
coordinates: geoJSON.coordinates[i] | ||
}; | ||
@@ -786,3 +786,3 @@ if (within(ls, comparisonGeoJSON) === false) { | ||
for (i = 0; i < geoJSON.coordinates.length; i++) { | ||
const ls = { 'type': 'LineString', 'coordinates': geoJSON.coordinates[i] }; | ||
const ls = { type: 'LineString', coordinates: geoJSON.coordinates[i] }; | ||
@@ -839,2 +839,8 @@ if (within(ls, comparisonGeoJSON) === false) { | ||
const VINCENTY = { | ||
a: 6378137, | ||
b: 6356752.3142, | ||
f: 1 / 298.257223563 | ||
}; | ||
const toGeographic = (geojson) => applyConverter(geojson, positionToGeographic); | ||
@@ -852,3 +858,3 @@ | ||
type: 'Feature', | ||
geometry: createCircle(center, rad, steps), | ||
geometry: createGeodesicCircle(center, rad, steps), | ||
properties: { | ||
@@ -862,4 +868,6 @@ radius: rad, | ||
const createCircle = (center, radius, interpolate) => { | ||
const mercatorPosition = positionToMercator(center); | ||
/* cribbed from | ||
http://stackoverflow.com/questions/24145205/writing-a-function-to-convert-a-circle-to-a-polygon-using-leaflet-js | ||
*/ | ||
const createGeodesicCircle = (center, radius, interpolate) => { | ||
const steps = interpolate || 64; | ||
@@ -870,11 +878,55 @@ const polygon = { | ||
}; | ||
for (var i = 1; i <= steps; i++) { | ||
const radians = i * (360 / steps) * Math.PI / 180; | ||
polygon.coordinates[0].push([mercatorPosition[0] + radius * Math.cos(radians), mercatorPosition[1] + radius * Math.sin(radians)]); | ||
let angle; | ||
for (var i = 0; i < steps; i++) { | ||
angle = (i * 360 / steps); | ||
polygon.coordinates[0].push(destinationVincenty(center, angle, radius)); | ||
} | ||
polygon.coordinates = closedPolygon(polygon.coordinates); | ||
return toGeographic(polygon); | ||
return polygon; | ||
}; | ||
const destinationVincenty = (coords, brng, dist) => { | ||
var cos2SigmaM, sinSigma, cosSigma, deltaSigma; | ||
var a = VINCENTY.a; var b = VINCENTY.b; var f = VINCENTY.f; | ||
var lon1 = coords[0]; | ||
var lat1 = coords[1]; | ||
var s = dist; | ||
var pi = Math.PI; | ||
var alpha1 = brng * pi / 180; // converts brng degrees to radius | ||
var sinAlpha1 = Math.sin(alpha1); | ||
var cosAlpha1 = Math.cos(alpha1); | ||
var tanU1 = (1 - f) * Math.tan(lat1 * pi / 180 /* converts lat1 degrees to radius */); | ||
var cosU1 = 1 / Math.sqrt((1 + tanU1 * tanU1)); var sinU1 = tanU1 * cosU1; | ||
var sigma1 = Math.atan2(tanU1, cosAlpha1); | ||
var sinAlpha = cosU1 * sinAlpha1; | ||
var cosSqAlpha = 1 - sinAlpha * sinAlpha; | ||
var uSq = cosSqAlpha * (a * a - b * b) / (b * b); | ||
var A = 1 + uSq / 16384 * (4096 + uSq * (-768 + uSq * (320 - 175 * uSq))); | ||
var B = uSq / 1024 * (256 + uSq * (-128 + uSq * (74 - 47 * uSq))); | ||
var sigma = s / (b * A); var sigmaP = 2 * Math.PI; | ||
while (Math.abs(sigma - sigmaP) > 1e-12) { | ||
cos2SigmaM = Math.cos(2 * sigma1 + sigma); | ||
sinSigma = Math.sin(sigma); | ||
cosSigma = Math.cos(sigma); | ||
deltaSigma = B * sinSigma * (cos2SigmaM + B / 4 * (cosSigma * (-1 + 2 * cos2SigmaM * cos2SigmaM) - | ||
B / 6 * cos2SigmaM * (-3 + 4 * sinSigma * sinSigma) * (-3 + 4 * cos2SigmaM * cos2SigmaM))); | ||
sigmaP = sigma; | ||
sigma = s / (b * A) + deltaSigma; | ||
} | ||
var tmp = sinU1 * sinSigma - cosU1 * cosSigma * cosAlpha1; | ||
var lat2 = Math.atan2(sinU1 * cosSigma + cosU1 * sinSigma * cosAlpha1, | ||
(1 - f) * Math.sqrt(sinAlpha * sinAlpha + tmp * tmp)); | ||
var lambda = Math.atan2(sinSigma * sinAlpha1, cosU1 * cosSigma - sinU1 * sinSigma * cosAlpha1); | ||
var C = f / 16 * cosSqAlpha * (4 + f * (4 - 3 * cosSqAlpha)); | ||
var lam = lambda - (1 - C) * f * sinAlpha * | ||
(sigma + C * sinSigma * (cos2SigmaM + C * cosSigma * (-1 + 2 * cos2SigmaM * cos2SigmaM))); | ||
var lamFunc = lon1 + (lam * 180 / pi); // converts lam radius to degrees | ||
var lat2a = lat2 * 180 / pi; // converts lat2a radius to degrees | ||
return [lamFunc, lat2a]; | ||
}; | ||
/* Copyright (c) 2012-2019 Environmental Systems Research Institute, Inc. | ||
@@ -886,3 +938,3 @@ * Apache-2.0 */ | ||
* @function | ||
* @param {object} GeoJSON - The input [GeoJSON](https://tools.ietf.org/html/rfc7946) Geometry, Feature, GeometryCollection or ReatureCollection. | ||
* @param {object} GeoJSON - The input [GeoJSON](https://tools.ietf.org/html/rfc7946) Geometry, Feature, GeometryCollection or FeatureCollection. | ||
* @return {Object} Object in the form { x, y, w, h }. | ||
@@ -913,3 +965,3 @@ * ```js | ||
* @function | ||
* @param {object} GeoJSON - The input [GeoJSON](https://tools.ietf.org/html/rfc7946) Geometry, Feature, GeometryCollection or ReatureCollection. | ||
* @param {object} GeoJSON - The input [GeoJSON](https://tools.ietf.org/html/rfc7946) Geometry, Feature, GeometryCollection or FeatureCollection. | ||
* @return {object} GeoJSON | ||
@@ -916,0 +968,0 @@ * ```js |
/* @preserve | ||
* @terraformer/spatial - v2.0.2 - MIT | ||
* @terraformer/spatial - v2.0.4 - MIT | ||
* Copyright (c) 2012-2020 Environmental Systems Research Institute, Inc. | ||
* Thu Apr 16 2020 00:21:35 GMT-0700 (Pacific Daylight Time) | ||
* Sun May 17 2020 12:38:49 GMT-0700 (Pacific Daylight Time) | ||
*/ | ||
@@ -88,6 +88,6 @@ (function (global, factory) { | ||
const MercatorCRS = { | ||
'type': 'link', | ||
'properties': { | ||
'href': 'http://spatialreference.org/ref/sr-org/6928/ogcwkt/', | ||
'type': 'ogcwkt' | ||
type: 'link', | ||
properties: { | ||
href: 'http://spatialreference.org/ref/sr-org/6928/ogcwkt/', | ||
type: 'ogcwkt' | ||
} | ||
@@ -97,6 +97,6 @@ }; | ||
const GeographicCRS = { | ||
'type': 'link', | ||
'properties': { | ||
'href': 'http://spatialreference.org/ref/epsg/4326/ogcwkt/', | ||
'type': 'ogcwkt' | ||
type: 'link', | ||
properties: { | ||
href: 'http://spatialreference.org/ref/epsg/4326/ogcwkt/', | ||
type: 'ogcwkt' | ||
} | ||
@@ -179,3 +179,3 @@ }; | ||
let q = p; | ||
for (let r in points) { | ||
for (const r in points) { | ||
const t = turn(p, q, points[r]); | ||
@@ -200,3 +200,3 @@ if (t === -1 || (t === 0 && euclideanDistance(p, points[r]) > euclideanDistance(p, q))) { | ||
// Returns the points on the convex hull of points in CCW order. | ||
let hull = [points.sort(compSort)[0]]; | ||
const hull = [points.sort(compSort)[0]]; | ||
@@ -218,6 +218,6 @@ for (var p = 0; p < hull.length; p++) { | ||
const closedPolygon = (coordinates) => { | ||
let outer = []; | ||
const outer = []; | ||
for (let i = 0; i < coordinates.length; i++) { | ||
let inner = coordinates[i].slice(); | ||
const inner = coordinates[i].slice(); | ||
if (pointsEqual(inner[0], inner[inner.length - 1]) === false) { | ||
@@ -471,3 +471,3 @@ inner.push(inner[0]); | ||
const calculateBoundsForFeatureCollection = (featureCollection) => { | ||
let extents = []; | ||
const extents = []; | ||
for (let i = featureCollection.features.length - 1; i >= 0; i--) { | ||
@@ -486,3 +486,3 @@ const extent = calculateBounds(featureCollection.features[i].geometry); | ||
const calculateBoundsForGeometryCollection = (geometryCollection) => { | ||
let extents = []; | ||
const extents = []; | ||
@@ -711,4 +711,4 @@ for (let i = geometryCollection.geometries.length - 1; i >= 0; i--) { | ||
const ls = { | ||
'type': 'LineString', | ||
'coordinates': geoJSON.coordinates[i] | ||
type: 'LineString', | ||
coordinates: geoJSON.coordinates[i] | ||
}; | ||
@@ -792,3 +792,3 @@ if (within(ls, comparisonGeoJSON) === false) { | ||
for (i = 0; i < geoJSON.coordinates.length; i++) { | ||
const ls = { 'type': 'LineString', 'coordinates': geoJSON.coordinates[i] }; | ||
const ls = { type: 'LineString', coordinates: geoJSON.coordinates[i] }; | ||
@@ -845,2 +845,8 @@ if (within(ls, comparisonGeoJSON) === false) { | ||
const VINCENTY = { | ||
a: 6378137, | ||
b: 6356752.3142, | ||
f: 1 / 298.257223563 | ||
}; | ||
const toGeographic = (geojson) => applyConverter(geojson, positionToGeographic); | ||
@@ -858,3 +864,3 @@ | ||
type: 'Feature', | ||
geometry: createCircle(center, rad, steps), | ||
geometry: createGeodesicCircle(center, rad, steps), | ||
properties: { | ||
@@ -868,4 +874,6 @@ radius: rad, | ||
const createCircle = (center, radius, interpolate) => { | ||
const mercatorPosition = positionToMercator(center); | ||
/* cribbed from | ||
http://stackoverflow.com/questions/24145205/writing-a-function-to-convert-a-circle-to-a-polygon-using-leaflet-js | ||
*/ | ||
const createGeodesicCircle = (center, radius, interpolate) => { | ||
const steps = interpolate || 64; | ||
@@ -876,11 +884,55 @@ const polygon = { | ||
}; | ||
for (var i = 1; i <= steps; i++) { | ||
const radians = i * (360 / steps) * Math.PI / 180; | ||
polygon.coordinates[0].push([mercatorPosition[0] + radius * Math.cos(radians), mercatorPosition[1] + radius * Math.sin(radians)]); | ||
let angle; | ||
for (var i = 0; i < steps; i++) { | ||
angle = (i * 360 / steps); | ||
polygon.coordinates[0].push(destinationVincenty(center, angle, radius)); | ||
} | ||
polygon.coordinates = closedPolygon(polygon.coordinates); | ||
return toGeographic(polygon); | ||
return polygon; | ||
}; | ||
const destinationVincenty = (coords, brng, dist) => { | ||
var cos2SigmaM, sinSigma, cosSigma, deltaSigma; | ||
var a = VINCENTY.a; var b = VINCENTY.b; var f = VINCENTY.f; | ||
var lon1 = coords[0]; | ||
var lat1 = coords[1]; | ||
var s = dist; | ||
var pi = Math.PI; | ||
var alpha1 = brng * pi / 180; // converts brng degrees to radius | ||
var sinAlpha1 = Math.sin(alpha1); | ||
var cosAlpha1 = Math.cos(alpha1); | ||
var tanU1 = (1 - f) * Math.tan(lat1 * pi / 180 /* converts lat1 degrees to radius */); | ||
var cosU1 = 1 / Math.sqrt((1 + tanU1 * tanU1)); var sinU1 = tanU1 * cosU1; | ||
var sigma1 = Math.atan2(tanU1, cosAlpha1); | ||
var sinAlpha = cosU1 * sinAlpha1; | ||
var cosSqAlpha = 1 - sinAlpha * sinAlpha; | ||
var uSq = cosSqAlpha * (a * a - b * b) / (b * b); | ||
var A = 1 + uSq / 16384 * (4096 + uSq * (-768 + uSq * (320 - 175 * uSq))); | ||
var B = uSq / 1024 * (256 + uSq * (-128 + uSq * (74 - 47 * uSq))); | ||
var sigma = s / (b * A); var sigmaP = 2 * Math.PI; | ||
while (Math.abs(sigma - sigmaP) > 1e-12) { | ||
cos2SigmaM = Math.cos(2 * sigma1 + sigma); | ||
sinSigma = Math.sin(sigma); | ||
cosSigma = Math.cos(sigma); | ||
deltaSigma = B * sinSigma * (cos2SigmaM + B / 4 * (cosSigma * (-1 + 2 * cos2SigmaM * cos2SigmaM) - | ||
B / 6 * cos2SigmaM * (-3 + 4 * sinSigma * sinSigma) * (-3 + 4 * cos2SigmaM * cos2SigmaM))); | ||
sigmaP = sigma; | ||
sigma = s / (b * A) + deltaSigma; | ||
} | ||
var tmp = sinU1 * sinSigma - cosU1 * cosSigma * cosAlpha1; | ||
var lat2 = Math.atan2(sinU1 * cosSigma + cosU1 * sinSigma * cosAlpha1, | ||
(1 - f) * Math.sqrt(sinAlpha * sinAlpha + tmp * tmp)); | ||
var lambda = Math.atan2(sinSigma * sinAlpha1, cosU1 * cosSigma - sinU1 * sinSigma * cosAlpha1); | ||
var C = f / 16 * cosSqAlpha * (4 + f * (4 - 3 * cosSqAlpha)); | ||
var lam = lambda - (1 - C) * f * sinAlpha * | ||
(sigma + C * sinSigma * (cos2SigmaM + C * cosSigma * (-1 + 2 * cos2SigmaM * cos2SigmaM))); | ||
var lamFunc = lon1 + (lam * 180 / pi); // converts lam radius to degrees | ||
var lat2a = lat2 * 180 / pi; // converts lat2a radius to degrees | ||
return [lamFunc, lat2a]; | ||
}; | ||
/* Copyright (c) 2012-2019 Environmental Systems Research Institute, Inc. | ||
@@ -892,3 +944,3 @@ * Apache-2.0 */ | ||
* @function | ||
* @param {object} GeoJSON - The input [GeoJSON](https://tools.ietf.org/html/rfc7946) Geometry, Feature, GeometryCollection or ReatureCollection. | ||
* @param {object} GeoJSON - The input [GeoJSON](https://tools.ietf.org/html/rfc7946) Geometry, Feature, GeometryCollection or FeatureCollection. | ||
* @return {Object} Object in the form { x, y, w, h }. | ||
@@ -919,3 +971,3 @@ * ```js | ||
* @function | ||
* @param {object} GeoJSON - The input [GeoJSON](https://tools.ietf.org/html/rfc7946) Geometry, Feature, GeometryCollection or ReatureCollection. | ||
* @param {object} GeoJSON - The input [GeoJSON](https://tools.ietf.org/html/rfc7946) Geometry, Feature, GeometryCollection or FeatureCollection. | ||
* @return {object} GeoJSON | ||
@@ -922,0 +974,0 @@ * ```js |
{ | ||
"name": "@terraformer/spatial", | ||
"description": "Spatial predicates for GeoJSON.", | ||
"version": "2.0.2", | ||
"version": "2.0.5", | ||
"author": "Patrick Arlt <patrick.arlt@gmail.com>", | ||
@@ -39,4 +39,3 @@ "bugs": { | ||
"build": "rollup -c ../../rollup.umd.config.js && rollup -c ../../rollup.esm.config.js", | ||
"doc": "jsdoc2md --files src/index.js --template README.hbs > README.md", | ||
"prepare": "npm run build" | ||
"doc": "jsdoc2md --files src/index.js --template README.hbs > README.md" | ||
}, | ||
@@ -46,3 +45,3 @@ "publishConfig": { | ||
}, | ||
"gitHead": "70ecb3026d4aa20e6ff39da6bc4e74a75ba90bd9" | ||
"gitHead": "9f19918eb640d4c8817da255555a9f525442f3f0" | ||
} |
@@ -29,7 +29,11 @@ # @terraformer/spatial | ||
* [Terraformer](#module_Terraformer) | ||
* [.MercatorCRS](#module_Terraformer.MercatorCRS) | ||
* [.GeographicCRS](#module_Terraformer.GeographicCRS) | ||
* [.calculateBounds(GeoJSON)](#module_Terraformer.calculateBounds) ⇒ <code>Array.<Number></code> | ||
* [.calculateEnvelope(GeoJSON)](#module_Terraformer.calculateEnvelope) ⇒ <code>Object</code> | ||
* [.positionToGeographic(CoordinatePair)](#module_Terraformer.positionToGeographic) ⇒ <code>Array.<Number, Number></code> | ||
* [.positionToMercator(CoordinatePair)](#module_Terraformer.positionToMercator) ⇒ <code>Array.<Number, Number></code> | ||
* [.toMercator(GeoJSON)](#module_Terraformer.toMercator) ⇒ <code>object</code> | ||
* [.convexHull(GeoJSON)](#module_Terraformer.convexHull) ⇒ <code>Array.<Coordinates></code> | ||
* [.isConvex(GeoJSON)](#module_Terraformer.isConvex) ⇒ <code>Boolean</code> | ||
* [.polygonContainsPoint(GeoJSON, GeoJSON)](#module_Terraformer.polygonContainsPoint) ⇒ <code>Boolean</code> | ||
@@ -41,2 +45,14 @@ * [.within(GeoJSON, GeoJSON)](#module_Terraformer.within) ⇒ <code>Boolean</code> | ||
<a name="module_Terraformer.MercatorCRS"></a> | ||
### Terraformer.MercatorCRS | ||
WKID [3857](https://epsg.io/3857) | ||
**Kind**: static constant of [<code>Terraformer</code>](#module_Terraformer) | ||
<a name="module_Terraformer.GeographicCRS"></a> | ||
### Terraformer.GeographicCRS | ||
WKID [4326](https://epsg.io/4326) | ||
**Kind**: static constant of [<code>Terraformer</code>](#module_Terraformer) | ||
<a name="module_Terraformer.calculateBounds"></a> | ||
@@ -62,3 +78,3 @@ | ||
| --- | --- | --- | | ||
| GeoJSON | <code>object</code> | The input [GeoJSON](https://tools.ietf.org/html/rfc7946) Geometry, Feature, GeometryCollection or ReatureCollection. | | ||
| GeoJSON | <code>object</code> | The input [GeoJSON](https://tools.ietf.org/html/rfc7946) Geometry, Feature, GeometryCollection or FeatureCollection. | | ||
@@ -85,3 +101,3 @@ <a name="module_Terraformer.calculateEnvelope"></a> | ||
| --- | --- | --- | | ||
| GeoJSON | <code>object</code> | The input [GeoJSON](https://tools.ietf.org/html/rfc7946) Geometry, Feature, GeometryCollection or ReatureCollection. | | ||
| GeoJSON | <code>object</code> | The input [GeoJSON](https://tools.ietf.org/html/rfc7946) Geometry, Feature, GeometryCollection or FeatureCollection. | | ||
@@ -105,2 +121,19 @@ <a name="module_Terraformer.positionToGeographic"></a> | ||
<a name="module_Terraformer.positionToMercator"></a> | ||
### Terraformer.positionToMercator(CoordinatePair) ⇒ <code>Array.<Number, Number></code> | ||
Reprojects the passed Coordinate pair to web mercator (3857) spatial reference. | ||
**Kind**: static method of [<code>Terraformer</code>](#module_Terraformer) | ||
**Returns**: <code>Array.<Number, Number></code> - CoordinatePair. | ||
```js | ||
import { positionToGeographic } from "@terraformer/spatial" | ||
positionToMercator([ 45, 60 ]) // [ -13580978, 5621521 ] | ||
``` | ||
| Param | Type | Description | | ||
| --- | --- | --- | | ||
| CoordinatePair | <code>Array.<Number, Number></code> | An X,Y position. | | ||
<a name="module_Terraformer.toMercator"></a> | ||
@@ -126,3 +159,3 @@ | ||
| --- | --- | --- | | ||
| GeoJSON | <code>object</code> | The input [GeoJSON](https://tools.ietf.org/html/rfc7946) Geometry, Feature, GeometryCollection or ReatureCollection. | | ||
| GeoJSON | <code>object</code> | The input [GeoJSON](https://tools.ietf.org/html/rfc7946) Geometry, Feature, GeometryCollection or FeatureCollection. | | ||
@@ -140,5 +173,5 @@ <a name="module_Terraformer.convexHull"></a> | ||
convexHull({ | ||
'type': 'LineString', | ||
'coordinates': [ | ||
[100, 0], [-45, 122], [80, -60] | ||
type: "LineString", | ||
coordinates: [ | ||
[ 100, 0 ], [ -45, 122 ], [ 80, -60 ] | ||
] | ||
@@ -151,3 +184,3 @@ }) | ||
coordinates: [ | ||
[ 100, 0 ], [ -45, 122 ], [ 80, -60 ], [ 100, 0 ] | ||
[ [ 100, 0 ], [ -45, 122 ], [ 80, -60 ], [ 100, 0 ] ] | ||
] | ||
@@ -159,4 +192,28 @@ } | ||
| --- | --- | --- | | ||
| GeoJSON | <code>object</code> | The input [GeoJSON](https://tools.ietf.org/html/rfc7946) Geometry, Feature, GeometryCollection or ReatureCollection. | | ||
| GeoJSON | <code>object</code> | The input [GeoJSON](https://tools.ietf.org/html/rfc7946) Geometry, Feature, GeometryCollection or FeatureCollection. | | ||
<a name="module_Terraformer.isConvex"></a> | ||
### Terraformer.isConvex(GeoJSON) ⇒ <code>Boolean</code> | ||
Determine whether input GeoJSON has a [convex](https://en.wikipedia.org/wiki/Convex_set) shape. | ||
**Kind**: static method of [<code>Terraformer</code>](#module_Terraformer) | ||
**Returns**: <code>Boolean</code> - Yes/No | ||
```js | ||
import { isConvex } from "@terraformer/spatial" | ||
isConvex({ | ||
type: "Polygon", | ||
coordinates: [ | ||
[ [ 100, 0 ], [ -45, 122 ], [ 80, -60 ], [ 100, 0 ] ] | ||
] | ||
}) | ||
>> true | ||
``` | ||
| Param | Type | Description | | ||
| --- | --- | --- | | ||
| GeoJSON | <code>Object</code> | The input [GeoJSON](https://tools.ietf.org/html/rfc7946) Geometry, Feature, GeometryCollection or FeatureCollection. | | ||
<a name="module_Terraformer.polygonContainsPoint"></a> | ||
@@ -174,5 +231,5 @@ | ||
[ | ||
[1, 2], [2, 2], [2, 1], [1, 1], [1, 2] | ||
[ [ 1, 2 ], [ 2, 2 ], [ 2, 1 ], [ 1, 1 ], [ 1, 2 ] ] | ||
], | ||
[10, 10] | ||
[ 10, 10 ] | ||
) | ||
@@ -271,4 +328,4 @@ | ||
| --- | --- | --- | | ||
| GeoJSON | <code>Object</code> | The input [GeoJSON](https://tools.ietf.org/html/rfc7946) Geometry, Feature, GeometryCollection or ReatureCollection. | | ||
| GeoJSON | <code>Object</code> | The input [GeoJSON](https://tools.ietf.org/html/rfc7946) Geometry, Feature, GeometryCollection or ReatureCollection. | | ||
| GeoJSON | <code>Object</code> | The input [GeoJSON](https://tools.ietf.org/html/rfc7946) Geometry, Feature, GeometryCollection or FeatureCollection. | | ||
| GeoJSON | <code>Object</code> | The input [GeoJSON](https://tools.ietf.org/html/rfc7946) Geometry, Feature, GeometryCollection or FeatureCollection. | | ||
@@ -275,0 +332,0 @@ <a name="module_Terraformer.toCircle"></a> |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
73203
1665
386
0