Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

terraformer

Package Overview
Dependencies
Maintainers
1
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

terraformer - npm Package Compare versions

Comparing version 1.0.3 to 1.0.4

docs-build/assets/css/terraformer-a32d97d4.css

2

package.json
{
"name": "terraformer",
"version": "1.0.3",
"version": "1.0.4",
"description": "A Geo-toolkit built in Javascript.",

@@ -5,0 +5,0 @@ "main": "terraformer.js",

@@ -172,2 +172,10 @@ if(typeof module === "object"){

it("should be able to tell a non-convex polygon using Tools", function(){
expect(Terraformer.Tools.isConvex(GeoJSON.polygons[1].coordinates[0])).toEqual(false);
});
it("should be able to tell a convex polygon using Tools", function(){
expect(Terraformer.Tools.isConvex(GeoJSON.polygons[0].coordinates[0])).toEqual(true);
});
it("should calculate envelope", function(){

@@ -232,3 +240,3 @@ expect(point.envelope()).toEqual({ x: 45, y: 60, w: 0, h: 0 });

expect(multiPoint.convexHull().coordinates).toEqual([
[ [ -45, 122 ], [ 80, -60 ], [ 100, 0 ], [ -45, 122 ] ]
[ [ 100, 0 ], [ -45, 122 ], [ 80, -60 ], [ 100, 0 ] ]
]);

@@ -292,3 +300,3 @@ });

expect(lineString.convexHull().coordinates).toEqual([
[ [ -45, 122 ], [ 80, -60 ], [ 100, 0 ], [ -45, 122 ] ]
[ [ 100, 0 ], [ -45, 122 ], [ 80, -60 ], [ 100, 0 ] ]
]);

@@ -341,3 +349,3 @@ });

expect(multiLineString.convexHull().coordinates).toEqual([
[ [ -115, 55 ], [ -110, 45 ], [ -105, 40 ], [ -100, 40 ], [ -110, 55 ], [ -115, 55 ] ]
[ [ -100, 40 ], [ -110, 55 ], [ -115, 55 ], [ -110, 45 ], [ -105, 40 ], [ -100, 40 ] ]
]);

@@ -405,3 +413,3 @@ });

expect(polygon.convexHull().coordinates).toEqual([
[ [ 100, 1 ], [ 100, 0 ], [ 101, 0 ], [ 101, 1 ], [ 100, 1 ] ]
[ [ 101, 1 ], [ 100, 1 ], [ 100, 0 ], [ 101, 0 ], [ 101, 1 ] ]
]);

@@ -417,3 +425,3 @@ expect(polygon.convexHull().type).toEqual("Polygon");

describe("MultiPolygon", function(){
var multiPolygon;
var multiPolygon, mp;

@@ -430,3 +438,3 @@ beforeEach(function(){

it("should return true when a MultiPolygon intersects another", function(){
var mp = new Terraformer.MultiPolygon([
mp = new Terraformer.MultiPolygon([
[

@@ -458,4 +466,10 @@ [ [102.0, 2.0], [103.0, 2.0], [103.0, 3.0], [102.0, 3.0], [102.0, 2.0] ]

it("should calculate convex hull", function (){
expect(multiPolygon.convexHull().coordinates).toEqual([
[ [ 102, 3 ], [ 100, 1 ], [ 100, 0 ], [ 101, 0 ], [ 103, 2 ], [ 103, 3 ], [ 102, 3 ] ]
expect(mp.convexHull().coordinates).toEqual([
[ [ 103, 3 ],
[ 102, 3 ],
[ 100, 1 ],
[ 100, 0 ],
[ 102, 0 ],
[ 103, 2 ],
[ 103, 3 ] ]
]);

@@ -603,3 +617,3 @@ expect(multiPolygon.convexHull().type).toEqual("Polygon");

expect(feature.convexHull().coordinates).toEqual([
[ [ 41.83, 71.01 ], [ 21.79, 36.56 ], [ 56.95, 33.75 ], [ 41.83, 71.01 ] ]
[ [ 56.95, 33.75 ], [ 41.83, 71.01 ], [ 21.79, 36.56 ], [ 56.95, 33.75 ] ]
]);

@@ -606,0 +620,0 @@ });

@@ -405,6 +405,10 @@ (function (root, factory) {

function compSort(p1, p2) {
if(p1[0] - p2[0] > p1[1] - p2[1]) {
if (p1[0] > p2[0]) {
return -1;
} else if (p1[0] < p2[0]) {
return 1;
} else if(p1[0] - p2[0] < p1[1] - p2[1]) {
} else if (p1[1] > p2[1]) {
return -1;
} else if (p1[1] < p2[1]) {
return 1;
} else {

@@ -416,55 +420,54 @@ return 0;

/*
Internal: used to determine turn
*/
function turn(p, q, r) {
// Returns -1, 0, 1 if p,q,r forms a right, straight, or left turn.
return cmp((q[0] - p[0]) * (r[1] - p[1]) - (r[0] - p[0]) * (q[1] - p[1]), 0);
function ccw(p1, p2, p3) {
return (p2[0] - p1[0]) * (p3[1] - p1[1]) - (p2[1] - p1[1]) * (p3[0] - p1[0]);
}
/*
Internal: used to determine euclidean distance between two points
*/
function euclideanDistance(p, q) {
// Returns the squared Euclidean distance between p and q.
var dx = q[0] - p[0];
var dy = q[1] - p[1];
function convexHull(points) {
var i, t, k = 0;
var hull = [ ];
return dx * dx + dy * dy;
}
points = points.sort(compSort);
function nextHullPoint(points, p) {
// Returns the next point on the convex hull in CCW from p.
var q = p;
for(var r in points) {
var t = turn(p, q, points[r]);
if(t === -1 || t === 0 && euclideanDistance(p, points[r]) > euclideanDistance(p, q)) {
q = points[r];
}
/* lower hull */
for (i = 0; i < points.length; ++i) {
while (k >= 2 && ccw(hull[k-2], hull[k-1], points[i]) <= 0) --k;
hull[k++] = points[i];
}
return q;
/* upper hull */
for (i = points.length - 2, t = k+1; i >= 0; --i) {
while (k >= t && ccw(hull[k-2], hull[k-1], points[i]) <= 0) --k;
hull[k++] = points[i];
}
return hull;
}
function convexHull(points) {
// implementation of the Jarvis March algorithm
// adapted from http://tixxit.wordpress.com/2009/12/09/jarvis-march/
function isConvex(points) {
var ltz;
if(points.length === 0) {
return [];
} else if(points.length === 1) {
return points;
}
for (var i = 0; i < points.length - 3; i++) {
var p1 = points[i];
var p2 = points[i + 1];
var p3 = points[i + 2];
var v = [p2[0] - p1[0], p2[1] - p1[1]];
// Returns the points on the convex hull of points in CCW order.
var hull = [points.sort(compSort)[0]];
// p3.x * v.y - p3.y * v.x + v.x * p1.y - v.y * p1.x
var res = p3[0] * v[1] - p3[1] * v[0] + v[0] * p1[1] - v[1] * p1[0];
for(var p = 0; p < hull.length; p++) {
var q = nextHullPoint(points, hull[p]);
if(q !== hull[0]) {
hull.push(q);
if (i === 0) {
if (res < 0) {
ltz = true;
} else {
ltz = false;
}
} else {
if (ltz && (res > 0) || !ltz && (res < 0)) {
return false;
}
}
}
return hull;
return true;
}

@@ -506,3 +509,3 @@

function vertexIntersectsVertex(a1, a2, b1, b2) {
function edgeIntersectsEdge(a1, a2, b1, b2) {
var ua_t = (b2[0] - b1[0]) * (a1[1] - b1[1]) - (b2[1] - b1[1]) * (a1[0] - b1[0]);

@@ -524,21 +527,19 @@ var ub_t = (a2[0] - a1[0]) * (a1[1] - b1[1]) - (a2[1] - a1[1]) * (a1[0] - b1[0]);

function arrayIntersectsArray(a, b) {
for (var i = 0; i < a.length - 1; i++) {
for (var j = 0; j < b.length - 1; j++) {
if (vertexIntersectsVertex(a[i], a[i + 1], b[j], b[j + 1])) {
return true;
}
}
}
return false;
function isNumber(n) {
return !isNaN(parseFloat(n)) && isFinite(n);
}
function arrayIntersectsMultiArray(a, b) {
for (var i = 0; i < b.length; i++) {
var inner = b[i];
for (var j = 0; j < inner.length - 1; j++) {
for (var k = 0; k < a.length - 1; k++) {
if (vertexIntersectsVertex(inner[j], inner[j + 1], a[k], a[k + 1])) {
function arraysIntersectArrays(a, b) {
if (isNumber(a[0][0])) {
if (isNumber(b[0][0])) {
for (var i = 0; i < a.length - 1; i++) {
for (var j = 0; j < b.length - 1; j++) {
if (edgeIntersectsEdge(a[i], a[i + 1], b[j], b[j + 1])) {
return true;
}
}
}
} else {
for (var k = 0; k < b.length; k++) {
if (arraysIntersectArrays(a, b[k])) {
return true;

@@ -548,47 +549,12 @@ }

}
}
return false;
}
function multiArrayIntersectsMultiArray(a, b) {
for (var i = 0; i < a.length; i++) {
if (arrayIntersectsMultiArray(a[i], b)) {
return true;
} else {
for (var l = 0; l < a.length; l++) {
if (arraysIntersectArrays(a[l], b)) {
return true;
}
}
}
return false;
}
function arrayIntersectsMultiMultiArray(a, b) {
for (var i = 0; i < b.length; i++) {
if (arrayIntersectsMultiArray(a, b[i])) {
return true;
}
return false;
}
}
function multiArrayIntersectsMultiMultiArray(a, b) {
for (var i = 0; i < a.length; i++) {
if (arrayIntersectsMultiMultiArray(a[i], b)) {
return true;
}
return false;
}
}
function multiMultiArrayIntersectsMultiMultiArray(a, b) {
for (var i = 0; i < a.length; i++) {
if (multiArrayIntersectsMultiMultiArray(a[i], b)) {
return true;
}
return false;
}
}
/*

@@ -817,3 +783,3 @@ Internal: Returns a copy of coordinates for s closed polygon

if (this.coordinates.length && polygonContainsPoint(primitive.coordinates, this.coordinates[0][0])) {
return !multiArrayIntersectsMultiArray(closedPolygon(this.coordinates), closedPolygon(primitive.coordinates));
return !arraysIntersectArrays(closedPolygon(this.coordinates), closedPolygon(primitive.coordinates));
} else {

@@ -875,3 +841,3 @@ return false;

coordinates = primitive.coordinates[i];
if (polygonContainsPoint(coordinates, this.coordinates) && multiArrayIntersectsMultiArray(this.coordinates, primitive.coordinates) === false) {
if (polygonContainsPoint(coordinates, this.coordinates) && arraysIntersectArrays([this.coordinates], primitive.coordinates) === false) {
return true;

@@ -895,3 +861,3 @@ }

if (multiArrayIntersectsMultiMultiArray(this.coordinates, primitive.coordinates) === false) {
if (arraysIntersectArrays(this.coordinates, primitive.coordinates) === false) {
if (primitive.coordinates.length) {

@@ -964,38 +930,6 @@ for (i = 0; i < primitive.coordinates.length; i++) {

if (this.type === 'LineString') {
if (primitive.type === 'LineString') {
return arrayIntersectsArray(this.coordinates, primitive.coordinates);
} else if (primitive.type === 'MultiLineString') {
return arrayIntersectsMultiArray(this.coordinates, primitive.coordinates);
} else if (primitive.type === 'Polygon') {
return arrayIntersectsMultiArray(this.coordinates, closedPolygon(primitive.coordinates));
} else if (primitive.type === 'MultiPolygon') {
return arrayIntersectsMultiMultiArray(this.coordinates, primitive.coordinates);
}
} else if (this.type === 'MultiLineString') {
if (primitive.type === 'LineString') {
return arrayIntersectsMultiArray(primitive.coordinates, this.coordinates);
} else if (primitive.type === 'Polygon' || primitive.type === 'MultiLineString') {
return multiArrayIntersectsMultiArray(this.coordinates, primitive.coordinates);
} else if (primitive.type === 'MultiPolygon') {
return multiArrayIntersectsMultiMultiArray(this.coordinates, primitive.coordinates);
}
} else if (this.type === 'Polygon') {
if (primitive.type === 'LineString') {
return arrayIntersectsMultiArray(primitive.coordinates, closedPolygon(this.coordinates));
} else if (primitive.type === 'MultiLineString') {
return multiArrayIntersectsMultiArray(closedPolygon(this.coordinates), primitive.coordinates);
} else if (primitive.type === 'Polygon') {
return multiArrayIntersectsMultiArray(closedPolygon(this.coordinates), closedPolygon(primitive.coordinates));
} else if (primitive.type === 'MultiPolygon') {
return multiArrayIntersectsMultiMultiArray(closedPolygon(this.coordinates), primitive.coordinates);
}
} else if (this.type === 'MultiPolygon') {
if (primitive.type === 'LineString') {
return arrayIntersectsMultiMultiArray(primitive.coordinates, this.coordinates);
} else if (primitive.type === 'Polygon' || primitive.type === 'MultiLineString') {
return multiArrayIntersectsMultiMultiArray(closedPolygon(primitive.coordinates), this.coordinates);
} else if (primitive.type === 'MultiPolygon') {
return multiMultiArrayIntersectsMultiMultiArray(this.coordinates, primitive.coordinates);
}
if (this.type !== 'Point' && this.type !== 'MultiPoint' &&
primitive.type !== 'Point' && primitive.type !== 'MultiPoint') {
return arraysIntersectArrays(this.coordinates, primitive.coordinates);
} else if (this.type === 'Feature') {

@@ -1437,6 +1371,7 @@ // in the case of a Feature, use the internal primitive for intersection

exports.Tools.polygonContainsPoint = polygonContainsPoint;
exports.Tools.arrayIntersectsArray = arrayIntersectsArray;
exports.Tools.arraysIntersectArrays = arraysIntersectArrays;
exports.Tools.coordinatesContainPoint = coordinatesContainPoint;
exports.Tools.coordinatesEqual = coordinatesEqual;
exports.Tools.convexHull = convexHull;
exports.Tools.isConvex = isConvex;

@@ -1443,0 +1378,0 @@ exports.MercatorCRS = MercatorCRS;

@@ -1,4 +0,4 @@

/*! Terraformer JS - 1.0.3 - 2014-02-24
/*! Terraformer JS - 1.0.4 - 2014-05-22
* https://github.com/esri/Terraformer
* Copyright (c) 2014 Environmental Systems Research Institute, Inc.
* Licensed MIT */!function(a,b){"object"==typeof module&&"object"==typeof module.exports&&(exports=module.exports=b()),"object"==typeof window&&(a.Terraformer=b())}(this,function(){function a(a){return"[object Array]"===Object.prototype.toString.call(a)}function b(){var a=Array.prototype.slice.apply(arguments);void 0!==typeof console&&console.warn&&console.warn.apply(console,a)}function c(a,b){for(var c in b)b.hasOwnProperty(c)&&(a[c]=b[c]);return a}function d(a){if(a.type)switch(a.type){case"Point":return[a.coordinates[0],a.coordinates[1],a.coordinates[0],a.coordinates[1]];case"MultiPoint":return g(a.coordinates);case"LineString":return g(a.coordinates);case"MultiLineString":return e(a.coordinates);case"Polygon":return e(a.coordinates);case"MultiPolygon":return f(a.coordinates);case"Feature":return a.geometry?d(a.geometry):null;case"FeatureCollection":return h(a);case"GeometryCollection":return i(a);default:throw new Error("Unknown type: "+a.type)}return null}function e(a){for(var b=null,c=null,d=null,e=null,f=0;f<a.length;f++)for(var g=a[f],h=0;h<g.length;h++){var i=g[h],j=i[0],k=i[1];null===b?b=j:b>j&&(b=j),null===c?c=j:j>c&&(c=j),null===d?d=k:d>k&&(d=k),null===e?e=k:k>e&&(e=k)}return[b,d,c,e]}function f(a){for(var b=null,c=null,d=null,e=null,f=0;f<a.length;f++)for(var g=a[f],h=0;h<g.length;h++)for(var i=g[h],j=0;j<i.length;j++){var k=i[j],l=k[0],m=k[1];null===b?b=l:b>l&&(b=l),null===c?c=l:l>c&&(c=l),null===d?d=m:d>m&&(d=m),null===e?e=m:m>e&&(e=m)}return[b,d,c,e]}function g(a){for(var b=null,c=null,d=null,e=null,f=0;f<a.length;f++){var g=a[f],h=g[0],i=g[1];null===b?b=h:b>h&&(b=h),null===c?c=h:h>c&&(c=h),null===d?d=i:d>i&&(d=i),null===e?e=i:i>e&&(e=i)}return[b,d,c,e]}function h(a){for(var b,c=[],e=a.features.length-1;e>=0;e--)b=d(a.features[e].geometry),c.push([b[0],b[1]]),c.push([b[2],b[3]]);return g(c)}function i(a){for(var b,c=[],e=a.geometries.length-1;e>=0;e--)b=d(a.geometries[e]),c.push([b[0],b[1]]),c.push([b[2],b[3]]);return g(c)}function k(a){var b=d(a);return{x:b[0],y:b[1],w:Math.abs(b[0]-b[2]),h:Math.abs(b[1]-b[3])}}function l(a){return a*Z}function m(a){return a*$}function n(a,b){for(var c=0;c<a.length;c++)"number"==typeof a[c][0]&&(a[c]=b(a[c])),"object"==typeof a[c]&&(a[c]=n(a[c],b));return a}function o(a){var b=a[0],c=a[1];return[l(b/Y)-360*Math.floor((l(b/Y)+180)/360),l(Math.PI/2-2*Math.atan(Math.exp(-1*c/Y)))]}function p(a){var b=a[0],c=Math.max(Math.min(a[1],89.99999),-89.99999);return[m(b)*Y,Y/2*Math.log((1+Math.sin(m(c)))/(1-Math.sin(m(c))))]}function q(a,b,c){if("Point"===a.type)a.coordinates=b(a.coordinates);else if("Feature"===a.type)a.geometry=q(a.geometry,b,!0);else if("FeatureCollection"===a.type)for(var d=0;d<a.features.length;d++)a.features[d]=q(a.features[d],b,!0);else if("GeometryCollection"===a.type)for(var e=0;e<a.geometries.length;e++)a.geometries[e]=q(a.geometries[e],b,!0);else a.coordinates=n(a.coordinates,b);return c||b===p&&(a.crs=_),b===o&&delete a.crs,a}function r(a){return q(a,p)}function s(a){return q(a,o)}function t(a,b){return b>a?-1:a>b?1:0}function u(a,b){return a[0]-b[0]>a[1]-b[1]?1:a[0]-b[0]<a[1]-b[1]?-1:0}function v(a,b,c){return t((b[0]-a[0])*(c[1]-a[1])-(c[0]-a[0])*(b[1]-a[1]),0)}function w(a,b){var c=b[0]-a[0],d=b[1]-a[1];return c*c+d*d}function x(a,b){var c=b;for(var d in a){var e=v(b,c,a[d]);(-1===e||0===e&&w(b,a[d])>w(b,c))&&(c=a[d])}return c}function y(a){if(0===a.length)return[];if(1===a.length)return a;for(var b=[a.sort(u)[0]],c=0;c<b.length;c++){var d=x(a,b[c]);d!==b[0]&&b.push(d)}return b}function z(a,b){for(var c=!1,d=-1,e=a.length,f=e-1;++d<e;f=d)(a[d][1]<=b[1]&&b[1]<a[f][1]||a[f][1]<=b[1]&&b[1]<a[d][1])&&b[0]<(a[f][0]-a[d][0])*(b[1]-a[d][1])/(a[f][1]-a[d][1])+a[d][0]&&(c=!c);return c}function A(a,b){if(a&&a.length){if(1===a.length)return z(a[0],b);if(z(a[0],b)){for(var c=1;c<a.length;c++)if(z(a[c],b))return!1;return!0}return!1}return!1}function B(a,b,c,d){var e=(d[0]-c[0])*(a[1]-c[1])-(d[1]-c[1])*(a[0]-c[0]),f=(b[0]-a[0])*(a[1]-c[1])-(b[1]-a[1])*(a[0]-c[0]),g=(d[1]-c[1])*(b[0]-a[0])-(d[0]-c[0])*(b[1]-a[1]);if(0!==g){var h=e/g,i=f/g;if(h>=0&&1>=h&&i>=0&&1>=i)return!0}return!1}function C(a,b){for(var c=0;c<a.length-1;c++)for(var d=0;d<b.length-1;d++)if(B(a[c],a[c+1],b[d],b[d+1]))return!0;return!1}function D(a,b){for(var c=0;c<b.length;c++)for(var d=b[c],e=0;e<d.length-1;e++)for(var f=0;f<a.length-1;f++)if(B(d[e],d[e+1],a[f],a[f+1]))return!0;return!1}function E(a,b){for(var c=0;c<a.length;c++)if(D(a[c],b))return!0;return!1}function F(a,b){for(var c=0;c<b.length;c++)return D(a,b[c])?!0:!1}function G(a,b){for(var c=0;c<a.length;c++)return F(a[c],b)?!0:!1}function H(a,b){for(var c=0;c<a.length;c++)return G(a[c],b)?!0:!1}function I(a){for(var b=[],c=0;c<a.length;c++){var d=a[c].slice();J(d[0],d[d.length-1])===!1&&d.push(d[0]),b.push(d)}return b}function J(a,b){for(var c=0;c<a.length;c++)if(a[c]!==b[c])return!1;return!0}function K(a,b){if(a.length!==b.length)return!1;for(var c=a.slice().sort(u),d=b.slice().sort(u),e=0;e<c.length;e++){if(c[e].length!==d[e].length)return!1;for(var f=0;f<c.length;f++)if(c[e][f]!==d[e][f])return!1}return!0}function L(a){if(a)switch(a.type){case"Point":return new M(a);case"MultiPoint":return new N(a);case"LineString":return new O(a);case"MultiLineString":return new P(a);case"Polygon":return new Q(a);case"MultiPolygon":return new R(a);case"Feature":return new S(a);case"FeatureCollection":return new T(a);case"GeometryCollection":return new U(a);default:throw new Error("Unknown type: "+a.type)}}function M(b){var d=Array.prototype.slice.call(arguments);if(b&&"Point"===b.type&&b.coordinates)c(this,b);else if(b&&a(b))this.coordinates=b;else{if(!(d.length>=2))throw"Terraformer: invalid input for Terraformer.Point";this.coordinates=d}this.type="Point"}function N(b){if(b&&"MultiPoint"===b.type&&b.coordinates)c(this,b);else{if(!a(b))throw"Terraformer: invalid input for Terraformer.MultiPoint";this.coordinates=b}this.type="MultiPoint"}function O(b){if(b&&"LineString"===b.type&&b.coordinates)c(this,b);else{if(!a(b))throw"Terraformer: invalid input for Terraformer.LineString";this.coordinates=b}this.type="LineString"}function P(b){if(b&&"MultiLineString"===b.type&&b.coordinates)c(this,b);else{if(!a(b))throw"Terraformer: invalid input for Terraformer.MultiLineString";this.coordinates=b}this.type="MultiLineString"}function Q(b){if(b&&"Polygon"===b.type&&b.coordinates)c(this,b);else{if(!a(b))throw"Terraformer: invalid input for Terraformer.Polygon";this.coordinates=b}this.type="Polygon"}function R(b){if(b&&"MultiPolygon"===b.type&&b.coordinates)c(this,b);else{if(!a(b))throw"Terraformer: invalid input for Terraformer.MultiPolygon";this.coordinates=b}this.type="MultiPolygon"}function S(a){if(a&&"Feature"===a.type)c(this,a);else{if(!(a&&a.type&&a.coordinates))throw"Terraformer: invalid input for Terraformer.Feature";this.geometry=a}this.type="Feature"}function T(b){if(b&&"FeatureCollection"===b.type&&b.features)c(this,b);else{if(!a(b))throw"Terraformer: invalid input for Terraformer.FeatureCollection";this.features=b}this.type="FeatureCollection"}function U(b){if(b&&"GeometryCollection"===b.type&&b.geometries)c(this,b);else if(a(b))this.geometries=b;else{if(!b.coordinates||!b.type)throw"Terraformer: invalid input for Terraformer.GeometryCollection";this.type="GeometryCollection",this.geometries=[b]}this.type="GeometryCollection"}function V(a,b,c){for(var d=p(a),e=c||64,f={type:"Polygon",coordinates:[[]]},g=1;e>=g;g++){var h=g*(360/e)*Math.PI/180;f.coordinates[0].push([d[0]+b*Math.cos(h),d[1]+b*Math.sin(h)])}return f.coordinates=I(f.coordinates),s(f)}function W(a,b,d){var e=d||64,f=b||250;if(!a||a.length<2||!f||!e)throw new Error("Terraformer: missing parameter for Terraformer.Circle");c(this,new S({type:"Feature",geometry:V(a,f,e),properties:{radius:f,center:a,steps:e}}))}var X={},Y=6378137,Z=57.29577951308232,$=.017453292519943,_={type:"link",properties:{href:"http://spatialreference.org/ref/sr-org/6928/ogcwkt/",type:"ogcwkt"}},ab={type:"link",properties:{href:"http://spatialreference.org/ref/epsg/4326/ogcwkt/",type:"ogcwkt"}},bb=["length"];return L.prototype.toMercator=function(){return r(this)},L.prototype.toGeographic=function(){return s(this)},L.prototype.envelope=function(){return k(this)},L.prototype.bbox=function(){return d(this)},L.prototype.convexHull=function(){var a,b,c=[];if("Point"===this.type)return null;if("LineString"===this.type||"MultiPoint"===this.type){if(!(this.coordinates&&this.coordinates.length>=3))return null;c=this.coordinates}else if("Polygon"===this.type||"MultiLineString"===this.type){if(!(this.coordinates&&this.coordinates.length>0))return null;for(a=0;a<this.coordinates.length;a++)c=c.concat(this.coordinates[a]);if(c.length<3)return null}else if("MultiPolygon"===this.type){if(!(this.coordinates&&this.coordinates.length>0))return null;for(a=0;a<this.coordinates.length;a++)for(b=0;b<this.coordinates[a].length;b++)c=c.concat(this.coordinates[a][b]);if(c.length<3)return null}else if("Feature"===this.type){var d=new L(this.geometry);return d.convexHull()}return new Q({type:"Polygon",coordinates:I([y(c)])})},L.prototype.toJSON=function(){var a={};for(var b in this)this.hasOwnProperty(b)&&-1===bb.indexOf(b)&&(a[b]=this[b]);return a.bbox=d(this),a},L.prototype.contains=function(a){return new L(a).within(this)},L.prototype.within=function(a){var b,c,d;if("Point"===a.type&&"Point"===this.type)return J(this.coordinates,a.coordinates);if("MultiLineString"===a.type&&"Point"===this.type)for(c=0;c<a.coordinates.length;c++){var e={type:"LineString",coordinates:a.coordinates[c]};if(this.within(e))return!0}if(("LineString"===a.type||"MultiPoint"===a.type)&&"Point"===this.type)for(c=0;c<a.coordinates.length;c++){if(this.coordinates.length!==a.coordinates[c].length)return!1;if(J(this.coordinates,a.coordinates[c]))return!0}if("Polygon"===a.type){if("Polygon"===this.type){if(a.coordinates.length===this.coordinates.length)for(c=0;c<this.coordinates.length;c++)if(K(this.coordinates[c],a.coordinates[c]))return!0;return this.coordinates.length&&A(a.coordinates,this.coordinates[0][0])?!E(I(this.coordinates),I(a.coordinates)):!1}if("Point"===this.type)return A(a.coordinates,this.coordinates);if("LineString"===this.type||"MultiPoint"===this.type){if(!this.coordinates||0===this.coordinates.length)return!1;for(c=0;c<this.coordinates.length;c++)if(A(a.coordinates,this.coordinates[c])===!1)return!1;return!0}if("MultiLineString"===this.type){for(c=0;c<this.coordinates.length;c++){var f=new O(this.coordinates[c]);if(f.within(a)===!1)return d++,!1}return!0}if("MultiPolygon"===this.type){for(c=0;c<this.coordinates.length;c++){var g=new L({type:"Polygon",coordinates:this.coordinates[c]});if(g.within(a)===!1)return!1}return!0}}if("MultiPolygon"===a.type){if("Point"===this.type){if(a.coordinates.length)for(c=0;c<a.coordinates.length;c++)if(b=a.coordinates[c],A(b,this.coordinates)&&E(this.coordinates,a.coordinates)===!1)return!0;return!1}if("Polygon"===this.type){for(c=0;c<this.coordinates.length;c++)if(a.coordinates[c].length===this.coordinates.length)for(j=0;j<this.coordinates.length;j++)if(K(this.coordinates[j],a.coordinates[c][j]))return!0;if(G(this.coordinates,a.coordinates)===!1&&a.coordinates.length){for(c=0;c<a.coordinates.length;c++)b=a.coordinates[c],d=A(b,this.coordinates[0][0])===!1?!1:!0;return d}}else if("LineString"===this.type||"MultiPoint"===this.type)for(c=0;c<a.coordinates.length;c++){var h={type:"Polygon",coordinates:a.coordinates[c]};return this.within(h)?!0:!1}else{if("MultiLineString"===this.type){for(c=0;c<this.coordinates.length;c++){var i=new O(this.coordinates[c]);if(i.within(a)===!1)return!1}return!0}if("MultiPolygon"===this.type){for(c=0;c<a.coordinates.length;c++){var k={type:"Polygon",coordinates:a.coordinates[c]};if(this.within(k)===!1)return!1}return!0}}}return!1},L.prototype.intersects=function(a){"Feature"===a.type&&(a=a.geometry);var c=new L(a);if(this.within(a)||c.within(this))return!0;if("LineString"===this.type){if("LineString"===a.type)return C(this.coordinates,a.coordinates);if("MultiLineString"===a.type)return D(this.coordinates,a.coordinates);if("Polygon"===a.type)return D(this.coordinates,I(a.coordinates));if("MultiPolygon"===a.type)return F(this.coordinates,a.coordinates)}else if("MultiLineString"===this.type){if("LineString"===a.type)return D(a.coordinates,this.coordinates);if("Polygon"===a.type||"MultiLineString"===a.type)return E(this.coordinates,a.coordinates);if("MultiPolygon"===a.type)return G(this.coordinates,a.coordinates)}else if("Polygon"===this.type){if("LineString"===a.type)return D(a.coordinates,I(this.coordinates));if("MultiLineString"===a.type)return E(I(this.coordinates),a.coordinates);if("Polygon"===a.type)return E(I(this.coordinates),I(a.coordinates));if("MultiPolygon"===a.type)return G(I(this.coordinates),a.coordinates)}else if("MultiPolygon"===this.type){if("LineString"===a.type)return F(a.coordinates,this.coordinates);if("Polygon"===a.type||"MultiLineString"===a.type)return G(I(a.coordinates),this.coordinates);if("MultiPolygon"===a.type)return H(this.coordinates,a.coordinates)}else if("Feature"===this.type){var d=new L(this.geometry);return d.intersects(a)}return b("Type "+this.type+" to "+a.type+" intersection is not supported by intersects"),!1},M.prototype=new L,M.prototype.constructor=M,N.prototype=new L,N.prototype.constructor=N,N.prototype.forEach=function(a){for(var b=0;b<this.coordinates.length;b++)a.apply(this,[this.coordinates[b],b,this.coordinates]);return this},N.prototype.addPoint=function(a){return this.coordinates.push(a),this},N.prototype.insertPoint=function(a,b){return this.coordinates.splice(b,0,a),this},N.prototype.removePoint=function(a){return"number"==typeof a?this.coordinates.splice(a,1):this.coordinates.splice(this.coordinates.indexOf(a),1),this},N.prototype.get=function(a){return new M(this.coordinates[a])},O.prototype=new L,O.prototype.constructor=O,O.prototype.addVertex=function(a){return this.coordinates.push(a),this},O.prototype.insertVertex=function(a,b){return this.coordinates.splice(b,0,a),this},O.prototype.removeVertex=function(a){return this.coordinates.splice(a,1),this},P.prototype=new L,P.prototype.constructor=P,P.prototype.forEach=function(a){for(var b=0;b<this.coordinates.length;b++)a.apply(this,[this.coordinates[b],b,this.coordinates])},P.prototype.get=function(a){return new O(this.coordinates[a])},Q.prototype=new L,Q.prototype.constructor=Q,Q.prototype.addVertex=function(a){return this.coordinates[0].push(a),this},Q.prototype.insertVertex=function(a,b){return this.coordinates[0].splice(b,0,a),this},Q.prototype.removeVertex=function(a){return this.coordinates[0].splice(a,1),this},Q.prototype.close=function(){this.coordinates=I(this.coordinates)},R.prototype=new L,R.prototype.constructor=R,R.prototype.forEach=function(a){for(var b=0;b<this.coordinates.length;b++)a.apply(this,[this.coordinates[b],b,this.coordinates])},R.prototype.get=function(a){return new Q(this.coordinates[a])},R.prototype.close=function(){var a=[];return this.forEach(function(b){a.push(I(b))}),this.coordinates=a,this},S.prototype=new L,S.prototype.constructor=S,T.prototype=new L,T.prototype.constructor=T,T.prototype.forEach=function(a){for(var b=0;b<this.features.length;b++)a.apply(this,[this.features[b],b,this.features])},T.prototype.get=function(a){var b;return this.forEach(function(c){c.id===a&&(b=c)}),new S(b)},U.prototype=new L,U.prototype.constructor=U,U.prototype.forEach=function(a){for(var b=0;b<this.geometries.length;b++)a.apply(this,[this.geometries[b],b,this.geometries])},U.prototype.get=function(a){return new L(this.geometries[a])},W.prototype=new L,W.prototype.constructor=W,W.prototype.recalculate=function(){return this.geometry=V(this.properties.center,this.properties.radius,this.properties.steps),this},W.prototype.center=function(a){return a&&(this.properties.center=a,this.recalculate()),this.properties.center},W.prototype.radius=function(a){return a&&(this.properties.radius=a,this.recalculate()),this.properties.radius},W.prototype.steps=function(a){return a&&(this.properties.steps=a,this.recalculate()),this.properties.steps},W.prototype.toJSON=function(){var a=L.prototype.toJSON.call(this);return a},X.Primitive=L,X.Point=M,X.MultiPoint=N,X.LineString=O,X.MultiLineString=P,X.Polygon=Q,X.MultiPolygon=R,X.Feature=S,X.FeatureCollection=T,X.GeometryCollection=U,X.Circle=W,X.toMercator=r,X.toGeographic=s,X.Tools={},X.Tools.positionToMercator=p,X.Tools.positionToGeographic=o,X.Tools.applyConverter=q,X.Tools.toMercator=r,X.Tools.toGeographic=s,X.Tools.createCircle=V,X.Tools.calculateBounds=d,X.Tools.calculateEnvelope=k,X.Tools.coordinatesContainPoint=z,X.Tools.polygonContainsPoint=A,X.Tools.arrayIntersectsArray=C,X.Tools.coordinatesContainPoint=z,X.Tools.coordinatesEqual=K,X.Tools.convexHull=y,X.MercatorCRS=_,X.GeographicCRS=ab,X});
* Licensed MIT */!function(a,b){"object"==typeof module&&"object"==typeof module.exports&&(exports=module.exports=b()),"object"==typeof window&&(a.Terraformer=b())}(this,function(){function a(a){return"[object Array]"===Object.prototype.toString.call(a)}function b(){var a=Array.prototype.slice.apply(arguments);void 0!==typeof console&&console.warn&&console.warn.apply(console,a)}function c(a,b){for(var c in b)b.hasOwnProperty(c)&&(a[c]=b[c]);return a}function d(a){if(a.type)switch(a.type){case"Point":return[a.coordinates[0],a.coordinates[1],a.coordinates[0],a.coordinates[1]];case"MultiPoint":return g(a.coordinates);case"LineString":return g(a.coordinates);case"MultiLineString":return e(a.coordinates);case"Polygon":return e(a.coordinates);case"MultiPolygon":return f(a.coordinates);case"Feature":return a.geometry?d(a.geometry):null;case"FeatureCollection":return h(a);case"GeometryCollection":return i(a);default:throw new Error("Unknown type: "+a.type)}return null}function e(a){for(var b=null,c=null,d=null,e=null,f=0;f<a.length;f++)for(var g=a[f],h=0;h<g.length;h++){var i=g[h],j=i[0],k=i[1];null===b?b=j:b>j&&(b=j),null===c?c=j:j>c&&(c=j),null===d?d=k:d>k&&(d=k),null===e?e=k:k>e&&(e=k)}return[b,d,c,e]}function f(a){for(var b=null,c=null,d=null,e=null,f=0;f<a.length;f++)for(var g=a[f],h=0;h<g.length;h++)for(var i=g[h],j=0;j<i.length;j++){var k=i[j],l=k[0],m=k[1];null===b?b=l:b>l&&(b=l),null===c?c=l:l>c&&(c=l),null===d?d=m:d>m&&(d=m),null===e?e=m:m>e&&(e=m)}return[b,d,c,e]}function g(a){for(var b=null,c=null,d=null,e=null,f=0;f<a.length;f++){var g=a[f],h=g[0],i=g[1];null===b?b=h:b>h&&(b=h),null===c?c=h:h>c&&(c=h),null===d?d=i:d>i&&(d=i),null===e?e=i:i>e&&(e=i)}return[b,d,c,e]}function h(a){for(var b,c=[],e=a.features.length-1;e>=0;e--)b=d(a.features[e].geometry),c.push([b[0],b[1]]),c.push([b[2],b[3]]);return g(c)}function i(a){for(var b,c=[],e=a.geometries.length-1;e>=0;e--)b=d(a.geometries[e]),c.push([b[0],b[1]]),c.push([b[2],b[3]]);return g(c)}function k(a){var b=d(a);return{x:b[0],y:b[1],w:Math.abs(b[0]-b[2]),h:Math.abs(b[1]-b[3])}}function l(a){return a*T}function m(a){return a*U}function n(a,b){for(var c=0;c<a.length;c++)"number"==typeof a[c][0]&&(a[c]=b(a[c])),"object"==typeof a[c]&&(a[c]=n(a[c],b));return a}function o(a){var b=a[0],c=a[1];return[l(b/S)-360*Math.floor((l(b/S)+180)/360),l(Math.PI/2-2*Math.atan(Math.exp(-1*c/S)))]}function p(a){var b=a[0],c=Math.max(Math.min(a[1],89.99999),-89.99999);return[m(b)*S,S/2*Math.log((1+Math.sin(m(c)))/(1-Math.sin(m(c))))]}function q(a,b,c){if("Point"===a.type)a.coordinates=b(a.coordinates);else if("Feature"===a.type)a.geometry=q(a.geometry,b,!0);else if("FeatureCollection"===a.type)for(var d=0;d<a.features.length;d++)a.features[d]=q(a.features[d],b,!0);else if("GeometryCollection"===a.type)for(var e=0;e<a.geometries.length;e++)a.geometries[e]=q(a.geometries[e],b,!0);else a.coordinates=n(a.coordinates,b);return c||b===p&&(a.crs=V),b===o&&delete a.crs,a}function r(a){return q(a,p)}function s(a){return q(a,o)}function t(a,b){return a[0]>b[0]?-1:a[0]<b[0]?1:a[1]>b[1]?-1:a[1]<b[1]?1:0}function u(a,b,c){return(b[0]-a[0])*(c[1]-a[1])-(b[1]-a[1])*(c[0]-a[0])}function v(a){var b,c,d=0,e=[];for(a=a.sort(t),b=0;b<a.length;++b){for(;d>=2&&u(e[d-2],e[d-1],a[b])<=0;)--d;e[d++]=a[b]}for(b=a.length-2,c=d+1;b>=0;--b){for(;d>=c&&u(e[d-2],e[d-1],a[b])<=0;)--d;e[d++]=a[b]}return e}function w(a){for(var b,c=0;c<a.length-3;c++){var d=a[c],e=a[c+1],f=a[c+2],g=[e[0]-d[0],e[1]-d[1]],h=f[0]*g[1]-f[1]*g[0]+g[0]*d[1]-g[1]*d[0];if(0===c)b=0>h?!0:!1;else if(b&&h>0||!b&&0>h)return!1}return!0}function x(a,b){for(var c=!1,d=-1,e=a.length,f=e-1;++d<e;f=d)(a[d][1]<=b[1]&&b[1]<a[f][1]||a[f][1]<=b[1]&&b[1]<a[d][1])&&b[0]<(a[f][0]-a[d][0])*(b[1]-a[d][1])/(a[f][1]-a[d][1])+a[d][0]&&(c=!c);return c}function y(a,b){if(a&&a.length){if(1===a.length)return x(a[0],b);if(x(a[0],b)){for(var c=1;c<a.length;c++)if(x(a[c],b))return!1;return!0}return!1}return!1}function z(a,b,c,d){var e=(d[0]-c[0])*(a[1]-c[1])-(d[1]-c[1])*(a[0]-c[0]),f=(b[0]-a[0])*(a[1]-c[1])-(b[1]-a[1])*(a[0]-c[0]),g=(d[1]-c[1])*(b[0]-a[0])-(d[0]-c[0])*(b[1]-a[1]);if(0!==g){var h=e/g,i=f/g;if(h>=0&&1>=h&&i>=0&&1>=i)return!0}return!1}function A(a){return!isNaN(parseFloat(a))&&isFinite(a)}function B(a,b){if(A(a[0][0])){if(A(b[0][0])){for(var c=0;c<a.length-1;c++)for(var d=0;d<b.length-1;d++)if(z(a[c],a[c+1],b[d],b[d+1]))return!0}else for(var e=0;e<b.length;e++)if(B(a,b[e]))return!0}else for(var f=0;f<a.length;f++)if(B(a[f],b))return!0;return!1}function C(a){for(var b=[],c=0;c<a.length;c++){var d=a[c].slice();D(d[0],d[d.length-1])===!1&&d.push(d[0]),b.push(d)}return b}function D(a,b){for(var c=0;c<a.length;c++)if(a[c]!==b[c])return!1;return!0}function E(a,b){if(a.length!==b.length)return!1;for(var c=a.slice().sort(t),d=b.slice().sort(t),e=0;e<c.length;e++){if(c[e].length!==d[e].length)return!1;for(var f=0;f<c.length;f++)if(c[e][f]!==d[e][f])return!1}return!0}function F(a){if(a)switch(a.type){case"Point":return new G(a);case"MultiPoint":return new H(a);case"LineString":return new I(a);case"MultiLineString":return new J(a);case"Polygon":return new K(a);case"MultiPolygon":return new L(a);case"Feature":return new M(a);case"FeatureCollection":return new N(a);case"GeometryCollection":return new O(a);default:throw new Error("Unknown type: "+a.type)}}function G(b){var d=Array.prototype.slice.call(arguments);if(b&&"Point"===b.type&&b.coordinates)c(this,b);else if(b&&a(b))this.coordinates=b;else{if(!(d.length>=2))throw"Terraformer: invalid input for Terraformer.Point";this.coordinates=d}this.type="Point"}function H(b){if(b&&"MultiPoint"===b.type&&b.coordinates)c(this,b);else{if(!a(b))throw"Terraformer: invalid input for Terraformer.MultiPoint";this.coordinates=b}this.type="MultiPoint"}function I(b){if(b&&"LineString"===b.type&&b.coordinates)c(this,b);else{if(!a(b))throw"Terraformer: invalid input for Terraformer.LineString";this.coordinates=b}this.type="LineString"}function J(b){if(b&&"MultiLineString"===b.type&&b.coordinates)c(this,b);else{if(!a(b))throw"Terraformer: invalid input for Terraformer.MultiLineString";this.coordinates=b}this.type="MultiLineString"}function K(b){if(b&&"Polygon"===b.type&&b.coordinates)c(this,b);else{if(!a(b))throw"Terraformer: invalid input for Terraformer.Polygon";this.coordinates=b}this.type="Polygon"}function L(b){if(b&&"MultiPolygon"===b.type&&b.coordinates)c(this,b);else{if(!a(b))throw"Terraformer: invalid input for Terraformer.MultiPolygon";this.coordinates=b}this.type="MultiPolygon"}function M(a){if(a&&"Feature"===a.type)c(this,a);else{if(!(a&&a.type&&a.coordinates))throw"Terraformer: invalid input for Terraformer.Feature";this.geometry=a}this.type="Feature"}function N(b){if(b&&"FeatureCollection"===b.type&&b.features)c(this,b);else{if(!a(b))throw"Terraformer: invalid input for Terraformer.FeatureCollection";this.features=b}this.type="FeatureCollection"}function O(b){if(b&&"GeometryCollection"===b.type&&b.geometries)c(this,b);else if(a(b))this.geometries=b;else{if(!b.coordinates||!b.type)throw"Terraformer: invalid input for Terraformer.GeometryCollection";this.type="GeometryCollection",this.geometries=[b]}this.type="GeometryCollection"}function P(a,b,c){for(var d=p(a),e=c||64,f={type:"Polygon",coordinates:[[]]},g=1;e>=g;g++){var h=g*(360/e)*Math.PI/180;f.coordinates[0].push([d[0]+b*Math.cos(h),d[1]+b*Math.sin(h)])}return f.coordinates=C(f.coordinates),s(f)}function Q(a,b,d){var e=d||64,f=b||250;if(!a||a.length<2||!f||!e)throw new Error("Terraformer: missing parameter for Terraformer.Circle");c(this,new M({type:"Feature",geometry:P(a,f,e),properties:{radius:f,center:a,steps:e}}))}var R={},S=6378137,T=57.29577951308232,U=.017453292519943,V={type:"link",properties:{href:"http://spatialreference.org/ref/sr-org/6928/ogcwkt/",type:"ogcwkt"}},W={type:"link",properties:{href:"http://spatialreference.org/ref/epsg/4326/ogcwkt/",type:"ogcwkt"}},X=["length"];return F.prototype.toMercator=function(){return r(this)},F.prototype.toGeographic=function(){return s(this)},F.prototype.envelope=function(){return k(this)},F.prototype.bbox=function(){return d(this)},F.prototype.convexHull=function(){var a,b,c=[];if("Point"===this.type)return null;if("LineString"===this.type||"MultiPoint"===this.type){if(!(this.coordinates&&this.coordinates.length>=3))return null;c=this.coordinates}else if("Polygon"===this.type||"MultiLineString"===this.type){if(!(this.coordinates&&this.coordinates.length>0))return null;for(a=0;a<this.coordinates.length;a++)c=c.concat(this.coordinates[a]);if(c.length<3)return null}else if("MultiPolygon"===this.type){if(!(this.coordinates&&this.coordinates.length>0))return null;for(a=0;a<this.coordinates.length;a++)for(b=0;b<this.coordinates[a].length;b++)c=c.concat(this.coordinates[a][b]);if(c.length<3)return null}else if("Feature"===this.type){var d=new F(this.geometry);return d.convexHull()}return new K({type:"Polygon",coordinates:C([v(c)])})},F.prototype.toJSON=function(){var a={};for(var b in this)this.hasOwnProperty(b)&&-1===X.indexOf(b)&&(a[b]=this[b]);return a.bbox=d(this),a},F.prototype.contains=function(a){return new F(a).within(this)},F.prototype.within=function(a){var b,c,d;if("Point"===a.type&&"Point"===this.type)return D(this.coordinates,a.coordinates);if("MultiLineString"===a.type&&"Point"===this.type)for(c=0;c<a.coordinates.length;c++){var e={type:"LineString",coordinates:a.coordinates[c]};if(this.within(e))return!0}if(("LineString"===a.type||"MultiPoint"===a.type)&&"Point"===this.type)for(c=0;c<a.coordinates.length;c++){if(this.coordinates.length!==a.coordinates[c].length)return!1;if(D(this.coordinates,a.coordinates[c]))return!0}if("Polygon"===a.type){if("Polygon"===this.type){if(a.coordinates.length===this.coordinates.length)for(c=0;c<this.coordinates.length;c++)if(E(this.coordinates[c],a.coordinates[c]))return!0;return this.coordinates.length&&y(a.coordinates,this.coordinates[0][0])?!B(C(this.coordinates),C(a.coordinates)):!1}if("Point"===this.type)return y(a.coordinates,this.coordinates);if("LineString"===this.type||"MultiPoint"===this.type){if(!this.coordinates||0===this.coordinates.length)return!1;for(c=0;c<this.coordinates.length;c++)if(y(a.coordinates,this.coordinates[c])===!1)return!1;return!0}if("MultiLineString"===this.type){for(c=0;c<this.coordinates.length;c++){var f=new I(this.coordinates[c]);if(f.within(a)===!1)return d++,!1}return!0}if("MultiPolygon"===this.type){for(c=0;c<this.coordinates.length;c++){var g=new F({type:"Polygon",coordinates:this.coordinates[c]});if(g.within(a)===!1)return!1}return!0}}if("MultiPolygon"===a.type){if("Point"===this.type){if(a.coordinates.length)for(c=0;c<a.coordinates.length;c++)if(b=a.coordinates[c],y(b,this.coordinates)&&B([this.coordinates],a.coordinates)===!1)return!0;return!1}if("Polygon"===this.type){for(c=0;c<this.coordinates.length;c++)if(a.coordinates[c].length===this.coordinates.length)for(j=0;j<this.coordinates.length;j++)if(E(this.coordinates[j],a.coordinates[c][j]))return!0;if(B(this.coordinates,a.coordinates)===!1&&a.coordinates.length){for(c=0;c<a.coordinates.length;c++)b=a.coordinates[c],d=y(b,this.coordinates[0][0])===!1?!1:!0;return d}}else if("LineString"===this.type||"MultiPoint"===this.type)for(c=0;c<a.coordinates.length;c++){var h={type:"Polygon",coordinates:a.coordinates[c]};return this.within(h)?!0:!1}else{if("MultiLineString"===this.type){for(c=0;c<this.coordinates.length;c++){var i=new I(this.coordinates[c]);if(i.within(a)===!1)return!1}return!0}if("MultiPolygon"===this.type){for(c=0;c<a.coordinates.length;c++){var k={type:"Polygon",coordinates:a.coordinates[c]};if(this.within(k)===!1)return!1}return!0}}}return!1},F.prototype.intersects=function(a){"Feature"===a.type&&(a=a.geometry);var c=new F(a);if(this.within(a)||c.within(this))return!0;if("Point"!==this.type&&"MultiPoint"!==this.type&&"Point"!==a.type&&"MultiPoint"!==a.type)return B(this.coordinates,a.coordinates);if("Feature"===this.type){var d=new F(this.geometry);return d.intersects(a)}return b("Type "+this.type+" to "+a.type+" intersection is not supported by intersects"),!1},G.prototype=new F,G.prototype.constructor=G,H.prototype=new F,H.prototype.constructor=H,H.prototype.forEach=function(a){for(var b=0;b<this.coordinates.length;b++)a.apply(this,[this.coordinates[b],b,this.coordinates]);return this},H.prototype.addPoint=function(a){return this.coordinates.push(a),this},H.prototype.insertPoint=function(a,b){return this.coordinates.splice(b,0,a),this},H.prototype.removePoint=function(a){return"number"==typeof a?this.coordinates.splice(a,1):this.coordinates.splice(this.coordinates.indexOf(a),1),this},H.prototype.get=function(a){return new G(this.coordinates[a])},I.prototype=new F,I.prototype.constructor=I,I.prototype.addVertex=function(a){return this.coordinates.push(a),this},I.prototype.insertVertex=function(a,b){return this.coordinates.splice(b,0,a),this},I.prototype.removeVertex=function(a){return this.coordinates.splice(a,1),this},J.prototype=new F,J.prototype.constructor=J,J.prototype.forEach=function(a){for(var b=0;b<this.coordinates.length;b++)a.apply(this,[this.coordinates[b],b,this.coordinates])},J.prototype.get=function(a){return new I(this.coordinates[a])},K.prototype=new F,K.prototype.constructor=K,K.prototype.addVertex=function(a){return this.coordinates[0].push(a),this},K.prototype.insertVertex=function(a,b){return this.coordinates[0].splice(b,0,a),this},K.prototype.removeVertex=function(a){return this.coordinates[0].splice(a,1),this},K.prototype.close=function(){this.coordinates=C(this.coordinates)},L.prototype=new F,L.prototype.constructor=L,L.prototype.forEach=function(a){for(var b=0;b<this.coordinates.length;b++)a.apply(this,[this.coordinates[b],b,this.coordinates])},L.prototype.get=function(a){return new K(this.coordinates[a])},L.prototype.close=function(){var a=[];return this.forEach(function(b){a.push(C(b))}),this.coordinates=a,this},M.prototype=new F,M.prototype.constructor=M,N.prototype=new F,N.prototype.constructor=N,N.prototype.forEach=function(a){for(var b=0;b<this.features.length;b++)a.apply(this,[this.features[b],b,this.features])},N.prototype.get=function(a){var b;return this.forEach(function(c){c.id===a&&(b=c)}),new M(b)},O.prototype=new F,O.prototype.constructor=O,O.prototype.forEach=function(a){for(var b=0;b<this.geometries.length;b++)a.apply(this,[this.geometries[b],b,this.geometries])},O.prototype.get=function(a){return new F(this.geometries[a])},Q.prototype=new F,Q.prototype.constructor=Q,Q.prototype.recalculate=function(){return this.geometry=P(this.properties.center,this.properties.radius,this.properties.steps),this},Q.prototype.center=function(a){return a&&(this.properties.center=a,this.recalculate()),this.properties.center},Q.prototype.radius=function(a){return a&&(this.properties.radius=a,this.recalculate()),this.properties.radius},Q.prototype.steps=function(a){return a&&(this.properties.steps=a,this.recalculate()),this.properties.steps},Q.prototype.toJSON=function(){var a=F.prototype.toJSON.call(this);return a},R.Primitive=F,R.Point=G,R.MultiPoint=H,R.LineString=I,R.MultiLineString=J,R.Polygon=K,R.MultiPolygon=L,R.Feature=M,R.FeatureCollection=N,R.GeometryCollection=O,R.Circle=Q,R.toMercator=r,R.toGeographic=s,R.Tools={},R.Tools.positionToMercator=p,R.Tools.positionToGeographic=o,R.Tools.applyConverter=q,R.Tools.toMercator=r,R.Tools.toGeographic=s,R.Tools.createCircle=P,R.Tools.calculateBounds=d,R.Tools.calculateEnvelope=k,R.Tools.coordinatesContainPoint=x,R.Tools.polygonContainsPoint=y,R.Tools.arraysIntersectArrays=B,R.Tools.coordinatesContainPoint=x,R.Tools.coordinatesEqual=E,R.Tools.convexHull=v,R.Tools.isConvex=w,R.MercatorCRS=V,R.GeographicCRS=W,R});

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc