From 20872e547b6c0e2f9048834ba75b5f87da83cdc8 Mon Sep 17 00:00:00 2001 From: moanos Date: Wed, 1 Jan 2025 21:02:10 +0100 Subject: [PATCH] fix: add turf to VC --- .../static/fellchensammlung/js/turf.min.js | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 src/fellchensammlung/static/fellchensammlung/js/turf.min.js diff --git a/src/fellchensammlung/static/fellchensammlung/js/turf.min.js b/src/fellchensammlung/static/fellchensammlung/js/turf.min.js new file mode 100644 index 0000000..635896d --- /dev/null +++ b/src/fellchensammlung/static/fellchensammlung/js/turf.min.js @@ -0,0 +1,37 @@ +!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).turf={})}(this,(function(t){"use strict";function e(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n=t.length?{done:!0}:{done:!1,value:t[r++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,s=!0,a=!1;return{s:function(){n=n.call(t)},n:function(){var t=n.next();return s=t.done,t},e:function(t){a=!0,o=t},f:function(){try{s||null==n.return||n.return()}finally{if(a)throw o}}}}function u(t,e,n){return(e=y(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function l(t){return l=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},l(t)}function h(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&p(t,e)}function c(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(c=function(){return!!t})()}function f(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}function g(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function p(t,e){return p=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},p(t,e)}function v(t,e){return n(t)||function(t,e){var n=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=n){var r,i,o,s,a=[],u=!0,l=!1;try{if(o=(n=n.call(t)).next,0===e){if(Object(n)!==n)return;u=!1}else for(;!(u=(r=o.call(n)).done)&&(a.push(r.value),a.length!==e);u=!0);}catch(t){l=!0,i=t}finally{try{if(!u&&null!=n.return&&(s=n.return(),Object(s)!==s))return}finally{if(l)throw i}}return a}}(t,e)||_(t,e)||g()}function d(t){return function(t){if(Array.isArray(t))return e(t)}(t)||f(t)||_(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function y(t){var e=function(t,e){if("object"!=typeof t||!t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var r=n.call(t,e||"default");if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:e+""}function m(t){return m="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},m(t)}function _(t,n){if(t){if("string"==typeof t)return e(t,n);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?e(t,n):void 0}}var x=6371008.8,E={centimeters:100*x,centimetres:100*x,degrees:360/(2*Math.PI),feet:3.28084*x,inches:39.37*x,kilometers:x/1e3,kilometres:x/1e3,meters:x,metres:x,miles:x/1609.344,millimeters:1e3*x,millimetres:1e3*x,nauticalmiles:x/1852,radians:1,yards:1.0936*x},k={acres:247105e-9,centimeters:1e4,centimetres:1e4,feet:10.763910417,hectares:1e-4,inches:1550.003100006,kilometers:1e-6,kilometres:1e-6,meters:1,metres:1,miles:386e-9,nauticalmiles:2.9155334959812285e-7,millimeters:1e6,millimetres:1e6,yards:1.195990046};function b(t,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r={type:"Feature"};return(0===n.id||n.id)&&(r.id=n.id),n.bbox&&(r.bbox=n.bbox),r.properties=e||{},r.geometry=t,r}function w(t,e){switch(t){case"Point":return I(e).geometry;case"LineString":return L(e).geometry;case"Polygon":return S(e).geometry;case"MultiPoint":return O(e).geometry;case"MultiLineString":return T(e).geometry;case"MultiPolygon":return R(e).geometry;default:throw new Error(t+" is invalid")}}function I(t,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(!t)throw new Error("coordinates is required");if(!Array.isArray(t))throw new Error("coordinates must be an Array");if(t.length<2)throw new Error("coordinates must be at least 2 numbers long");if(!U(t[0])||!U(t[1]))throw new Error("coordinates must contain numbers");return b({type:"Point",coordinates:t},e,n)}function N(t,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return C(t.map((function(t){return I(t,e)})),n)}function S(t,e){var n,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},i=a(t);try{for(i.s();!(n=i.n()).done;){var o=n.value;if(o.length<4)throw new Error("Each LinearRing of a Polygon must have 4 or more Positions.");if(o[o.length-1].length!==o[0].length)throw new Error("First and last Position are not equivalent.");for(var s=0;s2&&void 0!==arguments[2]?arguments[2]:{};return C(t.map((function(t){return S(t,e)})),n)}function L(t,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(t.length<2)throw new Error("coordinates must be an array of two or more positions");return b({type:"LineString",coordinates:t},e,n)}function P(t,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return C(t.map((function(t){return L(t,e)})),n)}function C(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n={type:"FeatureCollection"};return e.id&&(n.id=e.id),e.bbox&&(n.bbox=e.bbox),n.features=t,n}function T(t,e){return b({type:"MultiLineString",coordinates:t},e,arguments.length>2&&void 0!==arguments[2]?arguments[2]:{})}function O(t,e){return b({type:"MultiPoint",coordinates:t},e,arguments.length>2&&void 0!==arguments[2]?arguments[2]:{})}function R(t,e){return b({type:"MultiPolygon",coordinates:t},e,arguments.length>2&&void 0!==arguments[2]?arguments[2]:{})}function A(t,e){return b({type:"GeometryCollection",geometries:t},e,arguments.length>2&&void 0!==arguments[2]?arguments[2]:{})}function D(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;if(e&&!(e>=0))throw new Error("precision must be a positive number");var n=Math.pow(10,e||0);return Math.round(t*n)/n}function F(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"kilometers",n=E[e];if(!n)throw new Error(e+" units is invalid");return t*n}function q(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"kilometers",n=E[e];if(!n)throw new Error(e+" units is invalid");return t/n}function V(t,e){return Y(q(t,e))}function G(t){var e=t%360;return e<0&&(e+=360),e}function B(t){return(t%=360)>180?t-360:t<-180?t+360:t}function Y(t){return 180*(t%(2*Math.PI))/Math.PI}function z(t){return t%360*Math.PI/180}function j(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"kilometers",n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"kilometers";if(!(t>=0))throw new Error("length must be a positive number");return F(q(t,e),n)}function X(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"meters",n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"kilometers";if(!(t>=0))throw new Error("area must be a positive number");var r=k[e];if(!r)throw new Error("invalid original units");var i=k[n];if(!i)throw new Error("invalid final units");return t/r*i}function U(t){return!isNaN(t)&&null!==t&&!Array.isArray(t)}function Z(t){return null!==t&&"object"===m(t)&&!Array.isArray(t)}function H(t){if(!t)throw new Error("bbox is required");if(!Array.isArray(t))throw new Error("bbox must be an Array");if(4!==t.length&&6!==t.length)throw new Error("bbox must be an Array of 4 or 6 numbers");t.forEach((function(t){if(!U(t))throw new Error("bbox must only contain numbers")}))}function W(t){if(!t)throw new Error("id is required");if(-1===["string","number"].indexOf(m(t)))throw new Error("id must be a number or a string")}var J=Object.freeze({__proto__:null,areaFactors:k,azimuthToBearing:B,bearingToAzimuth:G,convertArea:X,convertLength:j,degreesToRadians:z,earthRadius:x,factors:E,feature:b,featureCollection:C,geometry:w,geometryCollection:A,isNumber:U,isObject:Z,lengthToDegrees:V,lengthToRadians:q,lineString:L,lineStrings:P,multiLineString:T,multiPoint:O,multiPolygon:R,point:I,points:N,polygon:S,polygons:M,radiansToDegrees:Y,radiansToLength:F,round:D,validateBBox:H,validateId:W});function K(t){if(!t)throw new Error("coord is required");if(!Array.isArray(t)){if("Feature"===t.type&&null!==t.geometry&&"Point"===t.geometry.type)return d(t.geometry.coordinates);if("Point"===t.type)return d(t.coordinates)}if(Array.isArray(t)&&t.length>=2&&!Array.isArray(t[0])&&!Array.isArray(t[1]))return d(t);throw new Error("coord must be GeoJSON Point or an Array of numbers")}function Q(t){if(Array.isArray(t))return t;if("Feature"===t.type){if(null!==t.geometry)return t.geometry.coordinates}else if(t.coordinates)return t.coordinates;throw new Error("coords must be GeoJSON Feature, Geometry Object or an Array")}function $(t){if(t.length>1&&U(t[0])&&U(t[1]))return!0;if(Array.isArray(t[0])&&t[0].length)return $(t[0]);throw new Error("coordinates must only contain numbers")}function tt(t,e,n){if(!e||!n)throw new Error("type and name required");if(!t||t.type!==e)throw new Error("Invalid input to "+n+": must be a "+e+", given "+t.type)}function et(t,e,n){if(!t)throw new Error("No feature passed");if(!n)throw new Error(".featureOf() requires a name");if(!t||"Feature"!==t.type||!t.geometry)throw new Error("Invalid input to "+n+", Feature with geometry required");if(!t.geometry||t.geometry.type!==e)throw new Error("Invalid input to "+n+": must be a "+e+", given "+t.geometry.type)}function nt(t,e,n){if(!t)throw new Error("No featureCollection passed");if(!n)throw new Error(".collectionOf() requires a name");if(!t||"FeatureCollection"!==t.type)throw new Error("Invalid input to "+n+", FeatureCollection required");var r,i=a(t.features);try{for(i.s();!(r=i.n()).done;){var o=r.value;if(!o||"Feature"!==o.type||!o.geometry)throw new Error("Invalid input to "+n+", Feature with geometry required");if(!o.geometry||o.geometry.type!==e)throw new Error("Invalid input to "+n+": must be a "+e+", given "+o.geometry.type)}}catch(t){i.e(t)}finally{i.f()}}function rt(t){return"Feature"===t.type?t.geometry:t}function it(t,e){return"FeatureCollection"===t.type?"FeatureCollection":"GeometryCollection"===t.type?"GeometryCollection":"Feature"===t.type&&null!==t.geometry?t.geometry.type:t.type}var ot=Object.freeze({__proto__:null,collectionOf:nt,containsNumber:$,featureOf:et,geojsonType:tt,getCoord:K,getCoords:Q,getGeom:rt,getType:it});function st(t,e){if(!0===(arguments.length>2&&void 0!==arguments[2]?arguments[2]:{}).final)return function(t,e){var n=st(e,t);return n=(n+180)%360}(t,e);var n=K(t),r=K(e),i=z(n[0]),o=z(r[0]),s=z(n[1]),a=z(r[1]),u=Math.sin(o-i)*Math.cos(a),l=Math.cos(s)*Math.sin(a)-Math.sin(s)*Math.cos(a)*Math.cos(o-i);return Y(Math.atan2(u,l))}function at(t,e,n){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},i=K(t),o=z(i[0]),s=z(i[1]),a=z(n),u=q(e,r.units),l=Math.asin(Math.sin(s)*Math.cos(u)+Math.cos(s)*Math.sin(u)*Math.cos(a));return I([Y(o+Math.atan2(Math.sin(a)*Math.sin(u)*Math.cos(s),Math.cos(u)-Math.sin(s)*Math.sin(l))),Y(l)],r.properties)}function ut(t,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=K(t),i=K(e),o=z(i[1]-r[1]),s=z(i[0]-r[0]),a=z(r[1]),u=z(i[1]),l=Math.pow(Math.sin(o/2),2)+Math.pow(Math.sin(s/2),2)*Math.cos(a)*Math.cos(u);return F(2*Math.atan2(Math.sqrt(l),Math.sqrt(1-l)),n.units)}function lt(t,e){var n;return(n=(arguments.length>2&&void 0!==arguments[2]?arguments[2]:{}).final?ht(K(e),K(t)):ht(K(t),K(e)))>180?-(360-n):n}function ht(t,e){var n=z(t[1]),r=z(e[1]),i=z(e[0]-t[0]);i>Math.PI&&(i-=2*Math.PI),i<-Math.PI&&(i+=2*Math.PI);var o=Math.log(Math.tan(r/2+Math.PI/4)/Math.tan(n/2+Math.PI/4));return(Y(Math.atan2(i,o))+360)%360}function ct(t,e,n){if(null!==t)for(var r,i,o,s,a,u,l,h,c=0,f=0,g=t.type,p="FeatureCollection"===g,v="Feature"===g,d=p?t.features.length:1,y=0;ya||f>u||g>l)return s=o,a=n,u=f,l=g,void(i=0);var p=L([s,o],t.properties);if(!1===e(p,n,r,g,i))return!1;i++,s=o}))&&void 0}}}))}function bt(t,e,n){var r=n,i=!1;return kt(t,(function(t,o,s,a,u){r=!1===i&&void 0===n?t:e(r,t,o,s,a,u),i=!0})),r}function wt(t,e){if(!t)throw new Error("geojson is required");xt(t,(function(t,n,r){if(null!==t.geometry){var i=t.geometry.type,o=t.geometry.coordinates;switch(i){case"LineString":if(!1===e(t,n,r,0,0))return!1;break;case"Polygon":for(var s=0;s0){e+=Math.abs(Ot(t[0]));for(var n=1;n=e?(r+2)%e:r+2],a=i[0]*Tt,u=o[1]*Tt;n+=(s[0]*Tt-a)*Math.sin(u),r++}return n*Ct}function Rt(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(null!=t.bbox&&!0!==e.recompute)return t.bbox;var n=[1/0,1/0,-1/0,-1/0];return ct(t,(function(t){n[0]>t[0]&&(n[0]=t[0]),n[1]>t[1]&&(n[1]=t[1]),n[2]e[2]&&(n|=2),t[1]e[3]&&(n|=8),n}function qt(t,e){var n,r=[],i=a(t);try{for(i.s();!(n=i.n()).done;){var o=At(n.value,e);o.length>0&&(o[0][0]===o[o.length-1][0]&&o[0][1]===o[o.length-1][1]||o.push(o[0]),o.length>=4&&r.push(o))}}catch(t){i.e(t)}finally{i.f()}return r}function Vt(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=Number(t[0]),r=Number(t[1]),i=Number(t[2]),o=Number(t[3]);if(6===t.length)throw new Error("@turf/bbox-polygon does not support BBox with 6 positions");var s=[n,r];return S([[s,[i,r],[i,o],[n,o],s]],e.properties,{bbox:t,id:e.id})}var Gt=function(){return s((function t(e){i(this,t),this.points=e.points||[],this.duration=e.duration||1e4,this.sharpness=e.sharpness||.85,this.centers=[],this.controls=[],this.stepLength=e.stepLength||60,this.length=this.points.length,this.delay=0;for(var n=0;nt&&(e.push(r),n=i)}return e}},{key:"vector",value:function(t){var e=this.pos(t+10),n=this.pos(t-10);return{angle:180*Math.atan2(e.y-n.y,e.x-n.x)/3.14,speed:Math.sqrt((n.x-e.x)*(n.x-e.x)+(n.y-e.y)*(n.y-e.y)+(n.z-e.z)*(n.z-e.z))}}},{key:"pos",value:function(t){var e=t-this.delay;e<0&&(e=0),e>this.duration&&(e=this.duration-1);var n=e/this.duration;if(n>=1)return this.points[this.length-1];var r=Math.floor((this.points.length-1)*n);return function(t,e,n,r,i){var o=function(t){var e=t*t,n=e*t;return[n,3*e*(1-t),3*t*(1-t)*(1-t),(1-t)*(1-t)*(1-t)]}(t),s={x:i.x*o[0]+r.x*o[1]+n.x*o[2]+e.x*o[3],y:i.y*o[0]+r.y*o[1]+n.y*o[2]+e.y*o[3],z:i.z*o[0]+r.z*o[1]+n.z*o[2]+e.z*o[3]};return s}((this.length-1)*n-r,this.points[r],this.controls[r][1],this.controls[r+1][0],this.points[r+1])}}])}();function Bt(t){for(var e,n,r=Q(t),i=0,o=1;o0}function Yt(t,e){for(var n=0,r=0,i=0,o=0,s=0,a=0,u=0,l=0,h=null,c=null,f=t[0],g=t[1],p=e.length;n0&&l>0)a=l,s=(h=c)[0]-f;else{if(u=c[0]-t[0],l>0&&a<=0){if((o=s*l-u*a)>0)i+=1;else if(0===o)return 0}else if(a>0&&l<=0){if((o=s*l-u*a)<0)i+=1;else if(0===o)return 0}else if(0===l&&a<0){if(0===(o=s*l-u*a))return 0}else if(0===a&&l<0){if(0===(o=s*l-u*a))return 0}else if(0===a&&0===l){if(u<=0&&s>=0)return 0;if(s<=0&&u>=0)return 0}h=c,a=l,s=u}}return i%2!=0}function zt(t,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(!t)throw new Error("point is required");if(!e)throw new Error("polygon is required");var r=K(t),i=rt(e),o=i.type,s=e.bbox,a=i.coordinates;if(s&&!1===function(t,e){return e[0]<=t[0]&&e[1]<=t[1]&&e[2]>=t[0]&&e[3]>=t[1]}(r,s))return!1;"Polygon"===o&&(a=[a]);for(var u=!1,l=0;l2&&void 0!==arguments[2]?arguments[2]:{},r=K(t),i=Q(e),o=0;oi)return!1}else if(0!==g)return!1;return Math.abs(c)===Math.abs(f)&&0===Math.abs(c)?!r&&(n[0]===t[0]&&n[1]===t[1]):r?"start"===r?Math.abs(c)>=Math.abs(f)?c>0?a0?u=Math.abs(f)?c>0?a<=o&&o0?u<=s&&s=Math.abs(f)?c>0?a0?u=Math.abs(f)?c>0?a<=o&&o<=l:l<=o&&o<=a:f>0?u<=s&&s<=h:h<=s&&s<=u}function Ut(t,e){if("Feature"===t.type&&null===t.geometry)return!1;if("Feature"===e.type&&null===e.geometry)return!1;if(!Zt(Rt(t),Rt(e)))return!1;var n,r=a(rt(e).coordinates);try{for(r.s();!(n=r.n()).done;){var i,o=a(n.value);try{for(o.s();!(i=o.n()).done;){if(!zt(i.value,t))return!1}}catch(t){o.e(t)}finally{o.f()}}}catch(t){r.e(t)}finally{r.f()}return!0}function Zt(t,e){return!(t[0]>e[0])&&(!(t[2]e[1])&&!(t[3]0&&void 0!==arguments[0]?arguments[0]:[],n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Kt;if(i(this,t),this.data=e,this.length=this.data.length,this.compare=n,this.length>0)for(var r=(this.length>>1)-1;r>=0;r--)this._down(r)}),[{key:"push",value:function(t){this.data.push(t),this.length++,this._up(this.length-1)}},{key:"pop",value:function(){if(0!==this.length){var t=this.data[0],e=this.data.pop();return this.length--,this.length>0&&(this.data[0]=e,this._down(0)),t}}},{key:"peek",value:function(){return this.data[0]}},{key:"_up",value:function(t){for(var e=this.data,n=this.compare,r=e[t];t>0;){var i=t-1>>1,o=e[i];if(n(r,o)>=0)break;e[t]=o,t=i}e[t]=r}},{key:"_down",value:function(t){for(var e=this.data,n=this.compare,r=this.length>>1,i=e[t];t=0)break;e[t]=s,t=o}e[t]=i}}])}();function Kt(t,e){return te?1:0}function Qt(t,e){return t.p.x>e.p.x?1:t.p.xe.p.y?1:-1:1}function $t(t,e){return t.rightSweepEvent.p.x>e.rightSweepEvent.p.x?1:t.rightSweepEvent.p.x0?(h.isLeftEndpoint=!0,l.isLeftEndpoint=!1):(l.isLeftEndpoint=!0,h.isLeftEndpoint=!1),e.push(l),e.push(h),s=a,re+=1}}ee+=1}var oe=s((function t(e){i(this,t),this.leftSweepEvent=e,this.rightSweepEvent=e.otherEvent}));function se(t,e){if(null===t||null===e)return!1;if(t.leftSweepEvent.ringId===e.leftSweepEvent.ringId&&(t.rightSweepEvent.isSamePoint(e.leftSweepEvent)||t.rightSweepEvent.isSamePoint(e.leftSweepEvent)||t.rightSweepEvent.isSamePoint(e.rightSweepEvent)||t.leftSweepEvent.isSamePoint(e.leftSweepEvent)||t.leftSweepEvent.isSamePoint(e.rightSweepEvent)))return!1;var n=t.leftSweepEvent.p.x,r=t.leftSweepEvent.p.y,i=t.rightSweepEvent.p.x,o=t.rightSweepEvent.p.y,s=e.leftSweepEvent.p.x,a=e.leftSweepEvent.p.y,u=e.rightSweepEvent.p.x,l=e.rightSweepEvent.p.y,h=(l-a)*(i-n)-(u-s)*(o-r),c=(u-s)*(r-a)-(l-a)*(n-s),f=(i-n)*(r-a)-(o-r)*(n-s);if(0===h)return!1;var g=c/h,p=f/h;return g>=0&&g<=1&&p>=0&&p<=1&&[n+g*(i-n),r+g*(o-r)]}var ae=function(t,e){var n=new Jt([],Qt);return function(t,e){if("FeatureCollection"===t.type)for(var n=t.features,r=0;r2&&void 0!==arguments[2]?arguments[2]:{},r=n.removeDuplicates,i=void 0===r||r,o=n.ignoreSelfIntersections,s=void 0===o||o,a=[];"FeatureCollection"===t.type?a=a.concat(t.features):"Feature"===t.type?a.push(t):"LineString"!==t.type&&"Polygon"!==t.type&&"MultiLineString"!==t.type&&"MultiPolygon"!==t.type||a.push(b(t)),"FeatureCollection"===e.type?a=a.concat(e.features):"Feature"===e.type?a.push(e):"LineString"!==e.type&&"Polygon"!==e.type&&"MultiLineString"!==e.type&&"MultiPolygon"!==e.type||a.push(b(e));var u=ae(C(a),s),l=[];if(i){var h={};u.forEach((function(t){var e=t.join(",");h[e]||(h[e]=!0,l.push(t))}))}else l=u;return C(l.map((function(t){return I(t)})))}function le(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=rt(t);switch(e.properties||"Feature"!==t.type||(e.properties=t.properties),n.type){case"Polygon":return function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=rt(t),r=n.coordinates,i=e.properties?e.properties:"Feature"===t.type?t.properties:{};return he(r,i)}(n,e);case"MultiPolygon":return function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=rt(t),r=n.coordinates,i=e.properties?e.properties:"Feature"===t.type?t.properties:{},o=[];return r.forEach((function(t){o.push(he(t,i))})),C(o)}(n,e);default:throw new Error("invalid poly")}}function he(t,e){return t.length>1?T(t,e):L(t[0],e)}function ce(t,e){var n=rt(t),r=rt(e),i=n.type,o=r.type;switch(i){case"MultiPoint":switch(o){case"LineString":return fe(n,r);case"Polygon":return pe(n,r);default:throw new Error("feature2 "+o+" geometry not supported")}case"LineString":switch(o){case"MultiPoint":return fe(r,n);case"LineString":return function(t,e){if(ue(t,e).features.length>0)for(var n=0;n0}function pe(t,e){for(var n=!1,r=!1,i=t.coordinates.length,o=0;o=Math.abs(a)?s>0?t[0]<=n[0]&&n[0]<=e[0]:e[0]<=n[0]&&n[0]<=t[0]:a>0?t[1]<=n[1]&&n[1]<=e[1]:e[1]<=n[1]&&n[1]<=t[1]:Math.abs(s)>=Math.abs(a)?s>0?t[0]0?t[1]2&&void 0!==arguments[2]?arguments[2]:{ignoreSelfIntersections:!0}).ignoreSelfIntersections,r=void 0===n||n,i=!0;return xt(t,(function(t){xt(e,(function(e){if(!1===i)return!1;i=function(t,e,n){switch(t.type){case"Point":switch(e.type){case"Point":return r=t.coordinates,i=e.coordinates,!(r[0]===i[0]&&r[1]===i[1]);case"LineString":return!ye(e,t);case"Polygon":return!zt(t,e)}break;case"LineString":switch(e.type){case"Point":return!ye(t,e);case"LineString":return!function(t,e,n){var r=ue(t,e,{ignoreSelfIntersections:n});if(r.features.length>0)return!0;return!1}(t,e,n);case"Polygon":return!me(e,t,n)}break;case"Polygon":switch(e.type){case"Point":return!zt(e,t);case"LineString":return!me(t,e,n);case"Polygon":return!function(t,e,n){var r,i=a(t.coordinates[0]);try{for(i.s();!(r=i.n()).done;){if(zt(r.value,e))return!0}}catch(t){i.e(t)}finally{i.f()}var o,s=a(e.coordinates[0]);try{for(s.s();!(o=s.n()).done;){if(zt(o.value,t))return!0}}catch(t){s.e(t)}finally{s.f()}var u=ue(le(t),le(e),{ignoreSelfIntersections:n});if(u.features.length>0)return!0;return!1}(e,t,n)}}var r,i;return!1}(t.geometry,e.geometry,r)}))})),i}function ye(t,e){for(var n=0;n0}function _e(t,e,n){var r=n[0]-t[0],i=n[1]-t[1],o=e[0]-t[0],s=e[1]-t[1];return 0==r*s-i*o&&(Math.abs(o)>=Math.abs(s)?o>0?t[0]<=n[0]&&n[0]<=e[0]:e[0]<=n[0]&&n[0]<=t[0]:s>0?t[1]<=n[1]&&n[1]<=e[1]:e[1]<=n[1]&&n[1]<=t[1])}var xe=Object.defineProperty,Ee=function(t,e){return xe(t,"name",{value:e,configurable:!0})},ke=function(){return s((function t(e){var n,r,o;i(this,t),this.direction=!1,this.compareProperties=!0,this.precision=Math.pow(10,-(null!=(n=null==e?void 0:e.precision)?n:17)),this.direction=null!=(r=null==e?void 0:e.direction)&&r,this.compareProperties=null==(o=null==e?void 0:e.compareProperties)||o}),[{key:"compare",value:function(t,e){var n=this;if(t.type!==e.type)return!1;if(!we(t,e))return!1;switch(t.type){case"Point":return this.compareCoord(t.coordinates,e.coordinates);case"LineString":return this.compareLine(t.coordinates,e.coordinates);case"Polygon":return this.comparePolygon(t,e);case"GeometryCollection":return this.compareGeometryCollection(t,e);case"Feature":return this.compareFeature(t,e);case"FeatureCollection":return this.compareFeatureCollection(t,e);default:if(t.type.startsWith("Multi")){var r=Ie(t),i=Ie(e);return r.every((function(t){return i.some((function(e){return n.compare(t,e)}))}))}}return!1}},{key:"compareCoord",value:function(t,e){var n=this;return t.length===e.length&&t.every((function(t,r){return Math.abs(t-e[r])2&&void 0!==arguments[2]?arguments[2]:0,r=arguments.length>3&&void 0!==arguments[3]&&arguments[3];if(!we(t,e))return!1;var i=t,o=e;if(r&&!this.compareCoord(i[0],o[0])){var s=this.fixStartIndex(o,i);if(!s)return!1;o=s}var a=this.compareCoord(i[n],o[n]);return this.direction||a?this.comparePath(i,o):!!this.compareCoord(i[n],o[o.length-(1+n)])&&this.comparePath(i.slice().reverse(),o)}},{key:"fixStartIndex",value:function(t,e){for(var n,r=-1,i=0;i=0&&(n=[].concat(t.slice(r,t.length),t.slice(1,r+1))),n}},{key:"comparePath",value:function(t,e){var n=this;return t.every((function(t,r){return n.compareCoord(t,e[r])}))}},{key:"comparePolygon",value:function(t,e){var n=this;if(this.compareLine(t.coordinates[0],e.coordinates[0],1,!0)){var r=t.coordinates.slice(1,t.coordinates.length),i=e.coordinates.slice(1,e.coordinates.length);return r.every((function(t){return i.some((function(e){return n.compareLine(t,e,1,!0)}))}))}return!1}},{key:"compareGeometryCollection",value:function(t,e){var n=this;return we(t.geometries,e.geometries)&&this.compareBBox(t,e)&&t.geometries.every((function(t,r){return n.compare(t,e.geometries[r])}))}},{key:"compareFeature",value:function(t,e){return t.id===e.id&&(!this.compareProperties||Se(t.properties,e.properties))&&this.compareBBox(t,e)&&this.compare(t.geometry,e.geometry)}},{key:"compareFeatureCollection",value:function(t,e){var n=this;return we(t.features,e.features)&&this.compareBBox(t,e)&&t.features.every((function(t,r){return n.compare(t,e.features[r])}))}},{key:"compareBBox",value:function(t,e){return Boolean(!t.bbox&&!e.bbox)||!(!t.bbox||!e.bbox)&&this.compareCoord(t.bbox,e.bbox)}}])}();Ee(ke,"GeojsonEquality");var be=ke;function we(t,e){return t.coordinates?t.coordinates.length===e.coordinates.length:t.length===e.length}function Ie(t){return t.coordinates.map((function(e){return{type:t.type.replace("Multi",""),coordinates:e}}))}function Ne(t,e,n){return new be(n).compare(t,e)}function Se(t,e){if(null===t&&null===e)return!0;if(null===t||null===e)return!1;var n=Object.keys(t),r=Object.keys(e);if(n.length!==r.length)return!1;for(var i=0,o=n;i1&&void 0!==arguments[1]?arguments[1]:{},n="object"===m(e)?e.mutate:e;if(!t)throw new Error("geojson is required");var r=it(t),i=[];switch(r){case"LineString":i=Pe(t,r);break;case"MultiLineString":case"Polygon":Q(t).forEach((function(t){i.push(Pe(t,r))}));break;case"MultiPolygon":Q(t).forEach((function(t){var e=[];t.forEach((function(t){e.push(Pe(t,r))})),i.push(e)}));break;case"Point":return t;case"MultiPoint":var o={};Q(t).forEach((function(t){var e=t.join("-");Object.prototype.hasOwnProperty.call(o,e)||(i.push(t),o[e]=!0)}));break;default:throw new Error(r+" geometry not supported")}return t.coordinates?!0===n?(t.coordinates=i,t):{type:r,coordinates:i}:!0===n?(t.geometry.coordinates=i,t):b({type:r,coordinates:i},t.properties,{bbox:t.bbox,id:t.id})}function Pe(t,e){var n=Q(t);if(2===n.length&&!Ce(n[0],n[1]))return n;var r=[],i=n.length-1,o=r.length;r.push(n[0]);for(var s=1;s2&&Te(r[o-3],r[o-1],r[o-2])&&r.splice(r.length-2,1))}if(r.push(n[n.length-1]),o=r.length,("Polygon"===e||"MultiPolygon"===e)&&Ce(n[0],n[n.length-1])&&o<4)throw new Error("invalid polygon");return"LineString"===e&&o<3||Te(r[o-3],r[o-1],r[o-2])&&r.splice(r.length-2,1),r}function Ce(t,e){return t[0]===e[0]&&t[1]===e[1]}function Te(t,e,n){var r=n[0],i=n[1],o=t[0],s=t[1],a=e[0],u=e[1],l=a-o,h=u-s;return 0===(r-o)*h-(i-s)*l&&(Math.abs(l)>=Math.abs(h)?l>0?o<=r&&r<=a:a<=r&&r<=o:h>0?s<=i&&i<=u:u<=i&&i<=s)}function Oe(t,e){var n=(arguments.length>2&&void 0!==arguments[2]?arguments[2]:{}).ignoreSelfIntersections,r=void 0===n||n,i=!1;return xt(t,(function(t){xt(e,(function(e){if(!0===i)return!0;i=!de(t.geometry,e.geometry,{ignoreSelfIntersections:r})}))})),i}function Re(t,e,n,r,i){Ae(t,e,n||0,r||t.length-1,i||Fe)}function Ae(t,e,n,r,i){for(;r>n;){if(r-n>600){var o=r-n+1,s=e-n+1,a=Math.log(o),u=.5*Math.exp(2*a/3),l=.5*Math.sqrt(a*u*(o-u)/o)*(s-o/2<0?-1:1);Ae(t,e,Math.max(n,Math.floor(e-s*u/o+l)),Math.min(r,Math.floor(e+(o-s)*u/o+l)),i)}var h=t[e],c=n,f=r;for(De(t,n,e),i(t[r],h)>0&&De(t,n,r);c0;)f--}0===i(t[n],h)?De(t,n,f):De(t,++f,r),f<=e&&(n=f+1),e<=f&&(r=f-1)}}function De(t,e,n){var r=t[e];t[e]=t[n],t[n]=r}function Fe(t,e){return te?1:0}var qe=function(){return s((function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:9;i(this,t),this._maxEntries=Math.max(4,e),this._minEntries=Math.max(2,Math.ceil(.4*this._maxEntries)),this.clear()}),[{key:"all",value:function(){return this._all(this.data,[])}},{key:"search",value:function(t){var e=this.data,n=[];if(!He(t,e))return n;for(var r=this.toBBox,i=[];e;){for(var o=0;o=0&&i[e].children.length>this._maxEntries;)this._split(i,e),e--;this._adjustParentBBoxes(r,i,e)}},{key:"_split",value:function(t,e){var n=t[e],r=n.children.length,i=this._minEntries;this._chooseSplitAxis(n,i,r);var o=this._chooseSplitIndex(n,i,r),s=We(n.children.splice(o,n.children.length-o));s.height=n.height,s.leaf=n.leaf,Ge(n,this.toBBox),Ge(s,this.toBBox),e?t[e-1].children.push(s):this._splitRoot(n,s)}},{key:"_splitRoot",value:function(t,e){this.data=We([t,e]),this.data.height=t.height+1,this.data.leaf=!1,Ge(this.data,this.toBBox)}},{key:"_chooseSplitIndex",value:function(t,e,n){for(var r,i,o,s,a,u,l,h=1/0,c=1/0,f=e;f<=n-e;f++){var g=Be(t,0,f,this.toBBox),p=Be(t,f,n,this.toBBox),v=(i=g,o=p,s=void 0,a=void 0,u=void 0,l=void 0,s=Math.max(i.minX,o.minX),a=Math.max(i.minY,o.minY),u=Math.min(i.maxX,o.maxX),l=Math.min(i.maxY,o.maxY),Math.max(0,u-s)*Math.max(0,l-a)),d=Xe(g)+Xe(p);v=e;h--){var c=t.children[h];Ye(s,t.leaf?i(c):c),a+=Ue(s)}return a}},{key:"_adjustParentBBoxes",value:function(t,e,n){for(var r=n;r>=0;r--)Ye(e[r],t)}},{key:"_condense",value:function(t){for(var e,n=t.length-1;n>=0;n--)0===t[n].children.length?n>0?(e=t[n-1].children).splice(e.indexOf(t[n]),1):this.clear():Ge(t[n],this.toBBox)}}])}();function Ve(t,e,n){if(!n)return e.indexOf(t);for(var r=0;r=t.minX&&e.maxY>=t.minY}function We(t){return{children:t,height:1,leaf:!0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}}function Je(t,e,n,r,i){for(var o=[e,n];o.length;)if(!((n=o.pop())-(e=o.pop())<=r)){var s=e+Math.ceil((n-e)/r/2)*r;Re(t,s,e,n,i),o.push(e,s,s,n)}}var Ke=Object.freeze({__proto__:null,default:qe});function Qe(t){var e=new qe(t);return e.insert=function(t){if("Feature"!==t.type)throw new Error("invalid feature");return t.bbox=t.bbox?t.bbox:Rt(t),qe.prototype.insert.call(this,t)},e.load=function(t){var e=[];return Array.isArray(t)?t.forEach((function(t){if("Feature"!==t.type)throw new Error("invalid features");t.bbox=t.bbox?t.bbox:Rt(t),e.push(t)})):vt(t,(function(t){if("Feature"!==t.type)throw new Error("invalid features");t.bbox=t.bbox?t.bbox:Rt(t),e.push(t)})),qe.prototype.load.call(this,e)},e.remove=function(t,e){if("Feature"!==t.type)throw new Error("invalid feature");return t.bbox=t.bbox?t.bbox:Rt(t),qe.prototype.remove.call(this,t,e)},e.clear=function(){return qe.prototype.clear.call(this)},e.search=function(t){return C(qe.prototype.search.call(this,this.toBBox(t)))},e.collides=function(t){return qe.prototype.collides.call(this,this.toBBox(t))},e.all=function(){return C(qe.prototype.all.call(this))},e.toJSON=function(){return qe.prototype.toJSON.call(this)},e.fromJSON=function(t){return qe.prototype.fromJSON.call(this,t)},e.toBBox=function(t){var e;if(t.bbox)e=t.bbox;else if(Array.isArray(t)&&4===t.length)e=t;else if(Array.isArray(t)&&6===t.length)e=[t[0],t[1],t[3],t[4]];else if("Feature"===t.type)e=Rt(t);else{if("FeatureCollection"!==t.type)throw new Error("invalid geojson");e=Rt(t)}return{minX:e[0],minY:e[1],maxX:e[2],maxY:e[3]}},e}function $e(t){if(!t)throw new Error("geojson is required");var e=[];return xt(t,(function(t){!function(t,e){var n=[],r=t.geometry;if(null!==r){switch(r.type){case"Polygon":n=Q(r);break;case"LineString":n=[Q(r)]}n.forEach((function(n){var r=function(t,e){var n=[];return t.reduce((function(t,r){var i=L([t,r],e);return i.bbox=function(t,e){var n=t[0],r=t[1],i=e[0],o=e[1],s=ni?n:i,l=r>o?r:o;return[s,a,u,l]}(t,r),n.push(i),r})),n}(n,t.properties);r.forEach((function(t){t.id=e.length,e.push(t)}))}))}}(t,e)})),C(e)}var tn,en,nn=Object.defineProperty,rn=Object.defineProperties,on=Object.getOwnPropertyDescriptors,sn=Object.getOwnPropertySymbols,an=Object.prototype.hasOwnProperty,un=Object.prototype.propertyIsEnumerable,ln=function(t,e,n){return e in t?nn(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n},hn=function(t,e){for(var n in e||(e={}))an.call(e,n)&&ln(t,n,e[n]);if(sn){var r,i=a(sn(e));try{for(i.s();!(r=i.n()).done;){n=r.value;un.call(e,n)&&ln(t,n,e[n])}}catch(t){i.e(t)}finally{i.f()}}return t},cn=function(t,e){return rn(t,on(e))};function fn(t,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(!t||!e)throw new Error("lines and pt are required arguments");var r=K(e),i=I([1/0,1/0],{dist:1/0,index:-1,multiFeatureIndex:-1,location:-1}),o=0;return xt(t,(function(t,s,a){for(var u=Q(t),l=0;lR||pn(p,f)>R?ut(dn(f),dn(g))<=ut(dn(f),dn(p))?[dn(g),!0,!1]:[dn(p),!1,!0]:[dn(f),!1,!1]}function mn(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function _n(t){if(t.__esModule)return t;var e=t.default;if("function"==typeof e){var n=function t(){return this instanceof t?Reflect.construct(e,arguments,this.constructor):e.apply(this,arguments)};n.prototype=e.prototype}else n={};return Object.defineProperty(n,"__esModule",{value:!0}),Object.keys(t).forEach((function(e){var r=Object.getOwnPropertyDescriptor(t,e);Object.defineProperty(n,e,r.get?r:{enumerable:!0,get:function(){return t[e]}})})),n}var xn=(en||(en=1,tn=function t(e,n){if(e===n)return!0;if(e&&n&&"object"==m(e)&&"object"==m(n)){if(e.constructor!==n.constructor)return!1;var r,i,o;if(Array.isArray(e)){if((r=e.length)!=n.length)return!1;for(i=r;0!=i--;)if(!t(e[i],n[i]))return!1;return!0}if(e.constructor===RegExp)return e.source===n.source&&e.flags===n.flags;if(e.valueOf!==Object.prototype.valueOf)return e.valueOf()===n.valueOf();if(e.toString!==Object.prototype.toString)return e.toString()===n.toString();if((r=(o=Object.keys(e)).length)!==Object.keys(n).length)return!1;for(i=r;0!=i--;)if(!Object.prototype.hasOwnProperty.call(n,o[i]))return!1;for(i=r;0!=i--;){var s=o[i];if(!t(e[s],n[s]))return!1}return!0}return e!=e&&n!=n}),tn),En=mn(xn);function kn(t,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(!Z(n=n||{}))throw new Error("options is invalid");var r,i=n.tolerance||0,o=[],s=Qe(),a=$e(t);s.load(a);var u=[];return kt(e,(function(t){var e=!1;t&&(vt(s.search(t),(function(n){if(!1===e){var o=Q(t).sort(),s=Q(n).sort();if(En(o,s))e=!0,r=r?bn(r,t)||r:t;else if(0===i?jt(o[0],n)&&jt(o[1],n):fn(n,o[0]).properties.dist<=i&&fn(n,o[1]).properties.dist<=i)e=!0,r=r?bn(r,t)||r:t;else if(0===i?jt(s[0],t)&&jt(s[1],t):fn(t,s[0]).properties.dist<=i&&fn(t,s[1]).properties.dist<=i)if(r){var a=bn(r,n);a?r=a:u.push(n)}else r=n}})),!1===e&&r&&(o.push(r),u.length&&(o=o.concat(u),u=[]),r=void 0))})),r&&o.push(r),C(o)}function bn(t,e){var n=Q(e),r=Q(t),i=r[0],o=r[r.length-1],s=t.geometry.coordinates;if(En(n[0],i))s.unshift(n[1]);else if(En(n[0],o))s.push(n[1]);else if(En(n[1],i))s.unshift(n[0]);else{if(!En(n[1],o))return;s.push(n[0])}return t}function wn(t,e){var n=G(lt(t[0],t[1])),r=G(lt(e[0],e[1]));return n===r||(r-n)%180==0}function In(t,e){if(t.geometry&&t.geometry.type)return t.geometry.type;if(t.type)return t.type;throw new Error("Invalid GeoJSON object for "+e)}function Nn(t,e){return!!Sn(e.coordinates[0],t.coordinates)||!!Sn(e.coordinates[e.coordinates.length-1],t.coordinates)}function Sn(t,e){return t[0]===e[0]&&t[1]===e[1]}function Mn(t){return t[0][0]===t[t.length-1][0]&&t[0][1]===t[t.length-1][1]}function Ln(t){for(var e=0;ee[0])&&(!(t[2]e[1])&&!(t[3]1&&void 0!==arguments[1]?arguments[1]:{},n=Rt(t);return I([(n[0]+n[2])/2,(n[1]+n[3])/2],e.properties,e)}var Dn,Fn={exports:{}};var qn=(Dn||(Dn=1,function(t,e){t.exports=function(){function t(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function e(t,e){for(var n=0;nt.length)&&(e=t.length);for(var n=0,r=new Array(e);n=t.length?{done:!0}:{done:!1,value:t[r++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,s=!0,a=!1;return{s:function(){n=n.call(t)},n:function(){var t=n.next();return s=t.done,t},e:function(t){a=!0,o=t},f:function(){try{s||null==n.return||n.return()}finally{if(a)throw o}}}}var y=function(){function e(){t(this,e),e.constructor_.apply(this,arguments)}return n(e,[{key:"getEndCapStyle",value:function(){return this._endCapStyle}},{key:"isSingleSided",value:function(){return this._isSingleSided}},{key:"setQuadrantSegments",value:function(t){this._quadrantSegments=t,0===this._quadrantSegments&&(this._joinStyle=e.JOIN_BEVEL),this._quadrantSegments<0&&(this._joinStyle=e.JOIN_MITRE,this._mitreLimit=Math.abs(this._quadrantSegments)),t<=0&&(this._quadrantSegments=1),this._joinStyle!==e.JOIN_ROUND&&(this._quadrantSegments=e.DEFAULT_QUADRANT_SEGMENTS)}},{key:"getJoinStyle",value:function(){return this._joinStyle}},{key:"setJoinStyle",value:function(t){this._joinStyle=t}},{key:"setSimplifyFactor",value:function(t){this._simplifyFactor=t<0?0:t}},{key:"getSimplifyFactor",value:function(){return this._simplifyFactor}},{key:"getQuadrantSegments",value:function(){return this._quadrantSegments}},{key:"setEndCapStyle",value:function(t){this._endCapStyle=t}},{key:"getMitreLimit",value:function(){return this._mitreLimit}},{key:"setMitreLimit",value:function(t){this._mitreLimit=t}},{key:"setSingleSided",value:function(t){this._isSingleSided=t}}],[{key:"constructor_",value:function(){if(this._quadrantSegments=e.DEFAULT_QUADRANT_SEGMENTS,this._endCapStyle=e.CAP_ROUND,this._joinStyle=e.JOIN_ROUND,this._mitreLimit=e.DEFAULT_MITRE_LIMIT,this._isSingleSided=!1,this._simplifyFactor=e.DEFAULT_SIMPLIFY_FACTOR,0===arguments.length);else if(1===arguments.length){var t=arguments[0];this.setQuadrantSegments(t)}else if(2===arguments.length){var n=arguments[0],r=arguments[1];this.setQuadrantSegments(n),this.setEndCapStyle(r)}else if(4===arguments.length){var i=arguments[0],o=arguments[1],s=arguments[2],a=arguments[3];this.setQuadrantSegments(i),this.setEndCapStyle(o),this.setJoinStyle(s),this.setMitreLimit(a)}}},{key:"bufferDistanceError",value:function(t){var e=Math.PI/2/t;return 1-Math.cos(e/2)}}]),e}();y.CAP_ROUND=1,y.CAP_FLAT=2,y.CAP_SQUARE=3,y.JOIN_ROUND=1,y.JOIN_MITRE=2,y.JOIN_BEVEL=3,y.DEFAULT_QUADRANT_SEGMENTS=8,y.DEFAULT_MITRE_LIMIT=5,y.DEFAULT_SIMPLIFY_FACTOR=.01;var _=function(e){r(o,e);var i=c(o);function o(e){var n;return t(this,o),(n=i.call(this,e)).name=Object.keys({Exception:o})[0],n}return n(o,[{key:"toString",value:function(){return this.message}}]),o}(u(Error)),x=function(e){r(i,e);var n=c(i);function i(e){var r;return t(this,i),(r=n.call(this,e)).name=Object.keys({IllegalArgumentException:i})[0],r}return i}(_),E=function(){function e(){t(this,e)}return n(e,[{key:"filter",value:function(t){}}]),e}();function k(){}function b(){}function w(){}var I,N,S,M,L,P,C,T,O=function(){function e(){t(this,e)}return n(e,null,[{key:"equalsWithTolerance",value:function(t,e,n){return Math.abs(t-e)<=n}}]),e}(),R=function(){function e(n,r){t(this,e),this.low=r||0,this.high=n||0}return n(e,null,[{key:"toBinaryString",value:function(t){var e,n="";for(e=2147483648;e>0;e>>>=1)n+=(t.high&e)===e?"1":"0";for(e=2147483648;e>0;e>>>=1)n+=(t.low&e)===e?"1":"0";return n}}]),e}();function A(){}function D(){}A.NaN=NaN,A.isNaN=function(t){return Number.isNaN(t)},A.isInfinite=function(t){return!Number.isFinite(t)},A.MAX_VALUE=Number.MAX_VALUE,A.POSITIVE_INFINITY=Number.POSITIVE_INFINITY,A.NEGATIVE_INFINITY=Number.NEGATIVE_INFINITY,"function"==typeof Float64Array&&"function"==typeof Int32Array?(P=2146435072,C=new Float64Array(1),T=new Int32Array(C.buffer),A.doubleToLongBits=function(t){C[0]=t;var e=0|T[0],n=0|T[1];return(n&P)===P&&0!=(1048575&n)&&0!==e&&(e=0,n=2146959360),new R(n,e)},A.longBitsToDouble=function(t){return T[0]=t.low,T[1]=t.high,C[0]}):(I=1023,N=Math.log2,S=Math.floor,M=Math.pow,L=function(){for(var t=53;t>0;t--){var e=M(2,t)-1;if(S(N(e))+1===t)return e}return 0}(),A.doubleToLongBits=function(t){var e,n,r,i,o,s,a,u,l;if(t<0||1/t===Number.NEGATIVE_INFINITY?(s=1<<31,t=-t):s=0,0===t)return new R(u=s,l=0);if(t===1/0)return new R(u=2146435072|s,l=0);if(t!=t)return new R(u=2146959360,l=0);if(i=0,l=0,(e=S(t))>1)if(e<=L)(i=S(N(e)))<=20?(l=0,u=e<<20-i&1048575):(l=e%(n=M(2,r=i-20))<<32-r,u=e/n&1048575);else for(r=e,l=0;0!==(r=S(n=r/2));)i++,l>>>=1,l|=(1&u)<<31,u>>>=1,n!==r&&(u|=524288);if(a=i+I,o=0===e,e=t-e,i<52&&0!==e)for(r=0;;){if((n=2*e)>=1?(e=n-1,o?(a--,o=!1):(r<<=1,r|=1,i++)):(e=n,o?0==--a&&(i++,o=!1):(r<<=1,i++)),20===i)u|=r,r=0;else if(52===i){l|=r;break}if(1===n){i<20?u|=r<<20-i:i<52&&(l|=r<<52-i);break}}return u|=a<<20,new R(u|=s,l)},A.longBitsToDouble=function(t){var e,n,r,i,o=t.high,s=t.low,a=o&1<<31?-1:1;for(r=((2146435072&o)>>20)-I,i=0,n=1<<19,e=1;e<=20;e++)o&n&&(i+=M(2,-e)),n>>>=1;for(n=1<<31,e=21;e<=52;e++)s&n&&(i+=M(2,-e)),n>>>=1;if(-1023===r){if(0===i)return 0*a;r=-1022}else{if(1024===r)return 0===i?a/0:NaN;i+=1}return a*i*M(2,r)});var F=function(e){r(i,e);var n=c(i);function i(e){var r;return t(this,i),(r=n.call(this,e)).name=Object.keys({RuntimeException:i})[0],r}return i}(_),q=function(e){r(o,e);var i=c(o);function o(){var e;return t(this,o),e=i.call(this),o.constructor_.apply(l(e),arguments),e}return n(o,null,[{key:"constructor_",value:function(){if(0===arguments.length)F.constructor_.call(this);else if(1===arguments.length){var t=arguments[0];F.constructor_.call(this,t)}}}]),o}(F),V=function(){function e(){t(this,e)}return n(e,null,[{key:"shouldNeverReachHere",value:function(){if(0===arguments.length)e.shouldNeverReachHere(null);else if(1===arguments.length){var t=arguments[0];throw new q("Should never reach here"+(null!==t?": "+t:""))}}},{key:"isTrue",value:function(){if(1===arguments.length){var t=arguments[0];e.isTrue(t,null)}else if(2===arguments.length){var n=arguments[1];if(!arguments[0])throw null===n?new q:new q(n)}}},{key:"equals",value:function(){if(2===arguments.length){var t=arguments[0],n=arguments[1];e.equals(t,n,null)}else if(3===arguments.length){var r=arguments[0],i=arguments[1],o=arguments[2];if(!i.equals(r))throw new q("Expected "+r+" but encountered "+i+(null!==o?": "+o:""))}}}]),e}(),G=new ArrayBuffer(8),B=new Float64Array(G),Y=new Int32Array(G),z=function(){function e(){t(this,e),e.constructor_.apply(this,arguments)}return n(e,[{key:"getM",value:function(){return A.NaN}},{key:"setOrdinate",value:function(t,n){switch(t){case e.X:this.x=n;break;case e.Y:this.y=n;break;case e.Z:this.setZ(n);break;default:throw new x("Invalid ordinate index: "+t)}}},{key:"equals2D",value:function(){if(1===arguments.length){var t=arguments[0];return this.x===t.x&&this.y===t.y}if(2===arguments.length){var e=arguments[0],n=arguments[1];return!!O.equalsWithTolerance(this.x,e.x,n)&&!!O.equalsWithTolerance(this.y,e.y,n)}}},{key:"setM",value:function(t){throw new x("Invalid ordinate index: "+e.M)}},{key:"getZ",value:function(){return this.z}},{key:"getOrdinate",value:function(t){switch(t){case e.X:return this.x;case e.Y:return this.y;case e.Z:return this.getZ()}throw new x("Invalid ordinate index: "+t)}},{key:"equals3D",value:function(t){return this.x===t.x&&this.y===t.y&&(this.getZ()===t.getZ()||A.isNaN(this.getZ())&&A.isNaN(t.getZ()))}},{key:"equals",value:function(t){return t instanceof e&&this.equals2D(t)}},{key:"equalInZ",value:function(t,e){return O.equalsWithTolerance(this.getZ(),t.getZ(),e)}},{key:"setX",value:function(t){this.x=t}},{key:"compareTo",value:function(t){var e=t;return this.xe.x?1:this.ye.y?1:0}},{key:"getX",value:function(){return this.x}},{key:"setZ",value:function(t){this.z=t}},{key:"clone",value:function(){try{return null}catch(t){if(t instanceof CloneNotSupportedException)return V.shouldNeverReachHere("this shouldn't happen because this class is Cloneable"),null;throw t}}},{key:"copy",value:function(){return new e(this)}},{key:"toString",value:function(){return"("+this.x+", "+this.y+", "+this.getZ()+")"}},{key:"distance3D",value:function(t){var e=this.x-t.x,n=this.y-t.y,r=this.getZ()-t.getZ();return Math.sqrt(e*e+n*n+r*r)}},{key:"getY",value:function(){return this.y}},{key:"setY",value:function(t){this.y=t}},{key:"distance",value:function(t){var e=this.x-t.x,n=this.y-t.y;return Math.sqrt(e*e+n*n)}},{key:"hashCode",value:function(){var t=17;return 37*(t=37*t+e.hashCode(this.x))+e.hashCode(this.y)}},{key:"setCoordinate",value:function(t){this.x=t.x,this.y=t.y,this.z=t.getZ()}},{key:"interfaces_",get:function(){return[k,b,w]}}],[{key:"constructor_",value:function(){if(this.x=null,this.y=null,this.z=null,0===arguments.length)e.constructor_.call(this,0,0);else if(1===arguments.length){var t=arguments[0];e.constructor_.call(this,t.x,t.y,t.getZ())}else if(2===arguments.length){var n=arguments[0],r=arguments[1];e.constructor_.call(this,n,r,e.NULL_ORDINATE)}else if(3===arguments.length){var i=arguments[0],o=arguments[1],s=arguments[2];this.x=i,this.y=o,this.z=s}}},{key:"hashCode",value:function(t){return B[0]=t,Y[0]^Y[1]}}]),e}(),j=function(){function e(){t(this,e),e.constructor_.apply(this,arguments)}return n(e,[{key:"compare",value:function(t,n){var r=e.compare(t.x,n.x);if(0!==r)return r;var i=e.compare(t.y,n.y);return 0!==i?i:this._dimensionsToTest<=2?0:e.compare(t.getZ(),n.getZ())}},{key:"interfaces_",get:function(){return[D]}}],[{key:"constructor_",value:function(){if(this._dimensionsToTest=2,0===arguments.length)e.constructor_.call(this,2);else if(1===arguments.length){var t=arguments[0];if(2!==t&&3!==t)throw new x("only 2 or 3 dimensions may be specified");this._dimensionsToTest=t}}},{key:"compare",value:function(t,e){return te?1:A.isNaN(t)?A.isNaN(e)?0:-1:A.isNaN(e)?1:0}}]),e}();z.DimensionalComparator=j,z.NULL_ORDINATE=A.NaN,z.X=0,z.Y=1,z.Z=2,z.M=3;var X=function(){function e(){t(this,e),e.constructor_.apply(this,arguments)}return n(e,[{key:"getArea",value:function(){return this.getWidth()*this.getHeight()}},{key:"equals",value:function(t){if(!(t instanceof e))return!1;var n=t;return this.isNull()?n.isNull():this._maxx===n.getMaxX()&&this._maxy===n.getMaxY()&&this._minx===n.getMinX()&&this._miny===n.getMinY()}},{key:"intersection",value:function(t){if(this.isNull()||t.isNull()||!this.intersects(t))return new e;var n=this._minx>t._minx?this._minx:t._minx,r=this._miny>t._miny?this._miny:t._miny;return new e(n,this._maxx=this._minx&&n.getMaxX()<=this._maxx&&n.getMinY()>=this._miny&&n.getMaxY()<=this._maxy}}else if(2===arguments.length){var r=arguments[0],i=arguments[1];return!this.isNull()&&r>=this._minx&&r<=this._maxx&&i>=this._miny&&i<=this._maxy}}},{key:"intersects",value:function(){if(1===arguments.length){if(arguments[0]instanceof e){var t=arguments[0];return!this.isNull()&&!t.isNull()&&!(t._minx>this._maxx||t._maxxthis._maxy||t._maxythis._maxx||(r.x>i.x?r.x:i.x)this._maxy||(r.y>i.y?r.y:i.y)this._maxx||othis._maxy||sthis._maxx&&(this._maxx=n._maxx),n._minythis._maxy&&(this._maxy=n._maxy))}}else if(2===arguments.length){var r=arguments[0],i=arguments[1];this.isNull()?(this._minx=r,this._maxx=r,this._miny=i,this._maxy=i):(rthis._maxx&&(this._maxx=r),ithis._maxy&&(this._maxy=i))}}},{key:"minExtent",value:function(){if(this.isNull())return 0;var t=this.getWidth(),e=this.getHeight();return te._minx?1:this._minye._miny?1:this._maxxe._maxx?1:this._maxye._maxy?1:0}},{key:"translate",value:function(t,e){if(this.isNull())return null;this.init(this.getMinX()+t,this.getMaxX()+t,this.getMinY()+e,this.getMaxY()+e)}},{key:"copy",value:function(){return new e(this)}},{key:"toString",value:function(){return"Env["+this._minx+" : "+this._maxx+", "+this._miny+" : "+this._maxy+"]"}},{key:"setToNull",value:function(){this._minx=0,this._maxx=-1,this._miny=0,this._maxy=-1}},{key:"disjoint",value:function(t){return!(!this.isNull()&&!t.isNull())||t._minx>this._maxx||t._maxxthis._maxy||t._maxye?t:e}},{key:"expandBy",value:function(){if(1===arguments.length){var t=arguments[0];this.expandBy(t,t)}else if(2===arguments.length){var e=arguments[0],n=arguments[1];if(this.isNull())return null;this._minx-=e,this._maxx+=e,this._miny-=n,this._maxy+=n,(this._minx>this._maxx||this._miny>this._maxy)&&this.setToNull()}}},{key:"contains",value:function(){if(1===arguments.length){if(arguments[0]instanceof e){var t=arguments[0];return this.covers(t)}if(arguments[0]instanceof z){var n=arguments[0];return this.covers(n)}}else if(2===arguments.length){var r=arguments[0],i=arguments[1];return this.covers(r,i)}}},{key:"centre",value:function(){return this.isNull()?null:new z((this.getMinX()+this.getMaxX())/2,(this.getMinY()+this.getMaxY())/2)}},{key:"init",value:function(){if(0===arguments.length)this.setToNull();else if(1===arguments.length){if(arguments[0]instanceof z){var t=arguments[0];this.init(t.x,t.x,t.y,t.y)}else if(arguments[0]instanceof e){var n=arguments[0];this._minx=n._minx,this._maxx=n._maxx,this._miny=n._miny,this._maxy=n._maxy}}else if(2===arguments.length){var r=arguments[0],i=arguments[1];this.init(r.x,i.x,r.y,i.y)}else if(4===arguments.length){var o=arguments[0],s=arguments[1],a=arguments[2],u=arguments[3];ot._maxx&&(e=this._minx-t._maxx);var n=0;return this._maxyt._maxy&&(n=this._miny-t._maxy),0===e?n:0===n?e:Math.sqrt(e*e+n*n)}},{key:"hashCode",value:function(){var t=17;return 37*(t=37*(t=37*(t=37*t+z.hashCode(this._minx))+z.hashCode(this._maxx))+z.hashCode(this._miny))+z.hashCode(this._maxy)}},{key:"interfaces_",get:function(){return[k,w]}}],[{key:"constructor_",value:function(){if(this._minx=null,this._maxx=null,this._miny=null,this._maxy=null,0===arguments.length)this.init();else if(1===arguments.length){if(arguments[0]instanceof z){var t=arguments[0];this.init(t.x,t.x,t.y,t.y)}else if(arguments[0]instanceof e){var n=arguments[0];this.init(n)}}else if(2===arguments.length){var r=arguments[0],i=arguments[1];this.init(r.x,i.x,r.y,i.y)}else if(4===arguments.length){var o=arguments[0],s=arguments[1],a=arguments[2],u=arguments[3];this.init(o,s,a,u)}}},{key:"intersects",value:function(){if(3===arguments.length){var t=arguments[0],e=arguments[1],n=arguments[2];return n.x>=(t.xe.x?t.x:e.x)&&n.y>=(t.ye.y?t.y:e.y)}if(4===arguments.length){var r=arguments[0],i=arguments[1],o=arguments[2],s=arguments[3],a=Math.min(o.x,s.x),u=Math.max(o.x,s.x),l=Math.min(r.x,i.x),h=Math.max(r.x,i.x);return!(l>u||hu||h=this.size())throw new nt;return this.array[t]}},{key:"push",value:function(t){return this.array.push(t),t}},{key:"pop",value:function(){if(0===this.array.length)throw new et;return this.array.pop()}},{key:"peek",value:function(){if(0===this.array.length)throw new et;return this.array[this.array.length-1]}},{key:"empty",value:function(){return 0===this.array.length}},{key:"isEmpty",value:function(){return this.empty()}},{key:"search",value:function(t){return this.array.indexOf(t)}},{key:"size",value:function(){return this.array.length}},{key:"toArray",value:function(){return this.array.slice()}}]),o}(rt);function ot(t,e){return t.interfaces_&&t.interfaces_.indexOf(e)>-1}var st=function(){function e(n){t(this,e),this.str=n}return n(e,[{key:"append",value:function(t){this.str+=t}},{key:"setCharAt",value:function(t,e){this.str=this.str.substr(0,t)+e+this.str.substr(t+1)}},{key:"toString",value:function(){return this.str}}]),e}(),at=function(){function e(n){t(this,e),this.value=n}return n(e,[{key:"intValue",value:function(){return this.value}},{key:"compareTo",value:function(t){return this.valuet?1:0}}],[{key:"compare",value:function(t,e){return te?1:0}},{key:"isNan",value:function(t){return Number.isNaN(t)}},{key:"valueOf",value:function(t){return new e(t)}}]),e}(),ut=function(){function e(){t(this,e)}return n(e,null,[{key:"isWhitespace",value:function(t){return t<=32&&t>=0||127===t}},{key:"toUpperCase",value:function(t){return t.toUpperCase()}}]),e}(),lt=function(){function e(){t(this,e),e.constructor_.apply(this,arguments)}return n(e,[{key:"le",value:function(t){return this._hi9?(c=!0,f="9"):f="0"+h,a.append(f),r=r.subtract(e.valueOf(h)).multiply(e.TEN),c&&r.selfAdd(e.TEN);var g=!0,p=e.magnitude(r._hi);if(p<0&&Math.abs(p)>=u-l&&(g=!1),!g)break}return n[0]=i,a.toString()}},{key:"sqr",value:function(){return this.multiply(this)}},{key:"doubleValue",value:function(){return this._hi+this._lo}},{key:"subtract",value:function(){if(arguments[0]instanceof e){var t=arguments[0];return this.add(t.negate())}if("number"==typeof arguments[0]){var n=arguments[0];return this.add(-n)}}},{key:"equals",value:function(){if(1===arguments.length&&arguments[0]instanceof e){var t=arguments[0];return this._hi===t._hi&&this._lo===t._lo}}},{key:"isZero",value:function(){return 0===this._hi&&0===this._lo}},{key:"selfSubtract",value:function(){if(arguments[0]instanceof e){var t=arguments[0];return this.isNaN()?this:this.selfAdd(-t._hi,-t._lo)}if("number"==typeof arguments[0]){var n=arguments[0];return this.isNaN()?this:this.selfAdd(-n,0)}}},{key:"getSpecialNumberString",value:function(){return this.isZero()?"0.0":this.isNaN()?"NaN ":null}},{key:"min",value:function(t){return this.le(t)?this:t}},{key:"selfDivide",value:function(){if(1===arguments.length){if(arguments[0]instanceof e){var t=arguments[0];return this.selfDivide(t._hi,t._lo)}if("number"==typeof arguments[0]){var n=arguments[0];return this.selfDivide(n,0)}}else if(2===arguments.length){var r=arguments[0],i=arguments[1],o=null,s=null,a=null,u=null,l=null,h=null,c=null,f=null;return l=this._hi/r,f=(o=(h=e.SPLIT*l)-(o=h-l))*(a=(f=e.SPLIT*r)-(a=f-r))-(c=l*r)+o*(u=r-a)+(s=l-o)*a+s*u,f=l+(h=(this._hi-c-f+this._lo-l*i)/r),this._hi=f,this._lo=l-f+h,this}}},{key:"dump",value:function(){return"DD<"+this._hi+", "+this._lo+">"}},{key:"divide",value:function(){if(arguments[0]instanceof e){var t=arguments[0],n=null,r=null,i=null,o=null,s=null,a=null,u=null,l=null;return r=(s=this._hi/t._hi)-(n=(a=e.SPLIT*s)-(n=a-s)),l=n*(i=(l=e.SPLIT*t._hi)-(i=l-t._hi))-(u=s*t._hi)+n*(o=t._hi-i)+r*i+r*o,new e(l=s+(a=(this._hi-u-l+this._lo-s*t._lo)/t._hi),s-l+a)}if("number"==typeof arguments[0]){var h=arguments[0];return A.isNaN(h)?e.createNaN():e.copy(this).selfDivide(h,0)}}},{key:"ge",value:function(t){return this._hi>t._hi||this._hi===t._hi&&this._lo>=t._lo}},{key:"pow",value:function(t){if(0===t)return e.valueOf(1);var n=new e(this),r=e.valueOf(1),i=Math.abs(t);if(i>1)for(;i>0;)i%2==1&&r.selfMultiply(n),(i/=2)>0&&(n=n.sqr());else r=n;return t<0?r.reciprocal():r}},{key:"ceil",value:function(){if(this.isNaN())return e.NaN;var t=Math.ceil(this._hi),n=0;return t===this._hi&&(n=Math.ceil(this._lo)),new e(t,n)}},{key:"compareTo",value:function(t){var e=t;return this._hie._hi?1:this._loe._lo?1:0}},{key:"rint",value:function(){return this.isNaN()?this:this.add(.5).floor()}},{key:"setValue",value:function(){if(arguments[0]instanceof e){var t=arguments[0];return this.init(t),this}if("number"==typeof arguments[0]){var n=arguments[0];return this.init(n),this}}},{key:"max",value:function(t){return this.ge(t)?this:t}},{key:"sqrt",value:function(){if(this.isZero())return e.valueOf(0);if(this.isNegative())return e.NaN;var t=1/Math.sqrt(this._hi),n=this._hi*t,r=e.valueOf(n),i=this.subtract(r.sqr())._hi*(.5*t);return r.add(i)}},{key:"selfAdd",value:function(){if(1===arguments.length){if(arguments[0]instanceof e){var t=arguments[0];return this.selfAdd(t._hi,t._lo)}if("number"==typeof arguments[0]){var n=arguments[0],r=null,i=null,o=null,s=null,a=null,u=null;return s=(o=this._hi+n)-(a=o-this._hi),i=(u=(s=n-a+(this._hi-s))+this._lo)+(o-(r=o+u)),this._hi=r+i,this._lo=i+(r-this._hi),this}}else if(2===arguments.length){var l=arguments[0],h=arguments[1],c=null,f=null,g=null,p=null,v=null,d=null,y=null;p=this._hi+l,f=this._lo+h,v=p-(d=p-this._hi),g=f-(y=f-this._lo);var m=(c=p+(d=(v=l-d+(this._hi-v))+f))+(d=(g=h-y+(this._lo-g))+(d+(p-c))),_=d+(c-m);return this._hi=m,this._lo=_,this}}},{key:"selfMultiply",value:function(){if(1===arguments.length){if(arguments[0]instanceof e){var t=arguments[0];return this.selfMultiply(t._hi,t._lo)}if("number"==typeof arguments[0]){var n=arguments[0];return this.selfMultiply(n,0)}}else if(2===arguments.length){var r=arguments[0],i=arguments[1],o=null,s=null,a=null,u=null,l=null,h=null;o=(l=e.SPLIT*this._hi)-this._hi,h=e.SPLIT*r,o=l-o,s=this._hi-o,a=h-r;var c=(l=this._hi*r)+(h=o*(a=h-a)-l+o*(u=r-a)+s*a+s*u+(this._hi*i+this._lo*r)),f=h+(o=l-c);return this._hi=c,this._lo=f,this}}},{key:"selfSqr",value:function(){return this.selfMultiply(this)}},{key:"floor",value:function(){if(this.isNaN())return e.NaN;var t=Math.floor(this._hi),n=0;return t===this._hi&&(n=Math.floor(this._lo)),new e(t,n)}},{key:"negate",value:function(){return this.isNaN()?this:new e(-this._hi,-this._lo)}},{key:"clone",value:function(){try{return null}catch(t){if(t instanceof CloneNotSupportedException)return null;throw t}}},{key:"multiply",value:function(){if(arguments[0]instanceof e){var t=arguments[0];return t.isNaN()?e.createNaN():e.copy(this).selfMultiply(t)}if("number"==typeof arguments[0]){var n=arguments[0];return A.isNaN(n)?e.createNaN():e.copy(this).selfMultiply(n,0)}}},{key:"isNaN",value:function(){return A.isNaN(this._hi)}},{key:"intValue",value:function(){return Math.trunc(this._hi)}},{key:"toString",value:function(){var t=e.magnitude(this._hi);return t>=-3&&t<=20?this.toStandardNotation():this.toSciNotation()}},{key:"toStandardNotation",value:function(){var t=this.getSpecialNumberString();if(null!==t)return t;var n=new Array(1).fill(null),r=this.extractSignificantDigits(!0,n),i=n[0]+1,o=r;if("."===r.charAt(0))o="0"+r;else if(i<0)o="0."+e.stringOfChar("0",-i)+r;else if(-1===r.indexOf(".")){var s=i-r.length;o=r+e.stringOfChar("0",s)+".0"}return this.isNegative()?"-"+o:o}},{key:"reciprocal",value:function(){var t,n,r,i,o=null,s=null,a=null,u=null;t=(r=1/this._hi)-(o=(a=e.SPLIT*r)-(o=a-r)),s=(u=e.SPLIT*this._hi)-this._hi;var l=r+(a=(1-(i=r*this._hi)-(u=o*(s=u-s)-i+o*(n=this._hi-s)+t*s+t*n)-r*this._lo)/this._hi);return new e(l,r-l+a)}},{key:"toSciNotation",value:function(){if(this.isZero())return e.SCI_NOT_ZERO;var t=this.getSpecialNumberString();if(null!==t)return t;var n=new Array(1).fill(null),r=this.extractSignificantDigits(!1,n),i=e.SCI_NOT_EXPONENT_CHAR+n[0];if("0"===r.charAt(0))throw new IllegalStateException("Found leading zero: "+r);var o="";r.length>1&&(o=r.substring(1));var s=r.charAt(0)+"."+o;return this.isNegative()?"-"+s+i:s+i}},{key:"abs",value:function(){return this.isNaN()?e.NaN:this.isNegative()?this.negate():new e(this)}},{key:"isPositive",value:function(){return this._hi>0||0===this._hi&&this._lo>0}},{key:"lt",value:function(t){return this._hit._hi||this._hi===t._hi&&this._lo>t._lo}},{key:"isNegative",value:function(){return this._hi<0||0===this._hi&&this._lo<0}},{key:"trunc",value:function(){return this.isNaN()?e.NaN:this.isPositive()?this.floor():this.ceil()}},{key:"signum",value:function(){return this._hi>0?1:this._hi<0?-1:this._lo>0?1:this._lo<0?-1:0}},{key:"interfaces_",get:function(){return[w,k,b]}}],[{key:"constructor_",value:function(){if(this._hi=0,this._lo=0,0===arguments.length)this.init(0);else if(1===arguments.length){if("number"==typeof arguments[0]){var t=arguments[0];this.init(t)}else if(arguments[0]instanceof e){var n=arguments[0];this.init(n)}else if("string"==typeof arguments[0]){var r=arguments[0];e.constructor_.call(this,e.parse(r))}}else if(2===arguments.length){var i=arguments[0],o=arguments[1];this.init(i,o)}}},{key:"determinant",value:function(){if("number"==typeof arguments[3]&&"number"==typeof arguments[2]&&"number"==typeof arguments[0]&&"number"==typeof arguments[1]){var t=arguments[0],n=arguments[1],r=arguments[2],i=arguments[3];return e.determinant(e.valueOf(t),e.valueOf(n),e.valueOf(r),e.valueOf(i))}if(arguments[3]instanceof e&&arguments[2]instanceof e&&arguments[0]instanceof e&&arguments[1]instanceof e){var o=arguments[1],s=arguments[2],a=arguments[3];return arguments[0].multiply(a).selfSubtract(o.multiply(s))}}},{key:"sqr",value:function(t){return e.valueOf(t).selfMultiply(t)}},{key:"valueOf",value:function(){if("string"==typeof arguments[0]){var t=arguments[0];return e.parse(t)}if("number"==typeof arguments[0])return new e(arguments[0])}},{key:"sqrt",value:function(t){return e.valueOf(t).sqrt()}},{key:"parse",value:function(t){for(var n=0,r=t.length;ut.isWhitespace(t.charAt(n));)n++;var i=!1;if(n=r);){var c=t.charAt(n);if(n++,ut.isDigit(c)){var f=c-"0";s.selfMultiply(e.TEN),s.selfAdd(f),a++}else{if("."!==c){if("e"===c||"E"===c){var g=t.substring(n);try{l=at.parseInt(g)}catch(e){throw e instanceof NumberFormatException?new NumberFormatException("Invalid exponent "+g+" in string "+t):e}break}throw new NumberFormatException("Unexpected character '"+c+"' at position "+n+" in string "+t)}u=a,h=!0}}var p=s;h||(u=a);var v=a-u-l;if(0===v)p=s;else if(v>0){var d=e.TEN.pow(v);p=s.divide(d)}else if(v<0){var y=e.TEN.pow(-v);p=s.multiply(y)}return i?p.negate():p}},{key:"createNaN",value:function(){return new e(A.NaN,A.NaN)}},{key:"copy",value:function(t){return new e(t)}},{key:"magnitude",value:function(t){var e=Math.abs(t),n=Math.log(e)/Math.log(10),r=Math.trunc(Math.floor(n));return 10*Math.pow(10,r)<=e&&(r+=1),r}},{key:"stringOfChar",value:function(t,e){for(var n=new st,r=0;r0){if(s<=0)return e.signum(a);i=o+s}else{if(!(o<0))return e.signum(a);if(s>=0)return e.signum(a);i=-o-s}var u=e.DP_SAFE_EPSILON*i;return a>=u||-a>=u?e.signum(a):2}},{key:"signum",value:function(t){return t>0?1:t<0?-1:0}}]),e}();ht.DP_SAFE_EPSILON=1e-15;var ct=function(){function e(){t(this,e)}return n(e,[{key:"getM",value:function(t){if(this.hasM()){var e=this.getDimension()-this.getMeasures();return this.getOrdinate(t,e)}return A.NaN}},{key:"setOrdinate",value:function(t,e,n){}},{key:"getZ",value:function(t){return this.hasZ()?this.getOrdinate(t,2):A.NaN}},{key:"size",value:function(){}},{key:"getOrdinate",value:function(t,e){}},{key:"getCoordinate",value:function(){}},{key:"getCoordinateCopy",value:function(t){}},{key:"createCoordinate",value:function(){}},{key:"getDimension",value:function(){}},{key:"hasM",value:function(){return this.getMeasures()>0}},{key:"getX",value:function(t){}},{key:"hasZ",value:function(){return this.getDimension()-this.getMeasures()>2}},{key:"getMeasures",value:function(){return 0}},{key:"expandEnvelope",value:function(t){}},{key:"copy",value:function(){}},{key:"getY",value:function(t){}},{key:"toCoordinateArray",value:function(){}},{key:"interfaces_",get:function(){return[b]}}]),e}();ct.X=0,ct.Y=1,ct.Z=2,ct.M=3;var ft=function(){function e(){t(this,e)}return n(e,null,[{key:"index",value:function(t,e,n){return ht.orientationIndex(t,e,n)}},{key:"isCCW",value:function(){if(arguments[0]instanceof Array){var t=arguments[0],n=t.length-1;if(n<3)throw new x("Ring has fewer than 4 points, so orientation cannot be determined");for(var r=t[0],i=0,o=1;o<=n;o++){var s=t[o];s.y>r.y&&(r=s,i=o)}var a=i;do{(a-=1)<0&&(a=n)}while(t[a].equals2D(r)&&a!==i);var u=i;do{u=(u+1)%n}while(t[u].equals2D(r)&&u!==i);var l=t[a],h=t[u];if(l.equals2D(r)||h.equals2D(r)||l.equals2D(h))return!1;var c=e.index(l,r,h);return 0===c?l.x>h.x:c>0}if(ot(arguments[0],ct)){var f=arguments[0],g=f.size()-1;if(g<3)throw new x("Ring has fewer than 4 points, so orientation cannot be determined");for(var p=f.getCoordinate(0),v=0,d=1;d<=g;d++){var y=f.getCoordinate(d);y.y>p.y&&(p=y,v=d)}var m=null,_=v;do{(_-=1)<0&&(_=g),m=f.getCoordinate(_)}while(m.equals2D(p)&&_!==v);var E=null,k=v;do{k=(k+1)%g,E=f.getCoordinate(k)}while(E.equals2D(p)&&k!==v);if(m.equals2D(p)||E.equals2D(p)||m.equals2D(E))return!1;var b=e.index(m,p,E);return 0===b?m.x>E.x:b>0}}}]),e}();ft.CLOCKWISE=-1,ft.RIGHT=ft.CLOCKWISE,ft.COUNTERCLOCKWISE=1,ft.LEFT=ft.COUNTERCLOCKWISE,ft.COLLINEAR=0,ft.STRAIGHT=ft.COLLINEAR;var gt=function(){function e(){t(this,e),e.constructor_.apply(this,arguments)}return n(e,[{key:"getCoordinate",value:function(){return this._minCoord}},{key:"getRightmostSide",value:function(t,e){var n=this.getRightmostSideOfSegment(t,e);return n<0&&(n=this.getRightmostSideOfSegment(t,e-1)),n<0&&(this._minCoord=null,this.checkForRightmostCoordinate(t)),n}},{key:"findRightmostEdgeAtVertex",value:function(){var t=this._minDe.getEdge().getCoordinates();V.isTrue(this._minIndex>0&&this._minIndexthis._minCoord.y&&n.y>this._minCoord.y&&r===ft.CLOCKWISE)&&(i=!0),i&&(this._minIndex=this._minIndex-1)}},{key:"getRightmostSideOfSegment",value:function(t,e){var n=t.getEdge().getCoordinates();if(e<0||e+1>=n.length)return-1;if(n[e].y===n[e+1].y)return-1;var r=tt.LEFT;return n[e].ythis._minCoord.x)&&(this._minDe=t,this._minIndex=n,this._minCoord=e[n])}},{key:"findRightmostEdgeAtNode",value:function(){var t=this._minDe.getNode().getEdges();this._minDe=t.getRightmostEdge(),this._minDe.isForward()||(this._minDe=this._minDe.getSym(),this._minIndex=this._minDe.getEdge().getCoordinates().length-1)}},{key:"findEdge",value:function(t){for(var e=t.iterator();e.hasNext();){var n=e.next();n.isForward()&&this.checkForRightmostCoordinate(n)}V.isTrue(0!==this._minIndex||this._minCoord.equals(this._minDe.getCoordinate()),"inconsistency in rightmost processing"),0===this._minIndex?this.findRightmostEdgeAtNode():this.findRightmostEdgeAtVertex(),this._orientedDe=this._minDe,this.getRightmostSide(this._minDe,this._minIndex)===tt.LEFT&&(this._orientedDe=this._minDe.getSym())}}],[{key:"constructor_",value:function(){this._minIndex=-1,this._minCoord=null,this._minDe=null,this._orientedDe=null}}]),e}(),pt=function(e){r(o,e);var i=c(o);function o(e,n){var r;return t(this,o),(r=i.call(this,n?e+" [ "+n+" ]":e)).pt=n?new z(n):void 0,r.name=Object.keys({TopologyException:o})[0],r}return n(o,[{key:"getCoordinate",value:function(){return this.pt}}]),o}(F),vt=function(){function e(){t(this,e),this.array=[]}return n(e,[{key:"addLast",value:function(t){this.array.push(t)}},{key:"removeFirst",value:function(){return this.array.shift()}},{key:"isEmpty",value:function(){return 0===this.array.length}}]),e}(),dt=function(e,i){r(s,e);var o=c(s);function s(e){var n;return t(this,s),(n=o.call(this)).array=[],e instanceof H&&n.addAll(e),n}return n(s,[{key:"interfaces_",get:function(){return[rt,H]}},{key:"ensureCapacity",value:function(){}},{key:"add",value:function(t){return 1===arguments.length?this.array.push(t):this.array.splice(arguments[0],0,arguments[1]),!0}},{key:"clear",value:function(){this.array=[]}},{key:"addAll",value:function(t){var e,n=d(t);try{for(n.s();!(e=n.n()).done;){var r=e.value;this.array.push(r)}}catch(t){n.e(t)}finally{n.f()}}},{key:"set",value:function(t,e){var n=this.array[t];return this.array[t]=e,n}},{key:"iterator",value:function(){return new yt(this)}},{key:"get",value:function(t){if(t<0||t>=this.size())throw new nt;return this.array[t]}},{key:"isEmpty",value:function(){return 0===this.array.length}},{key:"sort",value:function(t){t?this.array.sort((function(e,n){return t.compare(e,n)})):this.array.sort()}},{key:"size",value:function(){return this.array.length}},{key:"toArray",value:function(){return this.array.slice()}},{key:"remove",value:function(t){for(var e=0,n=this.array.length;e=1&&e.getDepth(tt.LEFT)<=0&&!e.isInteriorAreaEdge()&&e.setInResult(!0)}}},{key:"computeDepths",value:function(t){var e=new Q,n=new vt,r=t.getNode();for(n.addLast(r),e.add(r),t.setVisited(!0);!n.isEmpty();){var i=n.removeFirst();e.add(i),this.computeNodeDepth(i);for(var o=i.getEdges().iterator();o.hasNext();){var s=o.next().getSym();if(!s.isVisited()){var a=s.getNode();e.contains(a)||(n.addLast(a),e.add(a))}}}}},{key:"compareTo",value:function(t){var e=t;return this._rightMostCoord.xe._rightMostCoord.x?1:0}},{key:"getEnvelope",value:function(){if(null===this._env){for(var t=new X,e=this._dirEdgeList.iterator();e.hasNext();)for(var n=e.next().getEdge().getCoordinates(),r=0;re.x?t.x:e.x,a=t.y>e.y?t.y:e.y,u=n.xr.x?n.x:r.x,c=n.y>r.y?n.y:r.y,f=((i>u?i:u)+(sl?o:l)+(an?n:t}if(Number.isInteger(arguments[2])&&Number.isInteger(arguments[0])&&Number.isInteger(arguments[1])){var r=arguments[0],i=arguments[1],o=arguments[2];return ro?o:r}}},{key:"wrap",value:function(t,e){return t<0?e- -t%e:t%e}},{key:"max",value:function(){if(3===arguments.length){var t=arguments[1],e=arguments[2],n=arguments[0];return t>n&&(n=t),e>n&&(n=e),n}if(4===arguments.length){var r=arguments[1],i=arguments[2],o=arguments[3],s=arguments[0];return r>s&&(s=r),i>s&&(s=i),o>s&&(s=o),s}}},{key:"average",value:function(t,e){return(t+e)/2}}]),e}();Et.LOG_10=Math.log(10);var kt=function(){function e(){t(this,e)}return n(e,null,[{key:"segmentToSegment",value:function(t,n,r,i){if(t.equals(n))return e.pointToSegment(t,r,i);if(r.equals(i))return e.pointToSegment(i,t,n);var o=!1;if(X.intersects(t,n,r,i)){var s=(n.x-t.x)*(i.y-r.y)-(n.y-t.y)*(i.x-r.x);if(0===s)o=!0;else{var a=(t.y-r.y)*(i.x-r.x)-(t.x-r.x)*(i.y-r.y),u=((t.y-r.y)*(n.x-t.x)-(t.x-r.x)*(n.y-t.y))/s,l=a/s;(l<0||l>1||u<0||u>1)&&(o=!0)}}else o=!0;return o?Et.min(e.pointToSegment(t,r,i),e.pointToSegment(n,r,i),e.pointToSegment(r,t,n),e.pointToSegment(i,t,n)):0}},{key:"pointToSegment",value:function(t,e,n){if(e.x===n.x&&e.y===n.y)return t.distance(e);var r=(n.x-e.x)*(n.x-e.x)+(n.y-e.y)*(n.y-e.y),i=((t.x-e.x)*(n.x-e.x)+(t.y-e.y)*(n.y-e.y))/r;if(i<=0)return t.distance(e);if(i>=1)return t.distance(n);var o=((e.y-t.y)*(n.x-e.x)-(e.x-t.x)*(n.y-e.y))/r;return Math.abs(o)*Math.sqrt(r)}},{key:"pointToLinePerpendicular",value:function(t,e,n){var r=(n.x-e.x)*(n.x-e.x)+(n.y-e.y)*(n.y-e.y),i=((e.y-t.y)*(n.x-e.x)-(e.x-t.x)*(n.y-e.y))/r;return Math.abs(i)*Math.sqrt(r)}},{key:"pointToSegmentString",value:function(t,n){if(0===n.length)throw new x("Line array must contain at least one vertex");for(var r=t.distance(n[0]),i=0;i0)&&(o=a,i=s)}return i}}},{key:"extend",value:function(t,n,r){var i=t.create(r,n.getDimension()),o=n.size();if(e.copy(n,0,i,0,o),o>0)for(var s=o;s0)&&(e=r)}return e}}]),e}(),Mt=function(){function e(){t(this,e)}return n(e,null,[{key:"toDimensionSymbol",value:function(t){switch(t){case e.FALSE:return e.SYM_FALSE;case e.TRUE:return e.SYM_TRUE;case e.DONTCARE:return e.SYM_DONTCARE;case e.P:return e.SYM_P;case e.L:return e.SYM_L;case e.A:return e.SYM_A}throw new x("Unknown dimension value: "+t)}},{key:"toDimensionValue",value:function(t){switch(ut.toUpperCase(t)){case e.SYM_FALSE:return e.FALSE;case e.SYM_TRUE:return e.TRUE;case e.SYM_DONTCARE:return e.DONTCARE;case e.SYM_P:return e.P;case e.SYM_L:return e.L;case e.SYM_A:return e.A}throw new x("Unknown dimension symbol: "+t)}}]),e}();Mt.P=0,Mt.L=1,Mt.A=2,Mt.FALSE=-1,Mt.TRUE=-2,Mt.DONTCARE=-3,Mt.SYM_FALSE="F",Mt.SYM_TRUE="T",Mt.SYM_DONTCARE="*",Mt.SYM_P="0",Mt.SYM_L="1",Mt.SYM_A="2";var Lt=function(){function e(){t(this,e)}return n(e,[{key:"filter",value:function(t){}}]),e}(),Pt=function(){function e(){t(this,e)}return n(e,[{key:"filter",value:function(t,e){}},{key:"isDone",value:function(){}},{key:"isGeometryChanged",value:function(){}}]),e}(),Ct=function(e){r(s,e);var o=c(s);function s(){var e;return t(this,s),e=o.call(this),s.constructor_.apply(l(e),arguments),e}return n(s,[{key:"computeEnvelopeInternal",value:function(){return this.isEmpty()?new X:this._points.expandEnvelope(new X)}},{key:"isRing",value:function(){return this.isClosed()&&this.isSimple()}},{key:"getCoordinates",value:function(){return this._points.toCoordinateArray()}},{key:"copyInternal",value:function(){return new s(this._points.copy(),this._factory)}},{key:"equalsExact",value:function(){if(2===arguments.length&&"number"==typeof arguments[1]&&arguments[0]instanceof U){var t=arguments[0],e=arguments[1];if(!this.isEquivalentClass(t))return!1;var n=t;if(this._points.size()!==n._points.size())return!1;for(var r=0;r0){var n=this._points.copy();St.reverse(n),this._points=n}return null}}}},{key:"getCoordinate",value:function(){return this.isEmpty()?null:this._points.getCoordinate(0)}},{key:"getBoundaryDimension",value:function(){return this.isClosed()?Mt.FALSE:0}},{key:"isClosed",value:function(){return!this.isEmpty()&&this.getCoordinateN(0).equals2D(this.getCoordinateN(this.getNumPoints()-1))}},{key:"reverseInternal",value:function(){var t=this._points.copy();return St.reverse(t),this.getFactory().createLineString(t)}},{key:"getEndPoint",value:function(){return this.isEmpty()?null:this.getPointN(this.getNumPoints()-1)}},{key:"getTypeCode",value:function(){return U.TYPECODE_LINESTRING}},{key:"getDimension",value:function(){return 1}},{key:"getLength",value:function(){return It.ofLine(this._points)}},{key:"getNumPoints",value:function(){return this._points.size()}},{key:"compareToSameClass",value:function(){if(1===arguments.length){for(var t=arguments[0],e=0,n=0;e= 2)");this._points=t}},{key:"isCoordinate",value:function(t){for(var e=0;e=1&&this.getCoordinateSequence().size()= 4)")}},{key:"getGeometryType",value:function(){return U.TYPENAME_LINEARRING}}],[{key:"constructor_",value:function(){var t=arguments[0],e=arguments[1];Ct.constructor_.call(this,t,e),this.validateConstruction()}}]),s}(Ct);zt.MINIMUM_VALID_SIZE=4;var jt=function(e){r(o,e);var i=c(o);function o(){var e;return t(this,o),e=i.call(this),o.constructor_.apply(l(e),arguments),e}return n(o,[{key:"setOrdinate",value:function(t,e){switch(t){case o.X:this.x=e;break;case o.Y:this.y=e;break;default:throw new x("Invalid ordinate index: "+t)}}},{key:"getZ",value:function(){return z.NULL_ORDINATE}},{key:"getOrdinate",value:function(t){switch(t){case o.X:return this.x;case o.Y:return this.y}throw new x("Invalid ordinate index: "+t)}},{key:"setZ",value:function(t){throw new x("CoordinateXY dimension 2 does not support z-ordinate")}},{key:"copy",value:function(){return new o(this)}},{key:"toString",value:function(){return"("+this.x+", "+this.y+")"}},{key:"setCoordinate",value:function(t){this.x=t.x,this.y=t.y,this.z=t.getZ()}}],[{key:"constructor_",value:function(){if(0===arguments.length)z.constructor_.call(this);else if(1===arguments.length){if(arguments[0]instanceof o){var t=arguments[0];z.constructor_.call(this,t.x,t.y)}else if(arguments[0]instanceof z){var e=arguments[0];z.constructor_.call(this,e.x,e.y)}}else if(2===arguments.length){var n=arguments[0],r=arguments[1];z.constructor_.call(this,n,r,z.NULL_ORDINATE)}}}]),o}(z);jt.X=0,jt.Y=1,jt.Z=-1,jt.M=-1;var Xt=function(e){r(o,e);var i=c(o);function o(){var e;return t(this,o),e=i.call(this),o.constructor_.apply(l(e),arguments),e}return n(o,[{key:"getM",value:function(){return this._m}},{key:"setOrdinate",value:function(t,e){switch(t){case o.X:this.x=e;break;case o.Y:this.y=e;break;case o.M:this._m=e;break;default:throw new x("Invalid ordinate index: "+t)}}},{key:"setM",value:function(t){this._m=t}},{key:"getZ",value:function(){return z.NULL_ORDINATE}},{key:"getOrdinate",value:function(t){switch(t){case o.X:return this.x;case o.Y:return this.y;case o.M:return this._m}throw new x("Invalid ordinate index: "+t)}},{key:"setZ",value:function(t){throw new x("CoordinateXY dimension 2 does not support z-ordinate")}},{key:"copy",value:function(){return new o(this)}},{key:"toString",value:function(){return"("+this.x+", "+this.y+" m="+this.getM()+")"}},{key:"setCoordinate",value:function(t){this.x=t.x,this.y=t.y,this.z=t.getZ(),this._m=t.getM()}}],[{key:"constructor_",value:function(){if(this._m=null,0===arguments.length)z.constructor_.call(this),this._m=0;else if(1===arguments.length){if(arguments[0]instanceof o){var t=arguments[0];z.constructor_.call(this,t.x,t.y),this._m=t._m}else if(arguments[0]instanceof z){var e=arguments[0];z.constructor_.call(this,e.x,e.y),this._m=this.getM()}}else if(3===arguments.length){var n=arguments[0],r=arguments[1],i=arguments[2];z.constructor_.call(this,n,r,z.NULL_ORDINATE),this._m=i}}}]),o}(z);Xt.X=0,Xt.Y=1,Xt.Z=-1,Xt.M=2;var Ut=function(e){r(o,e);var i=c(o);function o(){var e;return t(this,o),e=i.call(this),o.constructor_.apply(l(e),arguments),e}return n(o,[{key:"getM",value:function(){return this._m}},{key:"setOrdinate",value:function(t,e){switch(t){case z.X:this.x=e;break;case z.Y:this.y=e;break;case z.Z:this.z=e;break;case z.M:this._m=e;break;default:throw new x("Invalid ordinate index: "+t)}}},{key:"setM",value:function(t){this._m=t}},{key:"getOrdinate",value:function(t){switch(t){case z.X:return this.x;case z.Y:return this.y;case z.Z:return this.getZ();case z.M:return this.getM()}throw new x("Invalid ordinate index: "+t)}},{key:"copy",value:function(){return new o(this)}},{key:"toString",value:function(){return"("+this.x+", "+this.y+", "+this.getZ()+" m="+this.getM()+")"}},{key:"setCoordinate",value:function(t){this.x=t.x,this.y=t.y,this.z=t.getZ(),this._m=t.getM()}}],[{key:"constructor_",value:function(){if(this._m=null,0===arguments.length)z.constructor_.call(this),this._m=0;else if(1===arguments.length){if(arguments[0]instanceof o){var t=arguments[0];z.constructor_.call(this,t),this._m=t._m}else if(arguments[0]instanceof z){var e=arguments[0];z.constructor_.call(this,e),this._m=this.getM()}}else if(4===arguments.length){var n=arguments[0],r=arguments[1],i=arguments[2],s=arguments[3];z.constructor_.call(this,n,r,i),this._m=s}}}]),o}(z),Zt=function(){function e(){t(this,e)}return n(e,null,[{key:"measures",value:function(t){return t instanceof jt?0:t instanceof Xt||t instanceof Ut?1:0}},{key:"dimension",value:function(t){return t instanceof jt?2:t instanceof Xt?3:t instanceof Ut?4:3}},{key:"create",value:function(){if(1===arguments.length){var t=arguments[0];return e.create(t,0)}if(2===arguments.length){var n=arguments[0],r=arguments[1];return 2===n?new jt:3===n&&0===r?new z:3===n&&1===r?new Xt:4===n&&1===r?new Ut:new z}}}]),e}(),Ht=function(e){r(s,e);var o=c(s);function s(){var e;return t(this,s),e=o.call(this),s.constructor_.apply(l(e),arguments),e}return n(s,[{key:"getCoordinate",value:function(t){return this.get(t)}},{key:"addAll",value:function(){if(2===arguments.length&&"boolean"==typeof arguments[1]&&ot(arguments[0],H)){for(var t=arguments[1],e=!1,n=arguments[0].iterator();n.hasNext();)this.add(n.next(),t),e=!0;return e}return f(i(s.prototype),"addAll",this).apply(this,arguments)}},{key:"clone",value:function(){for(var t=f(i(s.prototype),"clone",this).call(this),e=0;e=1&&this.get(this.size()-1).equals2D(r))return null;f(i(s.prototype),"add",this).call(this,r)}else if(arguments[0]instanceof Object&&"boolean"==typeof arguments[1]){var o=arguments[0],a=arguments[1];return this.add(o,a),!0}}else if(3===arguments.length){if("boolean"==typeof arguments[2]&&arguments[0]instanceof Array&&"boolean"==typeof arguments[1]){var u=arguments[0],l=arguments[1];if(arguments[2])for(var h=0;h=0;c--)this.add(u[c],l);return!0}if("boolean"==typeof arguments[2]&&Number.isInteger(arguments[0])&&arguments[1]instanceof z){var g=arguments[0],p=arguments[1];if(!arguments[2]){var v=this.size();if(v>0){if(g>0&&this.get(g-1).equals2D(p))return null;if(g_&&(x=-1);for(var E=m;E!==_;E+=x)this.add(d[E],y);return!0}}},{key:"closeRing",value:function(){if(this.size()>0){var t=this.get(0).copy();this.add(t,!1)}}}],[{key:"constructor_",value:function(){if(0===arguments.length);else if(1===arguments.length){var t=arguments[0];this.ensureCapacity(t.length),this.add(t,!0)}else if(2===arguments.length){var e=arguments[0],n=arguments[1];this.ensureCapacity(e.length),this.add(e,n)}}}]),s}(dt);Ht.coordArrayType=new Array(0).fill(null);var Wt=function(){function e(){t(this,e)}return n(e,null,[{key:"isRing",value:function(t){return!(t.length<4||!t[0].equals2D(t[t.length-1]))}},{key:"ptNotInList",value:function(t,n){for(var r=0;r=t?e:[]}},{key:"indexOf",value:function(t,e){for(var n=0;n0)&&(e=t[n]);return e}},{key:"extract",value:function(t,e,n){e=Et.clamp(e,0,t.length);var r=(n=Et.clamp(n,-1,t.length))-e+1;n<0&&(r=0),e>=t.length&&(r=0),nr.length)return 1;if(0===n.length)return 0;var i=Wt.compare(n,r);return Wt.isEqualReversed(n,r)?0:i}},{key:"OLDcompare",value:function(t,e){var n=t,r=e;if(n.lengthr.length)return 1;if(0===n.length)return 0;for(var i=Wt.increasingDirection(n),o=Wt.increasingDirection(r),s=i>0?0:n.length-1,a=o>0?0:n.length-1,u=0;u0){var t=new Qt(17*this._coordinates.length);t.append("("),t.append(this._coordinates[0]);for(var e=1;e3&&(t=3),t<2&&(t=2),new $t(arguments[0],t)}if(3===arguments.length){var e=arguments[2],n=arguments[1]-e;return e>1&&(e=1),n>3&&(n=3),n<2&&(n=2),new $t(arguments[0],n+e,e)}}}},{key:"interfaces_",get:function(){return[bt,w]}}],[{key:"instance",value:function(){return e.instanceObject}}]),e}();te.instanceObject=new te;var ee=function(e){r(s,e);var o=c(s);function s(){var e;return t(this,s),e=o.call(this),s.constructor_.apply(l(e),arguments),e}return n(s,[{key:"copyInternal",value:function(){for(var t=new Array(this._geometries.length).fill(null),e=0;e=0?t:e}}]),e}(),oe=function(){function e(){t(this,e),e.constructor_.apply(this,arguments)}return n(e,[{key:"readResolve",value:function(){return e.nameToTypeMap.get(this._name)}},{key:"toString",value:function(){return this._name}},{key:"interfaces_",get:function(){return[w]}}],[{key:"constructor_",value:function(){this._name=null;var t=arguments[0];this._name=t,e.nameToTypeMap.put(t,this)}}]),e}();oe.nameToTypeMap=new re,ie.Type=oe,ie.FIXED=new oe("FIXED"),ie.FLOATING=new oe("FLOATING"),ie.FLOATING_SINGLE=new oe("FLOATING SINGLE"),ie.maximumPreciseValue=9007199254740992;var se=function(e){r(s,e);var o=c(s);function s(){var e;return t(this,s),e=o.call(this),s.constructor_.apply(l(e),arguments),e}return n(s,[{key:"copyInternal",value:function(){for(var t=new Array(this._geometries.length).fill(null),e=0;e1){if(u instanceof Ft)return this.createMultiPolygon(e.toPolygonArray(t));if(u instanceof Ct)return this.createMultiLineString(e.toLineStringArray(t));if(u instanceof Ot)return this.createMultiPoint(e.toPointArray(t));V.shouldNeverReachHere("Unhandled geometry type: "+u.getGeometryType())}return u}},{key:"createMultiPointFromCoords",value:function(t){return this.createMultiPoint(null!==t?this.getCoordinateSequenceFactory().create(t):null)}},{key:"createPoint",value:function(){if(0===arguments.length)return this.createPoint(this.getCoordinateSequenceFactory().create([]));if(1===arguments.length){if(arguments[0]instanceof z){var t=arguments[0];return this.createPoint(null!==t?this.getCoordinateSequenceFactory().create([t]):null)}if(ot(arguments[0],ct))return new Ot(arguments[0],this)}}},{key:"getCoordinateSequenceFactory",value:function(){return this._coordinateSequenceFactory}},{key:"createPolygon",value:function(){if(0===arguments.length)return this.createPolygon(null,null);if(1===arguments.length){if(ot(arguments[0],ct)){var t=arguments[0];return this.createPolygon(this.createLinearRing(t))}if(arguments[0]instanceof Array){var e=arguments[0];return this.createPolygon(this.createLinearRing(e))}if(arguments[0]instanceof zt){var n=arguments[0];return this.createPolygon(n,null)}}else if(2===arguments.length)return new Ft(arguments[0],arguments[1],this)}},{key:"getSRID",value:function(){return this._SRID}},{key:"createGeometryCollection",value:function(){return 0===arguments.length?new Bt(null,this):1===arguments.length?new Bt(arguments[0],this):void 0}},{key:"getPrecisionModel",value:function(){return this._precisionModel}},{key:"createLinearRing",value:function(){if(0===arguments.length)return this.createLinearRing(this.getCoordinateSequenceFactory().create([]));if(1===arguments.length){if(arguments[0]instanceof Array){var t=arguments[0];return this.createLinearRing(null!==t?this.getCoordinateSequenceFactory().create(t):null)}if(ot(arguments[0],ct))return new zt(arguments[0],this)}}},{key:"createMultiPolygon",value:function(){return 0===arguments.length?new ee(null,this):1===arguments.length?new ee(arguments[0],this):void 0}},{key:"createMultiPoint",value:function(){if(0===arguments.length)return new Yt(null,this);if(1===arguments.length){if(arguments[0]instanceof Array)return new Yt(arguments[0],this);if(ot(arguments[0],ct)){var t=arguments[0];if(null===t)return this.createMultiPoint(new Array(0).fill(null));for(var e=new Array(t.size()).fill(null),n=0;n="a"&&t<="z"||t>="A"&&t<="Z"}},{key:"isNumeric_",value:function(t,e){return t>="0"&&t<="9"||"."==t&&!(void 0!==e&&e)}},{key:"isWhiteSpace_",value:function(t){return" "==t||"\t"==t||"\r"==t||"\n"==t}},{key:"nextChar_",value:function(){return this.wkt.charAt(++this.index_)}},{key:"nextToken",value:function(){var t,e=this.nextChar_(),n=this.index_,r=e;if("("==e)t=ve;else if(","==e)t=me;else if(")"==e)t=de;else if(this.isNumeric_(e)||"-"==e)t=ye,r=this.readNumber_();else if(this.isAlpha_(e))t=pe,r=this.readText_();else{if(this.isWhiteSpace_(e))return this.nextToken();if(""!==e)throw new Error("Unexpected character: "+e);t=_e}return{position:n,value:r,type:t}}},{key:"readNumber_",value:function(){var t,e=this.index_,n=!1,r=!1;do{"."==t?n=!0:"e"!=t&&"E"!=t||(r=!0),t=this.nextChar_()}while(this.isNumeric_(t,n)||!r&&("e"==t||"E"==t)||r&&("-"==t||"+"==t));return parseFloat(this.wkt.substring(e,this.index_--))}},{key:"readText_",value:function(){var t,e=this.index_;do{t=this.nextChar_()}while(this.isAlpha_(t));return this.wkt.substring(e,this.index_--).toUpperCase()}}]),e}(),ke=function(){function e(n,r){t(this,e),this.lexer_=n,this.token_,this.layout_=ue,this.factory=r}return n(e,[{key:"consume_",value:function(){this.token_=this.lexer_.nextToken()}},{key:"isTokenType",value:function(t){return this.token_.type==t}},{key:"match",value:function(t){var e=this.isTokenType(t);return e&&this.consume_(),e}},{key:"parse",value:function(){return this.consume_(),this.parseGeometry_()}},{key:"parseGeometryLayout_",value:function(){var t=ue,e=this.token_;if(this.isTokenType(pe)){var n=e.value;"Z"===n?t=le:"M"===n?t=he:"ZM"===n&&(t=ce),t!==ue&&this.consume_()}return t}},{key:"parseGeometryCollectionText_",value:function(){if(this.match(ve)){var t=[];do{t.push(this.parseGeometry_())}while(this.match(me));if(this.match(de))return t}else if(this.isEmptyGeometry_())return[];throw new Error(this.formatErrorMessage_())}},{key:"parsePointText_",value:function(){if(this.match(ve)){var t=this.parsePoint_();if(this.match(de))return t}else if(this.isEmptyGeometry_())return null;throw new Error(this.formatErrorMessage_())}},{key:"parseLineStringText_",value:function(){if(this.match(ve)){var t=this.parsePointList_();if(this.match(de))return t}else if(this.isEmptyGeometry_())return[];throw new Error(this.formatErrorMessage_())}},{key:"parsePolygonText_",value:function(){if(this.match(ve)){var t=this.parseLineStringTextList_();if(this.match(de))return t}else if(this.isEmptyGeometry_())return[];throw new Error(this.formatErrorMessage_())}},{key:"parseMultiPointText_",value:function(){var t;if(this.match(ve)){if(t=this.token_.type==ve?this.parsePointTextList_():this.parsePointList_(),this.match(de))return t}else if(this.isEmptyGeometry_())return[];throw new Error(this.formatErrorMessage_())}},{key:"parseMultiLineStringText_",value:function(){if(this.match(ve)){var t=this.parseLineStringTextList_();if(this.match(de))return t}else if(this.isEmptyGeometry_())return[];throw new Error(this.formatErrorMessage_())}},{key:"parseMultiPolygonText_",value:function(){if(this.match(ve)){var t=this.parsePolygonTextList_();if(this.match(de))return t}else if(this.isEmptyGeometry_())return[];throw new Error(this.formatErrorMessage_())}},{key:"parsePoint_",value:function(){for(var t=[],e=this.layout_.length,n=0;n1?t.createPolygon(r[0],r.slice(1)):t.createPolygon(r[0])},r=this.token_;if(this.match(pe)){var i=r.value;if(this.layout_=this.parseGeometryLayout_(),"GEOMETRYCOLLECTION"==i){var o=this.parseGeometryCollectionText_();return t.createGeometryCollection(o)}switch(i){case"POINT":var s=this.parsePointText_();return s?t.createPoint(a(z,g(s))):t.createPoint();case"LINESTRING":var u=this.parseLineStringText_().map(e);return t.createLineString(u);case"LINEARRING":var l=this.parseLineStringText_().map(e);return t.createLinearRing(l);case"POLYGON":var h=this.parsePolygonText_();return h&&0!==h.length?n(h):t.createPolygon();case"MULTIPOINT":var c=this.parseMultiPointText_();if(!c||0===c.length)return t.createMultiPoint();var f=c.map(e).map((function(e){return t.createPoint(e)}));return t.createMultiPoint(f);case"MULTILINESTRING":var p=this.parseMultiLineStringText_().map((function(n){return t.createLineString(n.map(e))}));return t.createMultiLineString(p);case"MULTIPOLYGON":var v=this.parseMultiPolygonText_();if(!v||0===v.length)return t.createMultiPolygon();var d=v.map(n);return t.createMultiPolygon(d);default:throw new Error("Invalid geometry type: "+i)}}throw new Error(this.formatErrorMessage_())}}]),e}();function be(t){if(t.isEmpty())return"";var e=t.getCoordinate(),n=[e.x,e.y];return void 0===e.z||Number.isNaN(e.z)||n.push(e.z),void 0===e.m||Number.isNaN(e.m)||n.push(e.m),n.join(" ")}function we(t){for(var e=t.getCoordinates().map((function(t){var e=[t.x,t.y];return void 0===t.z||Number.isNaN(t.z)||e.push(t.z),void 0===t.m||Number.isNaN(t.m)||e.push(t.m),e})),n=[],r=0,i=e.length;r0&&(e+=" "+r),t.isEmpty()?e+" "+ge:e+" ("+n(t)+")"}var Me=function(){function e(n){t(this,e),this.geometryFactory=n||new ae,this.precisionModel=this.geometryFactory.getPrecisionModel()}return n(e,[{key:"read",value:function(t){var e=new Ee(t);return new ke(e,this.geometryFactory).parse()}},{key:"write",value:function(t){return Se(t)}}]),e}(),Le=function(){function e(n){t(this,e),this.parser=new Me(n)}return n(e,[{key:"write",value:function(t){return this.parser.write(t)}}],[{key:"toLineString",value:function(t,e){if(2!==arguments.length)throw new Error("Not implemented");return"LINESTRING ( "+t.x+" "+t.y+", "+e.x+" "+e.y+" )"}}]),e}(),Pe=function(){function e(){t(this,e),e.constructor_.apply(this,arguments)}return n(e,[{key:"getIndexAlongSegment",value:function(t,e){return this.computeIntLineIndex(),this._intLineIndex[t][e]}},{key:"getTopologySummary",value:function(){var t=new Qt;return this.isEndPoint()&&t.append(" endpoint"),this._isProper&&t.append(" proper"),this.isCollinear()&&t.append(" collinear"),t.toString()}},{key:"computeIntersection",value:function(t,e,n,r){this._inputLines[0][0]=t,this._inputLines[0][1]=e,this._inputLines[1][0]=n,this._inputLines[1][1]=r,this._result=this.computeIntersect(t,e,n,r)}},{key:"getIntersectionNum",value:function(){return this._result}},{key:"computeIntLineIndex",value:function(){if(0===arguments.length)null===this._intLineIndex&&(this._intLineIndex=Array(2).fill().map((function(){return Array(2)})),this.computeIntLineIndex(0),this.computeIntLineIndex(1));else if(1===arguments.length){var t=arguments[0];this.getEdgeDistance(t,0)>this.getEdgeDistance(t,1)?(this._intLineIndex[t][0]=0,this._intLineIndex[t][1]=1):(this._intLineIndex[t][0]=1,this._intLineIndex[t][1]=0)}}},{key:"isProper",value:function(){return this.hasIntersection()&&this._isProper}},{key:"setPrecisionModel",value:function(t){this._precisionModel=t}},{key:"isInteriorIntersection",value:function(){if(0===arguments.length)return!!this.isInteriorIntersection(0)||!!this.isInteriorIntersection(1);if(1===arguments.length){for(var t=arguments[0],e=0;ei?r:i;else{var s=Math.abs(t.x-e.x),a=Math.abs(t.y-e.y);0!==(o=r>i?s:a)||t.equals(e)||(o=Math.max(s,a))}return V.isTrue(!(0===o&&!t.equals(e)),"Bad distance calculation"),o}},{key:"nonRobustComputeEdgeDistance",value:function(t,e,n){var r=t.x-e.x,i=t.y-e.y,o=Math.sqrt(r*r+i*i);return V.isTrue(!(0===o&&!t.equals(e)),"Invalid distance calculation"),o}}]),e}();Pe.DONT_INTERSECT=0,Pe.DO_INTERSECT=1,Pe.COLLINEAR=2,Pe.NO_INTERSECTION=0,Pe.POINT_INTERSECTION=1,Pe.COLLINEAR_INTERSECTION=2;var Ce=function(e){r(s,e);var o=c(s);function s(){return t(this,s),o.call(this)}return n(s,[{key:"isInSegmentEnvelopes",value:function(t){var e=new X(this._inputLines[0][0],this._inputLines[0][1]),n=new X(this._inputLines[1][0],this._inputLines[1][1]);return e.contains(t)&&n.contains(t)}},{key:"computeIntersection",value:function(){if(3!==arguments.length)return f(i(s.prototype),"computeIntersection",this).apply(this,arguments);var t=arguments[0],e=arguments[1],n=arguments[2];if(this._isProper=!1,X.intersects(e,n,t)&&0===ft.index(e,n,t)&&0===ft.index(n,e,t))return this._isProper=!0,(t.equals(e)||t.equals(n))&&(this._isProper=!1),this._result=Pe.POINT_INTERSECTION,null;this._result=Pe.NO_INTERSECTION}},{key:"intersection",value:function(t,e,n,r){var i=this.intersectionSafe(t,e,n,r);return this.isInSegmentEnvelopes(i)||(i=new z(s.nearestEndpoint(t,e,n,r))),null!==this._precisionModel&&this._precisionModel.makePrecise(i),i}},{key:"checkDD",value:function(t,e,n,r,i){var o=ht.intersection(t,e,n,r),s=this.isInSegmentEnvelopes(o);xt.out.println("DD in env = "+s+" --------------------- "+o),i.distance(o)>1e-4&&xt.out.println("Distance = "+i.distance(o))}},{key:"intersectionSafe",value:function(t,e,n,r){var i=_t.intersection(t,e,n,r);return null===i&&(i=s.nearestEndpoint(t,e,n,r)),i}},{key:"computeCollinearIntersection",value:function(t,e,n,r){var i=X.intersects(t,e,n),o=X.intersects(t,e,r),s=X.intersects(n,r,t),a=X.intersects(n,r,e);return i&&o?(this._intPt[0]=n,this._intPt[1]=r,Pe.COLLINEAR_INTERSECTION):s&&a?(this._intPt[0]=t,this._intPt[1]=e,Pe.COLLINEAR_INTERSECTION):i&&s?(this._intPt[0]=n,this._intPt[1]=t,!n.equals(t)||o||a?Pe.COLLINEAR_INTERSECTION:Pe.POINT_INTERSECTION):i&&a?(this._intPt[0]=n,this._intPt[1]=e,!n.equals(e)||o||s?Pe.COLLINEAR_INTERSECTION:Pe.POINT_INTERSECTION):o&&s?(this._intPt[0]=r,this._intPt[1]=t,!r.equals(t)||i||a?Pe.COLLINEAR_INTERSECTION:Pe.POINT_INTERSECTION):o&&a?(this._intPt[0]=r,this._intPt[1]=e,!r.equals(e)||i||s?Pe.COLLINEAR_INTERSECTION:Pe.POINT_INTERSECTION):Pe.NO_INTERSECTION}},{key:"computeIntersect",value:function(t,e,n,r){if(this._isProper=!1,!X.intersects(t,e,n,r))return Pe.NO_INTERSECTION;var i=ft.index(t,e,n),o=ft.index(t,e,r);if(i>0&&o>0||i<0&&o<0)return Pe.NO_INTERSECTION;var s=ft.index(n,r,t),a=ft.index(n,r,e);return s>0&&a>0||s<0&&a<0?Pe.NO_INTERSECTION:0===i&&0===o&&0===s&&0===a?this.computeCollinearIntersection(t,e,n,r):(0===i||0===o||0===s||0===a?(this._isProper=!1,t.equals2D(n)||t.equals2D(r)?this._intPt[0]=t:e.equals2D(n)||e.equals2D(r)?this._intPt[0]=e:0===i?this._intPt[0]=new z(n):0===o?this._intPt[0]=new z(r):0===s?this._intPt[0]=new z(t):0===a&&(this._intPt[0]=new z(e))):(this._isProper=!0,this._intPt[0]=this.intersection(t,e,n,r)),Pe.POINT_INTERSECTION)}}],[{key:"nearestEndpoint",value:function(t,e,n,r){var i=t,o=kt.pointToSegment(t,n,r),s=kt.pointToSegment(e,n,r);return sr&&(n=e.x,r=t.x),this._p.x>=n&&this._p.x<=r&&(this._isPointOnSegment=!0),null}if(t.y>this._p.y&&e.y<=this._p.y||e.y>this._p.y&&t.y<=this._p.y){var i=ft.index(t,e,this._p);if(i===ft.COLLINEAR)return this._isPointOnSegment=!0,null;e.ythis.location.length){var e=new Array(3).fill(null);e[tt.ON]=this.location[tt.ON],e[tt.LEFT]=Z.NONE,e[tt.RIGHT]=Z.NONE,this.location=e}for(var n=0;n1&&t.append(Z.toLocationSymbol(this.location[tt.LEFT])),t.append(Z.toLocationSymbol(this.location[tt.ON])),this.location.length>1&&t.append(Z.toLocationSymbol(this.location[tt.RIGHT])),t.toString()}},{key:"setLocations",value:function(t,e,n){this.location[tt.ON]=t,this.location[tt.LEFT]=e,this.location[tt.RIGHT]=n}},{key:"get",value:function(t){return t1}},{key:"isAnyNull",value:function(){for(var t=0;tthis._maxNodeDegree&&(this._maxNodeDegree=e),t=this.getNext(t)}while(t!==this._startDe);this._maxNodeDegree*=2}},{key:"addPoints",value:function(t,e,n){var r=t.getCoordinates();if(e){var i=1;n&&(i=0);for(var o=i;o=0;a--)this._pts.add(r[a])}}},{key:"isHole",value:function(){return this._isHole}},{key:"setInResult",value:function(){var t=this._startDe;do{t.getEdge().setInResult(!0),t=t.getNext()}while(t!==this._startDe)}},{key:"containsPoint",value:function(t){var e=this.getLinearRing();if(!e.getEnvelopeInternal().contains(t))return!1;if(!Oe.isInRing(t,e.getCoordinates()))return!1;for(var n=this._holes.iterator();n.hasNext();)if(n.next().containsPoint(t))return!1;return!0}},{key:"addHole",value:function(t){this._holes.add(t)}},{key:"isShell",value:function(){return null===this._shell}},{key:"getLabel",value:function(){return this._label}},{key:"getEdges",value:function(){return this._edges}},{key:"getMaxNodeDegree",value:function(){return this._maxNodeDegree<0&&this.computeMaxNodeDegree(),this._maxNodeDegree}},{key:"getShell",value:function(){return this._shell}},{key:"mergeLabel",value:function(){if(1===arguments.length){var t=arguments[0];this.mergeLabel(t,0),this.mergeLabel(t,1)}else if(2===arguments.length){var e=arguments[1],n=arguments[0].getLocation(e,tt.RIGHT);if(n===Z.NONE)return null;if(this._label.getLocation(e)===Z.NONE)return this._label.setLocation(e,n),null}}},{key:"setShell",value:function(t){this._shell=t,null!==t&&t.addHole(this)}},{key:"toPolygon",value:function(t){for(var e=new Array(this._holes.size()).fill(null),n=0;n=2,"found partial label"),this.computeIM(t)}},{key:"isInResult",value:function(){return this._isInResult}},{key:"isVisited",value:function(){return this._isVisited}}],[{key:"constructor_",value:function(){if(this._label=null,this._isInResult=!1,this._isCovered=!1,this._isCoveredSet=!1,this._isVisited=!1,0===arguments.length);else if(1===arguments.length){var t=arguments[0];this._label=t}}}]),e}(),Ge=function(e){r(s,e);var o=c(s);function s(){var e;return t(this,s),e=o.call(this),s.constructor_.apply(l(e),arguments),e}return n(s,[{key:"isIncidentEdgeInResult",value:function(){for(var t=this.getEdges().getEdges().iterator();t.hasNext();)if(t.next().getEdge().isInResult())return!0;return!1}},{key:"isIsolated",value:function(){return 1===this._label.getGeometryCount()}},{key:"getCoordinate",value:function(){return this._coord}},{key:"print",value:function(t){t.println("node "+this._coord+" lbl: "+this._label)}},{key:"computeIM",value:function(t){}},{key:"computeMergedLocation",value:function(t,e){var n=Z.NONE;if(n=this._label.getLocation(e),!t.isNull(e)){var r=t.getLocation(e);n!==Z.BOUNDARY&&(n=r)}return n}},{key:"setLabel",value:function(){if(2!==arguments.length||!Number.isInteger(arguments[1])||!Number.isInteger(arguments[0]))return f(i(s.prototype),"setLabel",this).apply(this,arguments);var t=arguments[0],e=arguments[1];null===this._label?this._label=new Ae(t,e):this._label.setLocation(t,e)}},{key:"getEdges",value:function(){return this._edges}},{key:"mergeLabel",value:function(){if(arguments[0]instanceof s){var t=arguments[0];this.mergeLabel(t._label)}else if(arguments[0]instanceof Ae)for(var e=arguments[0],n=0;n<2;n++){var r=this.computeMergedLocation(e,n);this._label.getLocation(n)===Z.NONE&&this._label.setLocation(n,r)}}},{key:"add",value:function(t){this._edges.insert(t),t.setNode(this)}},{key:"setLabelBoundary",value:function(t){if(null===this._label)return null;var e=Z.NONE;null!==this._label&&(e=this._label.getLocation(t));var n=null;switch(e){case Z.BOUNDARY:n=Z.INTERIOR;break;case Z.INTERIOR:default:n=Z.BOUNDARY}this._label.setLocation(t,n)}}],[{key:"constructor_",value:function(){this._coord=null,this._edges=null;var t=arguments[0],e=arguments[1];this._coord=t,this._edges=e,this._label=new Ae(0,Z.NONE)}}]),s}(Ve),Be=function(e){r(i,e);var n=c(i);function i(){return t(this,i),n.apply(this,arguments)}return i}(ne);function Ye(t){return null==t?0:t.color}function ze(t){return null==t?null:t.parent}function je(t,e){null!==t&&(t.color=e)}function Xe(t){return null==t?null:t.left}function Ue(t){return null==t?null:t.right}var Ze=function(e){r(o,e);var i=c(o);function o(){var e;return t(this,o),(e=i.call(this)).root_=null,e.size_=0,e}return n(o,[{key:"get",value:function(t){for(var e=this.root_;null!==e;){var n=t.compareTo(e.key);if(n<0)e=e.left;else{if(!(n>0))return e.value;e=e.right}}return null}},{key:"put",value:function(t,e){if(null===this.root_)return this.root_={key:t,value:e,left:null,right:null,parent:null,color:0,getValue:function(){return this.value},getKey:function(){return this.key}},this.size_=1,null;var n,r,i=this.root_;do{if(n=i,(r=t.compareTo(i.key))<0)i=i.left;else{if(!(r>0)){var o=i.value;return i.value=e,o}i=i.right}}while(null!==i);var s={key:t,left:null,right:null,value:e,parent:n,color:0,getValue:function(){return this.value},getKey:function(){return this.key}};return r<0?n.left=s:n.right=s,this.fixAfterInsertion(s),this.size_++,null}},{key:"fixAfterInsertion",value:function(t){var e;for(t.color=1;null!=t&&t!==this.root_&&1===t.parent.color;)ze(t)===Xe(ze(ze(t)))?1===Ye(e=Ue(ze(ze(t))))?(je(ze(t),0),je(e,0),je(ze(ze(t)),1),t=ze(ze(t))):(t===Ue(ze(t))&&(t=ze(t),this.rotateLeft(t)),je(ze(t),0),je(ze(ze(t)),1),this.rotateRight(ze(ze(t)))):1===Ye(e=Xe(ze(ze(t))))?(je(ze(t),0),je(e,0),je(ze(ze(t)),1),t=ze(ze(t))):(t===Xe(ze(t))&&(t=ze(t),this.rotateRight(t)),je(ze(t),0),je(ze(ze(t)),1),this.rotateLeft(ze(ze(t))));this.root_.color=0}},{key:"values",value:function(){var t=new dt,e=this.getFirstEntry();if(null!==e)for(t.add(e.value);null!==(e=o.successor(e));)t.add(e.value);return t}},{key:"entrySet",value:function(){var t=new Q,e=this.getFirstEntry();if(null!==e)for(t.add(e);null!==(e=o.successor(e));)t.add(e);return t}},{key:"rotateLeft",value:function(t){if(null!=t){var e=t.right;t.right=e.left,null!=e.left&&(e.left.parent=t),e.parent=t.parent,null==t.parent?this.root_=e:t.parent.left===t?t.parent.left=e:t.parent.right=e,e.left=t,t.parent=e}}},{key:"rotateRight",value:function(t){if(null!=t){var e=t.left;t.left=e.right,null!=e.right&&(e.right.parent=t),e.parent=t.parent,null==t.parent?this.root_=e:t.parent.right===t?t.parent.right=e:t.parent.left=e,e.right=t,t.parent=e}}},{key:"getFirstEntry",value:function(){var t=this.root_;if(null!=t)for(;null!=t.left;)t=t.left;return t}},{key:"size",value:function(){return this.size_}},{key:"containsKey",value:function(t){for(var e=this.root_;null!==e;){var n=t.compareTo(e.key);if(n<0)e=e.left;else{if(!(n>0))return!0;e=e.right}}return!1}}],[{key:"successor",value:function(t){var e;if(null===t)return null;if(null!==t.right){for(e=t.right;null!==e.left;)e=e.left;return e}e=t.parent;for(var n=t;null!==e&&n===e.right;)n=e,e=e.parent;return e}}]),o}(Be),He=function(){function e(){t(this,e),e.constructor_.apply(this,arguments)}return n(e,[{key:"find",value:function(t){return this.nodeMap.get(t)}},{key:"addNode",value:function(){if(arguments[0]instanceof z){var t=arguments[0],e=this.nodeMap.get(t);return null===e&&(e=this.nodeFact.createNode(t),this.nodeMap.put(t,e)),e}if(arguments[0]instanceof Ge){var n=arguments[0],r=this.nodeMap.get(n.getCoordinate());return null===r?(this.nodeMap.put(n.getCoordinate(),n),n):(r.mergeLabel(n),r)}}},{key:"print",value:function(t){for(var e=this.iterator();e.hasNext();)e.next().print(t)}},{key:"iterator",value:function(){return this.nodeMap.values().iterator()}},{key:"values",value:function(){return this.nodeMap.values()}},{key:"getBoundaryNodes",value:function(t){for(var e=new dt,n=this.iterator();n.hasNext();){var r=n.next();r.getLabel().getLocation(t)===Z.BOUNDARY&&e.add(r)}return e}},{key:"add",value:function(t){var e=t.getCoordinate();this.addNode(e).add(t)}}],[{key:"constructor_",value:function(){this.nodeMap=new Ze,this.nodeFact=null;var t=arguments[0];this.nodeFact=t}}]),e}(),We=function(){function e(){t(this,e)}return n(e,null,[{key:"isNorthern",value:function(t){return t===e.NE||t===e.NW}},{key:"isOpposite",value:function(t,e){return t!==e&&2==(t-e+4)%4}},{key:"commonHalfPlane",value:function(t,e){if(t===e)return t;if(2==(t-e+4)%4)return-1;var n=te?t:e)?3:n}},{key:"isInHalfPlane",value:function(t,n){return n===e.SE?t===e.SE||t===e.SW:t===n||t===n+1}},{key:"quadrant",value:function(){if("number"==typeof arguments[0]&&"number"==typeof arguments[1]){var t=arguments[0],n=arguments[1];if(0===t&&0===n)throw new x("Cannot compute the quadrant for point ( "+t+", "+n+" )");return t>=0?n>=0?e.NE:e.SE:n>=0?e.NW:e.SW}if(arguments[0]instanceof z&&arguments[1]instanceof z){var r=arguments[0],i=arguments[1];if(i.x===r.x&&i.y===r.y)throw new x("Cannot compute the quadrant for two identical points "+r);return i.x>=r.x?i.y>=r.y?e.NE:e.SE:i.y>=r.y?e.NW:e.SW}}}]),e}();We.NE=0,We.NW=1,We.SW=2,We.SE=3;var Je=function(){function e(){t(this,e),e.constructor_.apply(this,arguments)}return n(e,[{key:"compareDirection",value:function(t){return this._dx===t._dx&&this._dy===t._dy?0:this._quadrant>t._quadrant?1:this._quadrant2){o.linkDirectedEdgesForMinimalEdgeRings();var s=o.buildMinimalRings(),a=this.findShell(s);null!==a?(this.placePolygonHoles(a,s),e.add(a)):n.addAll(s)}else r.add(o)}return r}},{key:"buildMaximalEdgeRings",value:function(t){for(var e=new dt,n=t.iterator();n.hasNext();){var r=n.next();if(r.isInResult()&&r.getLabel().isArea()&&null===r.getEdgeRing()){var i=new qe(r,this._geometryFactory);e.add(i),i.setInResult()}}return e}},{key:"placePolygonHoles",value:function(t,e){for(var n=e.iterator();n.hasNext();){var r=n.next();r.isHole()&&r.setShell(t)}}},{key:"getPolygons",value:function(){return this.computePolygons(this._shellList)}},{key:"findShell",value:function(t){for(var e=0,n=null,r=t.iterator();r.hasNext();){var i=r.next();i.isHole()||(n=i,e++)}return V.isTrue(e<=1,"found two shells in MinimalEdgeRing list"),n}},{key:"add",value:function(){if(1===arguments.length){var t=arguments[0];this.add(t.getEdgeEnds(),t.getNodes())}else if(2===arguments.length){var e=arguments[0],n=arguments[1];$e.linkResultDirectedEdges(n);var r=this.buildMaximalEdgeRings(e),i=new dt,o=this.buildMinimalEdgeRings(r,this._shellList,i);this.sortShellsAndHoles(o,this._shellList,i),this.placeFreeHoles(this._shellList,i)}}}],[{key:"constructor_",value:function(){this._geometryFactory=null,this._shellList=new dt;var t=arguments[0];this._geometryFactory=t}},{key:"findEdgeRingContaining",value:function(t,e){for(var n=t.getLinearRing(),r=n.getEnvelopeInternal(),i=n.getCoordinateN(0),o=null,s=null,a=e.iterator();a.hasNext();){var u=a.next(),l=u.getLinearRing(),h=l.getEnvelopeInternal();if(!h.equals(r)&&h.contains(r)){i=Wt.ptNotInList(n.getCoordinates(),l.getCoordinates());var c=!1;Oe.isInRing(i,l.getCoordinates())&&(c=!0),c&&(null===o||s.contains(h))&&(s=(o=u).getLinearRing().getEnvelopeInternal())}}return o}}]),e}(),en=function(){function e(){t(this,e)}return n(e,[{key:"getBounds",value:function(){}}]),e}(),nn=function(){function e(){t(this,e),e.constructor_.apply(this,arguments)}return n(e,[{key:"getItem",value:function(){return this._item}},{key:"getBounds",value:function(){return this._bounds}},{key:"interfaces_",get:function(){return[en,w]}}],[{key:"constructor_",value:function(){this._bounds=null,this._item=null;var t=arguments[0],e=arguments[1];this._bounds=t,this._item=e}}]),e}(),rn=function(){function e(){t(this,e),e.constructor_.apply(this,arguments)}return n(e,[{key:"poll",value:function(){if(this.isEmpty())return null;var t=this._items.get(1);return this._items.set(1,this._items.get(this._size)),this._size-=1,this.reorder(1),t}},{key:"size",value:function(){return this._size}},{key:"reorder",value:function(t){for(var e=null,n=this._items.get(t);2*t<=this._size&&((e=2*t)!==this._size&&this._items.get(e+1).compareTo(this._items.get(e))<0&&e++,this._items.get(e).compareTo(n)<0);t=e)this._items.set(t,this._items.get(e));this._items.set(t,n)}},{key:"clear",value:function(){this._size=0,this._items.clear()}},{key:"peek",value:function(){return this.isEmpty()?null:this._items.get(1)}},{key:"isEmpty",value:function(){return 0===this._size}},{key:"add",value:function(t){this._items.add(null),this._size+=1;var e=this._size;for(this._items.set(0,t);t.compareTo(this._items.get(Math.trunc(e/2)))<0;e/=2)this._items.set(e,this._items.get(Math.trunc(e/2)));this._items.set(e,t)}}],[{key:"constructor_",value:function(){this._size=null,this._items=null,this._size=0,this._items=new dt,this._items.add(null)}}]),e}(),on=function(){function e(){t(this,e)}return n(e,[{key:"insert",value:function(t,e){}},{key:"remove",value:function(t,e){}},{key:"query",value:function(){}}]),e}(),sn=function(){function e(){t(this,e),e.constructor_.apply(this,arguments)}return n(e,[{key:"getLevel",value:function(){return this._level}},{key:"size",value:function(){return this._childBoundables.size()}},{key:"getChildBoundables",value:function(){return this._childBoundables}},{key:"addChildBoundable",value:function(t){V.isTrue(null===this._bounds),this._childBoundables.add(t)}},{key:"isEmpty",value:function(){return this._childBoundables.isEmpty()}},{key:"getBounds",value:function(){return null===this._bounds&&(this._bounds=this.computeBounds()),this._bounds}},{key:"interfaces_",get:function(){return[en,w]}}],[{key:"constructor_",value:function(){if(this._childBoundables=new dt,this._bounds=null,this._level=null,0===arguments.length);else if(1===arguments.length){var t=arguments[0];this._level=t}}}]),e}(),an={reverseOrder:function(){return{compare:function(t,e){return e.compareTo(t)}}},min:function(t){return an.sort(t),t.get(0)},sort:function(t,e){var n=t.toArray();e?At.sort(n,e):At.sort(n);for(var r=t.iterator(),i=0,o=n.length;ie.area(this._boundable2)?(this.expand(this._boundable1,this._boundable2,!1,t,n),null):(this.expand(this._boundable2,this._boundable1,!0,t,n),null);if(r)return this.expand(this._boundable1,this._boundable2,!1,t,n),null;if(i)return this.expand(this._boundable2,this._boundable1,!0,t,n),null;throw new x("neither boundable is composite")}},{key:"isLeaves",value:function(){return!(e.isComposite(this._boundable1)||e.isComposite(this._boundable2))}},{key:"compareTo",value:function(t){var e=t;return this._distancee._distance?1:0}},{key:"expand",value:function(t,n,r,i,o){for(var s=t.getChildBoundables().iterator();s.hasNext();){var a=s.next(),u=null;(u=r?new e(n,a,this._itemDistance):new e(a,n,this._itemDistance)).getDistance()-2),r.getLevel()===n)return i.add(r),null;for(var o=r.getChildBoundables().iterator();o.hasNext();){var s=o.next();s instanceof sn?this.boundablesAtLevel(n,s,i):(V.isTrue(s instanceof nn),-1===n&&i.add(s))}return null}}},{key:"query",value:function(){if(1===arguments.length){var t=arguments[0];this.build();var e=new dt;return this.isEmpty()||this.getIntersectsOp().intersects(this._root.getBounds(),t)&&this.queryInternal(t,this._root,e),e}if(2===arguments.length){var n=arguments[0],r=arguments[1];if(this.build(),this.isEmpty())return null;this.getIntersectsOp().intersects(this._root.getBounds(),n)&&this.queryInternal(n,this._root,r)}}},{key:"build",value:function(){if(this._built)return null;this._root=this._itemBoundables.isEmpty()?this.createNode(0):this.createHigherLevels(this._itemBoundables,-1),this._itemBoundables=null,this._built=!0}},{key:"getRoot",value:function(){return this.build(),this._root}},{key:"remove",value:function(){if(2===arguments.length){var t=arguments[0],e=arguments[1];return this.build(),!!this.getIntersectsOp().intersects(this._root.getBounds(),t)&&this.remove(t,this._root,e)}if(3===arguments.length){var n=arguments[0],r=arguments[1],i=arguments[2],o=this.removeItem(r,i);if(o)return!0;for(var s=null,a=r.getChildBoundables().iterator();a.hasNext();){var u=a.next();if(this.getIntersectsOp().intersects(u.getBounds(),n)&&u instanceof sn&&(o=this.remove(n,u,i))){s=u;break}}return null!==s&&s.getChildBoundables().isEmpty()&&r.getChildBoundables().remove(s),o}}},{key:"createHigherLevels",value:function(t,e){V.isTrue(!t.isEmpty());var n=this.createParentBoundables(t,e+1);return 1===n.size()?n.get(0):this.createHigherLevels(n,e+1)}},{key:"depth",value:function(){if(0===arguments.length)return this.isEmpty()?0:(this.build(),this.depth(this._root));if(1===arguments.length){for(var t=0,e=arguments[0].getChildBoundables().iterator();e.hasNext();){var n=e.next();if(n instanceof sn){var r=this.depth(n);r>t&&(t=r)}}return t+1}}},{key:"createParentBoundables",value:function(t,e){V.isTrue(!t.isEmpty());var n=new dt;n.add(this.createNode(e));var r=new dt(t);an.sort(r,this.getComparator());for(var i=r.iterator();i.hasNext();){var o=i.next();this.lastNode(n).getChildBoundables().size()===this.getNodeCapacity()&&n.add(this.createNode(e)),this.lastNode(n).addChildBoundable(o)}return n}},{key:"isEmpty",value:function(){return this._built?this._root.isEmpty():this._itemBoundables.isEmpty()}},{key:"interfaces_",get:function(){return[w]}}],[{key:"constructor_",value:function(){if(this._root=null,this._built=!1,this._itemBoundables=new dt,this._nodeCapacity=null,0===arguments.length)e.constructor_.call(this,e.DEFAULT_NODE_CAPACITY);else if(1===arguments.length){var t=arguments[0];V.isTrue(t>1,"Node capacity must be greater than 1"),this._nodeCapacity=t}}},{key:"compareDoubles",value:function(t,e){return t>e?1:t0);for(var n=new dt,r=0;r=0;){var u=o.poll(),l=u.getDistance();if(l>=i)break;u.isLeaves()?a.size()l&&(a.poll(),a.add(u)),i=a.peek().getDistance()):u.expandToQueue(o,i)}return s.getItems(a)}}},{key:"createNode",value:function(t){return new pn(t)}},{key:"size",value:function(){return 0===arguments.length?f(i(s.prototype),"size",this).call(this):f(i(s.prototype),"size",this).apply(this,arguments)}},{key:"insert",value:function(){if(!(2===arguments.length&&arguments[1]instanceof Object&&arguments[0]instanceof X))return f(i(s.prototype),"insert",this).apply(this,arguments);var t=arguments[0],e=arguments[1];if(t.isNull())return null;f(i(s.prototype),"insert",this).call(this,t,e)}},{key:"getIntersectsOp",value:function(){return s.intersectsOp}},{key:"verticalSlices",value:function(t,e){for(var n=Math.trunc(Math.ceil(t.size()/e)),r=new Array(e).fill(null),i=t.iterator(),o=0;o0;){var s=o.poll(),a=s.getDistance();if(a>=r)break;s.isLeaves()?(r=a,i=s):s.expandToQueue(o,r)}return null===i?null:[i.getBoundable(0).getItem(),i.getBoundable(1).getItem()]}}else{if(2===arguments.length){var u=arguments[0],l=arguments[1];if(this.isEmpty()||u.isEmpty())return null;var h=new ln(this.getRoot(),u.getRoot(),l);return this.nearestNeighbour(h)}if(3===arguments.length){var c=arguments[2],f=new nn(arguments[0],arguments[1]),g=new ln(this.getRoot(),f,c);return this.nearestNeighbour(g)[0]}if(4===arguments.length){var p=arguments[2],v=arguments[3],d=new nn(arguments[0],arguments[1]),y=new ln(this.getRoot(),d,p);return this.nearestNeighbourK(y,v)}}}},{key:"isWithinDistance",value:function(){if(2===arguments.length){var t=arguments[0],e=arguments[1],n=A.POSITIVE_INFINITY,r=new rn;for(r.add(t);!r.isEmpty();){var i=r.poll(),o=i.getDistance();if(o>e)return!1;if(i.maximumDistance()<=e)return!0;if(i.isLeaves()){if((n=o)<=e)return!0}else i.expandToQueue(r,n)}return!1}if(3===arguments.length){var s=arguments[0],a=arguments[1],u=arguments[2],l=new ln(this.getRoot(),s.getRoot(),a);return this.isWithinDistance(l,u)}}},{key:"interfaces_",get:function(){return[on,w]}}],[{key:"constructor_",value:function(){if(0===arguments.length)s.constructor_.call(this,s.DEFAULT_NODE_CAPACITY);else if(1===arguments.length){var t=arguments[0];cn.constructor_.call(this,t)}}},{key:"centreX",value:function(t){return s.avg(t.getMinX(),t.getMaxX())}},{key:"avg",value:function(t,e){return(t+e)/2}},{key:"getItems",value:function(t){for(var e=new Array(t.size()).fill(null),n=0;!t.isEmpty();){var r=t.poll();e[n]=r.getBoundable(0).getItem(),n++}return e}},{key:"centreY",value:function(t){return s.avg(t.getMinY(),t.getMaxY())}}]),s}(cn),pn=function(e){r(o,e);var i=c(o);function o(){var e;return t(this,o),e=i.call(this),o.constructor_.apply(l(e),arguments),e}return n(o,[{key:"computeBounds",value:function(){for(var t=null,e=this.getChildBoundables().iterator();e.hasNext();){var n=e.next();null===t?t=new X(n.getBounds()):t.expandToInclude(n.getBounds())}return t}}],[{key:"constructor_",value:function(){var t=arguments[0];sn.constructor_.call(this,t)}}]),o}(sn);gn.STRtreeNode=pn,gn.xComparator=new(function(){function e(){t(this,e)}return n(e,[{key:"interfaces_",get:function(){return[D]}},{key:"compare",value:function(t,e){return cn.compareDoubles(gn.centreX(t.getBounds()),gn.centreX(e.getBounds()))}}]),e}()),gn.yComparator=new(function(){function e(){t(this,e)}return n(e,[{key:"interfaces_",get:function(){return[D]}},{key:"compare",value:function(t,e){return cn.compareDoubles(gn.centreY(t.getBounds()),gn.centreY(e.getBounds()))}}]),e}()),gn.intersectsOp=new(function(){function e(){t(this,e)}return n(e,[{key:"interfaces_",get:function(){return[IntersectsOp]}},{key:"intersects",value:function(t,e){return t.intersects(e)}}]),e}()),gn.DEFAULT_NODE_CAPACITY=10;var vn=function(){function e(){t(this,e)}return n(e,null,[{key:"relativeSign",value:function(t,e){return te?1:0}},{key:"compare",value:function(t,n,r){if(n.equals2D(r))return 0;var i=e.relativeSign(n.x,r.x),o=e.relativeSign(n.y,r.y);switch(t){case 0:return e.compareValue(i,o);case 1:return e.compareValue(o,i);case 2:return e.compareValue(o,-i);case 3:return e.compareValue(-i,o);case 4:return e.compareValue(-i,-o);case 5:return e.compareValue(-o,-i);case 6:return e.compareValue(-o,i);case 7:return e.compareValue(i,-o)}return V.shouldNeverReachHere("invalid octant value"),0}},{key:"compareValue",value:function(t,e){return t<0?-1:t>0?1:e<0?-1:e>0?1:0}}]),e}(),dn=function(){function e(){t(this,e),e.constructor_.apply(this,arguments)}return n(e,[{key:"getCoordinate",value:function(){return this.coord}},{key:"print",value:function(t){t.print(this.coord),t.print(" seg # = "+this.segmentIndex)}},{key:"compareTo",value:function(t){var e=t;return this.segmentIndexe.segmentIndex?1:this.coord.equals2D(e.coord)?0:this._isInterior?e._isInterior?vn.compare(this._segmentOctant,this.coord,e.coord):1:-1}},{key:"isEndPoint",value:function(t){return 0===this.segmentIndex&&!this._isInterior||this.segmentIndex===t}},{key:"toString",value:function(){return this.segmentIndex+":"+this.coord.toString()}},{key:"isInterior",value:function(){return this._isInterior}},{key:"interfaces_",get:function(){return[k]}}],[{key:"constructor_",value:function(){this._segString=null,this.coord=null,this.segmentIndex=null,this._segmentOctant=null,this._isInterior=null;var t=arguments[0],e=arguments[1],n=arguments[2],r=arguments[3];this._segString=t,this.coord=new z(e),this.segmentIndex=n,this._segmentOctant=r,this._isInterior=!e.equals2D(t.getCoordinate(n))}}]),e}(),yn=function(){function e(){t(this,e)}return n(e,[{key:"hasNext",value:function(){}},{key:"next",value:function(){}},{key:"remove",value:function(){}}]),e}(),mn=function(){function e(){t(this,e),e.constructor_.apply(this,arguments)}return n(e,[{key:"getSplitCoordinates",value:function(){var t=new Ht;this.addEndpoints();for(var e=this.iterator(),n=e.next();e.hasNext();){var r=e.next();this.addEdgeCoordinates(n,r,t),n=r}return t.toCoordinateArray()}},{key:"addCollapsedNodes",value:function(){var t=new dt;this.findCollapsesFromInsertedNodes(t),this.findCollapsesFromExistingVertices(t);for(var e=t.iterator();e.hasNext();){var n=e.next().intValue();this.add(this._edge.getCoordinate(n),n)}}},{key:"createSplitEdgePts",value:function(t,e){var n=e.segmentIndex-t.segmentIndex+2;if(2===n)return[new z(t.coord),new z(e.coord)];var r=this._edge.getCoordinate(e.segmentIndex),i=e.isInterior()||!e.coord.equals2D(r);i||n--;var o=new Array(n).fill(null),s=0;o[s++]=new z(t.coord);for(var a=t.segmentIndex+1;a<=e.segmentIndex;a++)o[s++]=this._edge.getCoordinate(a);return i&&(o[s]=new z(e.coord)),o}},{key:"print",value:function(t){t.println("Intersections:");for(var e=this.iterator();e.hasNext();)e.next().print(t)}},{key:"findCollapsesFromExistingVertices",value:function(t){for(var e=0;e=0?n>=0?r>=i?0:1:r>=i?7:6:n>=0?r>=i?3:2:r>=i?4:5}if(arguments[0]instanceof z&&arguments[1]instanceof z){var o=arguments[0],s=arguments[1],a=s.x-o.x,u=s.y-o.y;if(0===a&&0===u)throw new x("Cannot compute the octant for two identical points "+o);return e.octant(a,u)}}}]),e}(),xn=function(){function e(){t(this,e)}return n(e,[{key:"getCoordinates",value:function(){}},{key:"size",value:function(){}},{key:"getCoordinate",value:function(t){}},{key:"isClosed",value:function(){}},{key:"setData",value:function(t){}},{key:"getData",value:function(){}}]),e}(),En=function(){function e(){t(this,e)}return n(e,[{key:"addIntersection",value:function(t,e){}},{key:"interfaces_",get:function(){return[xn]}}]),e}(),kn=function(){function e(){t(this,e),e.constructor_.apply(this,arguments)}return n(e,[{key:"getCoordinates",value:function(){return this._pts}},{key:"size",value:function(){return this._pts.length}},{key:"getCoordinate",value:function(t){return this._pts[t]}},{key:"isClosed",value:function(){return this._pts[0].equals(this._pts[this._pts.length-1])}},{key:"getSegmentOctant",value:function(t){return t===this._pts.length-1?-1:this.safeOctant(this.getCoordinate(t),this.getCoordinate(t+1))}},{key:"setData",value:function(t){this._data=t}},{key:"safeOctant",value:function(t,e){return t.equals2D(e)?0:_n.octant(t,e)}},{key:"getData",value:function(){return this._data}},{key:"addIntersection",value:function(){if(2===arguments.length){var t=arguments[0],e=arguments[1];this.addIntersectionNode(t,e)}else if(4===arguments.length){var n=arguments[1],r=arguments[3],i=new z(arguments[0].getIntersection(r));this.addIntersection(i,n)}}},{key:"toString",value:function(){return Le.toLineString(new $t(this._pts))}},{key:"getNodeList",value:function(){return this._nodeList}},{key:"addIntersectionNode",value:function(t,e){var n=e,r=n+1;if(r=0&&r>=0||n<=0&&r<=0?Math.max(n,r):0}if(arguments[0]instanceof z){var i=arguments[0];return ft.index(this.p0,this.p1,i)}}},{key:"toGeometry",value:function(t){return t.createLineString([this.p0,this.p1])}},{key:"isVertical",value:function(){return this.p0.x===this.p1.x}},{key:"equals",value:function(t){if(!(t instanceof e))return!1;var n=t;return this.p0.equals(n.p0)&&this.p1.equals(n.p1)}},{key:"intersection",value:function(t){var e=new Ce;return e.computeIntersection(this.p0,this.p1,t.p0,t.p1),e.hasIntersection()?e.getIntersection(0):null}},{key:"project",value:function(){if(arguments[0]instanceof z){var t=arguments[0];if(t.equals(this.p0)||t.equals(this.p1))return new z(t);var n=this.projectionFactor(t),r=new z;return r.x=this.p0.x+n*(this.p1.x-this.p0.x),r.y=this.p0.y+n*(this.p1.y-this.p0.y),r}if(arguments[0]instanceof e){var i=arguments[0],o=this.projectionFactor(i.p0),s=this.projectionFactor(i.p1);if(o>=1&&s>=1)return null;if(o<=0&&s<=0)return null;var a=this.project(i.p0);o<0&&(a=this.p0),o>1&&(a=this.p1);var u=this.project(i.p1);return s<0&&(u=this.p0),s>1&&(u=this.p1),new e(a,u)}}},{key:"normalize",value:function(){this.p1.compareTo(this.p0)<0&&this.reverse()}},{key:"angle",value:function(){return Math.atan2(this.p1.y-this.p0.y,this.p1.x-this.p0.x)}},{key:"getCoordinate",value:function(t){return 0===t?this.p0:this.p1}},{key:"distancePerpendicular",value:function(t){return kt.pointToLinePerpendicular(t,this.p0,this.p1)}},{key:"minY",value:function(){return Math.min(this.p0.y,this.p1.y)}},{key:"midPoint",value:function(){return e.midPoint(this.p0,this.p1)}},{key:"projectionFactor",value:function(t){if(t.equals(this.p0))return 0;if(t.equals(this.p1))return 1;var e=this.p1.x-this.p0.x,n=this.p1.y-this.p0.y,r=e*e+n*n;return r<=0?A.NaN:((t.x-this.p0.x)*e+(t.y-this.p0.y)*n)/r}},{key:"closestPoints",value:function(t){var e=this.intersection(t);if(null!==e)return[e,e];var n=new Array(2).fill(null),r=A.MAX_VALUE,i=null,o=this.closestPoint(t.p0);r=o.distance(t.p0),n[0]=o,n[1]=t.p0;var s=this.closestPoint(t.p1);(i=s.distance(t.p1))0&&e<1?this.project(t):this.p0.distance(t)1||A.isNaN(e))&&(e=1),e}},{key:"toString",value:function(){return"LINESTRING( "+this.p0.x+" "+this.p0.y+", "+this.p1.x+" "+this.p1.y+")"}},{key:"isHorizontal",value:function(){return this.p0.y===this.p1.y}},{key:"reflect",value:function(t){var e=this.p1.getY()-this.p0.getY(),n=this.p0.getX()-this.p1.getX(),r=this.p0.getY()*(this.p1.getX()-this.p0.getX())-this.p0.getX()*(this.p1.getY()-this.p0.getY()),i=e*e+n*n,o=e*e-n*n,s=t.getX(),a=t.getY();return new z((-o*s-2*e*n*a-2*e*r)/i,(o*a-2*e*n*s-2*n*r)/i)}},{key:"distance",value:function(){if(arguments[0]instanceof e){var t=arguments[0];return kt.segmentToSegment(this.p0,this.p1,t.p0,t.p1)}if(arguments[0]instanceof z){var n=arguments[0];return kt.pointToSegment(n,this.p0,this.p1)}}},{key:"pointAlong",value:function(t){var e=new z;return e.x=this.p0.x+t*(this.p1.x-this.p0.x),e.y=this.p0.y+t*(this.p1.y-this.p0.y),e}},{key:"hashCode",value:function(){var t=A.doubleToLongBits(this.p0.x);t^=31*A.doubleToLongBits(this.p0.y);var e=Math.trunc(t)^Math.trunc(t>>32),n=A.doubleToLongBits(this.p1.x);return n^=31*A.doubleToLongBits(this.p1.y),e^Math.trunc(n)^Math.trunc(n>>32)}},{key:"interfaces_",get:function(){return[k,w]}}],[{key:"constructor_",value:function(){if(this.p0=null,this.p1=null,0===arguments.length)e.constructor_.call(this,new z,new z);else if(1===arguments.length){var t=arguments[0];e.constructor_.call(this,t.p0,t.p1)}else if(2===arguments.length){var n=arguments[0],r=arguments[1];this.p0=n,this.p1=r}else if(4===arguments.length){var i=arguments[0],o=arguments[1],s=arguments[2],a=arguments[3];e.constructor_.call(this,new z(i,o),new z(s,a))}}},{key:"midPoint",value:function(t,e){return new z((t.x+e.x)/2,(t.y+e.y)/2)}}]),e}(),wn=function(){function e(){t(this,e),e.constructor_.apply(this,arguments)}return n(e,[{key:"overlap",value:function(){if(2===arguments.length);else if(4===arguments.length){var t=arguments[1],e=arguments[2],n=arguments[3];arguments[0].getLineSegment(t,this._overlapSeg1),e.getLineSegment(n,this._overlapSeg2),this.overlap(this._overlapSeg1,this._overlapSeg2)}}}],[{key:"constructor_",value:function(){this._overlapSeg1=new bn,this._overlapSeg2=new bn}}]),e}(),In=function(){function e(){t(this,e),e.constructor_.apply(this,arguments)}return n(e,[{key:"getLineSegment",value:function(t,e){e.p0=this._pts[t],e.p1=this._pts[t+1]}},{key:"computeSelect",value:function(t,e,n,r){var i=this._pts[e],o=this._pts[n];if(n-e==1)return r.select(this,e),null;if(!t.intersects(i,o))return null;var s=Math.trunc((e+n)/2);e=t.length-1)return t.length-1;for(var r=We.quadrant(t[n],t[n+1]),i=e+1;in.getId()&&(n.computeOverlaps(i,t),this._nOverlaps++),this._segInt.isDone())return null}}}],[{key:"constructor_",value:function(){if(this._monoChains=new dt,this._index=new gn,this._idCounter=0,this._nodedSegStrings=null,this._nOverlaps=0,0===arguments.length);else if(1===arguments.length){var t=arguments[0];Mn.constructor_.call(this,t)}}}]),o}(Mn),Pn=function(e){r(s,e);var o=c(s);function s(){var e;return t(this,s),e=o.call(this),s.constructor_.apply(l(e),arguments),e}return n(s,[{key:"overlap",value:function(){if(4!==arguments.length)return f(i(s.prototype),"overlap",this).apply(this,arguments);var t=arguments[1],e=arguments[2],n=arguments[3],r=arguments[0].getContext(),o=e.getContext();this._si.processIntersections(r,t,o,n)}}],[{key:"constructor_",value:function(){this._si=null;var t=arguments[0];this._si=t}}]),s}(wn);Ln.SegmentOverlapAction=Pn;var Cn=function(){function e(){t(this,e),e.constructor_.apply(this,arguments)}return n(e,[{key:"isDeletable",value:function(t,e,n,r){var i=this._inputLine[t],o=this._inputLine[e],s=this._inputLine[n];return!!this.isConcave(i,o,s)&&!!this.isShallow(i,o,s,r)&&this.isShallowSampled(i,o,t,n,r)}},{key:"deleteShallowConcavities",value:function(){for(var t=1,n=this.findNextNonDeletedIndex(t),r=this.findNextNonDeletedIndex(n),i=!1;r=0;r--)this.addPt(t[r])}},{key:"isRedundant",value:function(t){if(this._ptList.size()<1)return!1;var e=this._ptList.get(this._ptList.size()-1);return t.distance(e)Math.PI;)t-=e.PI_TIMES_2;for(;t<=-Math.PI;)t+=e.PI_TIMES_2;return t}},{key:"angle",value:function(){if(1===arguments.length){var t=arguments[0];return Math.atan2(t.y,t.x)}if(2===arguments.length){var e=arguments[0],n=arguments[1],r=n.x-e.x,i=n.y-e.y;return Math.atan2(i,r)}}},{key:"isAcute",value:function(t,e,n){var r=t.x-e.x,i=t.y-e.y;return r*(n.x-e.x)+i*(n.y-e.y)>0}},{key:"isObtuse",value:function(t,e,n){var r=t.x-e.x,i=t.y-e.y;return r*(n.x-e.x)+i*(n.y-e.y)<0}},{key:"interiorAngle",value:function(t,n,r){var i=e.angle(n,t),o=e.angle(n,r);return Math.abs(o-i)}},{key:"normalizePositive",value:function(t){if(t<0){for(;t<0;)t+=e.PI_TIMES_2;t>=e.PI_TIMES_2&&(t=0)}else{for(;t>=e.PI_TIMES_2;)t-=e.PI_TIMES_2;t<0&&(t=0)}return t}},{key:"angleBetween",value:function(t,n,r){var i=e.angle(n,t),o=e.angle(n,r);return e.diff(i,o)}},{key:"diff",value:function(t,e){var n=null;return(n=tMath.PI&&(n=2*Math.PI-n),n}},{key:"toRadians",value:function(t){return t*Math.PI/180}},{key:"getTurn",value:function(t,n){var r=Math.sin(n-t);return r>0?e.COUNTERCLOCKWISE:r<0?e.CLOCKWISE:e.NONE}},{key:"angleBetweenOriented",value:function(t,n,r){var i=e.angle(n,t),o=e.angle(n,r)-i;return o<=-Math.PI?o+e.PI_TIMES_2:o>Math.PI?o-e.PI_TIMES_2:o}}]),e}();On.PI_TIMES_2=2*Math.PI,On.PI_OVER_2=Math.PI/2,On.PI_OVER_4=Math.PI/4,On.COUNTERCLOCKWISE=ft.COUNTERCLOCKWISE,On.CLOCKWISE=ft.CLOCKWISE,On.NONE=ft.COLLINEAR;var Rn=function(){function e(){t(this,e),e.constructor_.apply(this,arguments)}return n(e,[{key:"addNextSegment",value:function(t,e){if(this._s0=this._s1,this._s1=this._s2,this._s2=t,this._seg0.setCoordinates(this._s0,this._s1),this.computeOffsetSegment(this._seg0,this._side,this._distance,this._offset0),this._seg1.setCoordinates(this._s1,this._s2),this.computeOffsetSegment(this._seg1,this._side,this._distance,this._offset1),this._s1.equals(this._s2))return null;var n=ft.index(this._s0,this._s1,this._s2),r=n===ft.CLOCKWISE&&this._side===tt.LEFT||n===ft.COUNTERCLOCKWISE&&this._side===tt.RIGHT;0===n?this.addCollinear(e):r?this.addOutsideTurn(n,e):this.addInsideTurn(n,e)}},{key:"addLineEndCap",value:function(t,e){var n=new bn(t,e),r=new bn;this.computeOffsetSegment(n,tt.LEFT,this._distance,r);var i=new bn;this.computeOffsetSegment(n,tt.RIGHT,this._distance,i);var o=e.x-t.x,s=e.y-t.y,a=Math.atan2(s,o);switch(this._bufParams.getEndCapStyle()){case y.CAP_ROUND:this._segList.addPt(r.p1),this.addDirectedFillet(e,a+Math.PI/2,a-Math.PI/2,ft.CLOCKWISE,this._distance),this._segList.addPt(i.p1);break;case y.CAP_FLAT:this._segList.addPt(r.p1),this._segList.addPt(i.p1);break;case y.CAP_SQUARE:var u=new z;u.x=Math.abs(this._distance)*Math.cos(a),u.y=Math.abs(this._distance)*Math.sin(a);var l=new z(r.p1.x+u.x,r.p1.y+u.y),h=new z(i.p1.x+u.x,i.p1.y+u.y);this._segList.addPt(l),this._segList.addPt(h)}}},{key:"getCoordinates",value:function(){return this._segList.getCoordinates()}},{key:"addMitreJoin",value:function(t,e,n,r){var i=_t.intersection(e.p0,e.p1,n.p0,n.p1);if(null!==i&&(r<=0?1:i.distance(t)/Math.abs(r))<=this._bufParams.getMitreLimit())return this._segList.addPt(i),null;this.addLimitedMitreJoin(e,n,r,this._bufParams.getMitreLimit())}},{key:"addOutsideTurn",value:function(t,n){if(this._offset0.p1.distance(this._offset1.p0)=h&&(a-=2*Math.PI),this._segList.addPt(e),this.addDirectedFillet(t,a,h,r,i),this._segList.addPt(n)}},{key:"addLastSegment",value:function(){this._segList.addPt(this._offset1.p1)}},{key:"initSideSegments",value:function(t,e,n){this._s1=t,this._s2=e,this._side=n,this._seg1.setCoordinates(t,e),this.computeOffsetSegment(this._seg1,n,this._distance,this._offset1)}},{key:"addLimitedMitreJoin",value:function(t,e,n,r){var i=this._seg0.p1,o=On.angle(i,this._seg0.p0),s=On.angleBetweenOriented(this._seg0.p0,i,this._seg1.p1)/2,a=On.normalize(o+s),u=On.normalize(a+Math.PI),l=r*n,h=n-l*Math.abs(Math.sin(s)),c=i.x+l*Math.cos(u),f=i.y+l*Math.sin(u),g=new z(c,f),p=new bn(i,g),v=p.pointAlongOffset(1,h),d=p.pointAlongOffset(1,-h);this._side===tt.LEFT?(this._segList.addPt(v),this._segList.addPt(d)):(this._segList.addPt(d),this._segList.addPt(v))}},{key:"addDirectedFillet",value:function(t,e,n,r,i){var o=r===ft.CLOCKWISE?-1:1,s=Math.abs(e-n),a=Math.trunc(s/this._filletAngleQuantum+.5);if(a<1)return null;for(var u=s/a,l=new z,h=0;h0){var r=new z((this._closingSegLengthFactor*this._offset0.p1.x+this._s1.x)/(this._closingSegLengthFactor+1),(this._closingSegLengthFactor*this._offset0.p1.y+this._s1.y)/(this._closingSegLengthFactor+1));this._segList.addPt(r);var i=new z((this._closingSegLengthFactor*this._offset1.p0.x+this._s1.x)/(this._closingSegLengthFactor+1),(this._closingSegLengthFactor*this._offset1.p0.y+this._s1.y)/(this._closingSegLengthFactor+1));this._segList.addPt(i)}else this._segList.addPt(this._s1);this._segList.addPt(this._offset1.p0)}}},{key:"createCircle",value:function(t){var e=new z(t.x+this._distance,t.y);this._segList.addPt(e),this.addDirectedFillet(t,0,2*Math.PI,-1,this._distance),this._segList.closeRing()}},{key:"addBevelJoin",value:function(t,e){this._segList.addPt(t.p1),this._segList.addPt(e.p0)}},{key:"init",value:function(t){this._distance=t,this._maxCurveSegmentError=t*(1-Math.cos(this._filletAngleQuantum/2)),this._segList=new Tn,this._segList.setPrecisionModel(this._precisionModel),this._segList.setMinimumVertexDistance(t*e.CURVE_VERTEX_SNAP_DISTANCE_FACTOR)}},{key:"addCollinear",value:function(t){this._li.computeIntersection(this._s0,this._s1,this._s1,this._s2),this._li.getIntersectionNum()>=2&&(this._bufParams.getJoinStyle()===y.JOIN_BEVEL||this._bufParams.getJoinStyle()===y.JOIN_MITRE?(t&&this._segList.addPt(this._offset0.p1),this._segList.addPt(this._offset1.p0)):this.addCornerFillet(this._s1,this._offset0.p1,this._offset1.p0,ft.CLOCKWISE,this._distance))}},{key:"closeRing",value:function(){this._segList.closeRing()}},{key:"hasNarrowConcaveAngle",value:function(){return this._hasNarrowConcaveAngle}}],[{key:"constructor_",value:function(){this._maxCurveSegmentError=0,this._filletAngleQuantum=null,this._closingSegLengthFactor=1,this._segList=null,this._distance=0,this._precisionModel=null,this._bufParams=null,this._li=null,this._s0=null,this._s1=null,this._s2=null,this._seg0=new bn,this._seg1=new bn,this._offset0=new bn,this._offset1=new bn,this._side=0,this._hasNarrowConcaveAngle=!1;var t=arguments[0],n=arguments[1],r=arguments[2];this._precisionModel=t,this._bufParams=n,this._li=new Ce,this._filletAngleQuantum=Math.PI/2/n.getQuadrantSegments(),n.getQuadrantSegments()>=8&&n.getJoinStyle()===y.JOIN_ROUND&&(this._closingSegLengthFactor=e.MAX_CLOSING_SEG_LEN_FACTOR),this.init(r)}}]),e}();Rn.OFFSET_SEGMENT_SEPARATION_FACTOR=.001,Rn.INSIDE_TURN_VERTEX_SNAP_DISTANCE_FACTOR=.001,Rn.CURVE_VERTEX_SNAP_DISTANCE_FACTOR=1e-6,Rn.MAX_CLOSING_SEG_LEN_FACTOR=80;var An=function(){function e(){t(this,e),e.constructor_.apply(this,arguments)}return n(e,[{key:"getOffsetCurve",value:function(t,e){if(this._distance=e,0===e)return null;var n=e<0,r=Math.abs(e),i=this.getSegGen(r);t.length<=1?this.computePointCurve(t[0],i):this.computeOffsetCurve(t,n,i);var o=i.getCoordinates();return n&&Wt.reverse(o),o}},{key:"computeSingleSidedBufferCurve",value:function(t,e,n){var r=this.simplifyTolerance(this._distance);if(e){n.addSegments(t,!0);var i=Cn.simplify(t,-r),o=i.length-1;n.initSideSegments(i[o],i[o-1],tt.LEFT),n.addFirstSegment();for(var s=o-2;s>=0;s--)n.addNextSegment(i[s],!0)}else{n.addSegments(t,!1);var a=Cn.simplify(t,r),u=a.length-1;n.initSideSegments(a[0],a[1],tt.LEFT),n.addFirstSegment();for(var l=2;l<=u;l++)n.addNextSegment(a[l],!0)}n.addLastSegment(),n.closeRing()}},{key:"computeRingBufferCurve",value:function(t,e,n){var r=this.simplifyTolerance(this._distance);e===tt.RIGHT&&(r=-r);var i=Cn.simplify(t,r),o=i.length-1;n.initSideSegments(i[o-1],i[0],e);for(var s=1;s<=o;s++){var a=1!==s;n.addNextSegment(i[s],a)}n.closeRing()}},{key:"computeLineBufferCurve",value:function(t,e){var n=this.simplifyTolerance(this._distance),r=Cn.simplify(t,n),i=r.length-1;e.initSideSegments(r[0],r[1],tt.LEFT);for(var o=2;o<=i;o++)e.addNextSegment(r[o],!0);e.addLastSegment(),e.addLineEndCap(r[i-1],r[i]);var s=Cn.simplify(t,-n),a=s.length-1;e.initSideSegments(s[a],s[a-1],tt.LEFT);for(var u=a-2;u>=0;u--)e.addNextSegment(s[u],!0);e.addLastSegment(),e.addLineEndCap(s[1],s[0]),e.closeRing()}},{key:"computePointCurve",value:function(t,e){switch(this._bufParams.getEndCapStyle()){case y.CAP_ROUND:e.createCircle(t);break;case y.CAP_SQUARE:e.createSquare(t)}}},{key:"getLineCurve",value:function(t,e){if(this._distance=e,this.isLineOffsetEmpty(e))return null;var n=Math.abs(e),r=this.getSegGen(n);if(t.length<=1)this.computePointCurve(t[0],r);else if(this._bufParams.isSingleSided()){var i=e<0;this.computeSingleSidedBufferCurve(t,i,r)}else this.computeLineBufferCurve(t,r);return r.getCoordinates()}},{key:"getBufferParameters",value:function(){return this._bufParams}},{key:"simplifyTolerance",value:function(t){return t*this._bufParams.getSimplifyFactor()}},{key:"getRingCurve",value:function(t,n,r){if(this._distance=r,t.length<=2)return this.getLineCurve(t,r);if(0===r)return e.copyCoordinates(t);var i=this.getSegGen(r);return this.computeRingBufferCurve(t,n,i),i.getCoordinates()}},{key:"computeOffsetCurve",value:function(t,e,n){var r=this.simplifyTolerance(this._distance);if(e){var i=Cn.simplify(t,-r),o=i.length-1;n.initSideSegments(i[o],i[o-1],tt.LEFT),n.addFirstSegment();for(var s=o-2;s>=0;s--)n.addNextSegment(i[s],!0)}else{var a=Cn.simplify(t,r),u=a.length-1;n.initSideSegments(a[0],a[1],tt.LEFT),n.addFirstSegment();for(var l=2;l<=u;l++)n.addNextSegment(a[l],!0)}n.addLastSegment()}},{key:"isLineOffsetEmpty",value:function(t){return 0===t||t<0&&!this._bufParams.isSingleSided()}},{key:"getSegGen",value:function(t){return new Rn(this._precisionModel,this._bufParams,t)}}],[{key:"constructor_",value:function(){this._distance=0,this._precisionModel=null,this._bufParams=null;var t=arguments[0],e=arguments[1];this._precisionModel=t,this._bufParams=e}},{key:"copyCoordinates",value:function(t){for(var e=new Array(t.length).fill(null),n=0;ni.getMaxY()||this.findStabbedSegments(t,r.getDirectedEdges(),e)}return e}if(3===arguments.length)if(ot(arguments[2],rt)&&arguments[0]instanceof z&&arguments[1]instanceof Ke){for(var o=arguments[0],s=arguments[1],a=arguments[2],u=s.getEdge().getCoordinates(),l=0;lthis._seg.p1.y&&this._seg.reverse(),!(Math.max(this._seg.p0.x,this._seg.p1.x)this._seg.p1.y||ft.index(this._seg.p0,this._seg.p1,o)===ft.RIGHT)){var h=s.getDepth(tt.LEFT);this._seg.p0.equals(u[l])||(h=s.getDepth(tt.RIGHT));var c=new Fn(this._seg,h);a.add(c)}}else if(ot(arguments[2],rt)&&arguments[0]instanceof z&&ot(arguments[1],rt))for(var f=arguments[0],g=arguments[2],p=arguments[1].iterator();p.hasNext();){var v=p.next();v.isForward()&&this.findStabbedSegments(f,v,g)}}},{key:"getDepth",value:function(t){var e=this.findStabbedSegments(t);return 0===e.size()?0:an.min(e)._leftDepth}}],[{key:"constructor_",value:function(){this._subgraphs=null,this._seg=new bn;var t=arguments[0];this._subgraphs=t}}]),e}(),Fn=function(){function e(){t(this,e),e.constructor_.apply(this,arguments)}return n(e,[{key:"compareTo",value:function(t){var e=t;if(this._upwardSeg.minX()>=e._upwardSeg.maxX())return 1;if(this._upwardSeg.maxX()<=e._upwardSeg.minX())return-1;var n=this._upwardSeg.orientationIndex(e._upwardSeg);return 0!==n||0!=(n=-1*e._upwardSeg.orientationIndex(this._upwardSeg))?n:this._upwardSeg.compareTo(e._upwardSeg)}},{key:"compareX",value:function(t,e){var n=t.p0.compareTo(e.p0);return 0!==n?n:t.p1.compareTo(e.p1)}},{key:"toString",value:function(){return this._upwardSeg.toString()}},{key:"interfaces_",get:function(){return[k]}}],[{key:"constructor_",value:function(){this._upwardSeg=null,this._leftDepth=null;var t=arguments[0],e=arguments[1];this._upwardSeg=new bn(t),this._leftDepth=e}}]),e}();Dn.DepthSegment=Fn;var qn=function(e){r(o,e);var i=c(o);function o(){var e;return t(this,o),e=i.call(this),o.constructor_.apply(l(e),arguments),e}return n(o,null,[{key:"constructor_",value:function(){_.constructor_.call(this,"Projective point not representable on the Cartesian plane.")}}]),o}(_),Vn=function(){function e(){t(this,e),e.constructor_.apply(this,arguments)}return n(e,[{key:"getY",value:function(){var t=this.y/this.w;if(A.isNaN(t)||A.isInfinite(t))throw new qn;return t}},{key:"getX",value:function(){var t=this.x/this.w;if(A.isNaN(t)||A.isInfinite(t))throw new qn;return t}},{key:"getCoordinate",value:function(){var t=new z;return t.x=this.getX(),t.y=this.getY(),t}}],[{key:"constructor_",value:function(){if(this.x=null,this.y=null,this.w=null,0===arguments.length)this.x=0,this.y=0,this.w=1;else if(1===arguments.length){var t=arguments[0];this.x=t.x,this.y=t.y,this.w=1}else if(2===arguments.length){if("number"==typeof arguments[0]&&"number"==typeof arguments[1]){var n=arguments[0],r=arguments[1];this.x=n,this.y=r,this.w=1}else if(arguments[0]instanceof e&&arguments[1]instanceof e){var i=arguments[0],o=arguments[1];this.x=i.y*o.w-o.y*i.w,this.y=o.x*i.w-i.x*o.w,this.w=i.x*o.y-o.x*i.y}else if(arguments[0]instanceof z&&arguments[1]instanceof z){var s=arguments[0],a=arguments[1];this.x=s.y-a.y,this.y=a.x-s.x,this.w=s.x*a.y-a.x*s.y}}else if(3===arguments.length){var u=arguments[0],l=arguments[1],h=arguments[2];this.x=u,this.y=l,this.w=h}else if(4===arguments.length){var c=arguments[0],f=arguments[1],g=arguments[2],p=arguments[3],v=c.y-f.y,d=f.x-c.x,y=c.x*f.y-f.x*c.y,m=g.y-p.y,_=p.x-g.x,x=g.x*p.y-p.x*g.y;this.x=d*x-_*y,this.y=m*y-v*x,this.w=v*_-m*d}}}]),e}(),Gn=function(){function e(){t(this,e),e.constructor_.apply(this,arguments)}return n(e,[{key:"area",value:function(){return e.area(this.p0,this.p1,this.p2)}},{key:"signedArea",value:function(){return e.signedArea(this.p0,this.p1,this.p2)}},{key:"interpolateZ",value:function(t){if(null===t)throw new x("Supplied point is null.");return e.interpolateZ(t,this.p0,this.p1,this.p2)}},{key:"longestSideLength",value:function(){return e.longestSideLength(this.p0,this.p1,this.p2)}},{key:"isAcute",value:function(){return e.isAcute(this.p0,this.p1,this.p2)}},{key:"circumcentre",value:function(){return e.circumcentre(this.p0,this.p1,this.p2)}},{key:"area3D",value:function(){return e.area3D(this.p0,this.p1,this.p2)}},{key:"centroid",value:function(){return e.centroid(this.p0,this.p1,this.p2)}},{key:"inCentre",value:function(){return e.inCentre(this.p0,this.p1,this.p2)}}],[{key:"constructor_",value:function(){this.p0=null,this.p1=null,this.p2=null;var t=arguments[0],e=arguments[1],n=arguments[2];this.p0=t,this.p1=e,this.p2=n}},{key:"area",value:function(t,e,n){return Math.abs(((n.x-t.x)*(e.y-t.y)-(e.x-t.x)*(n.y-t.y))/2)}},{key:"signedArea",value:function(t,e,n){return((n.x-t.x)*(e.y-t.y)-(e.x-t.x)*(n.y-t.y))/2}},{key:"det",value:function(t,e,n,r){return t*r-e*n}},{key:"interpolateZ",value:function(t,e,n,r){var i=e.x,o=e.y,s=n.x-i,a=r.x-i,u=n.y-o,l=r.y-o,h=s*l-a*u,c=t.x-i,f=t.y-o,g=(l*c-a*f)/h,p=(-u*c+s*f)/h;return e.getZ()+g*(n.getZ()-e.getZ())+p*(r.getZ()-e.getZ())}},{key:"longestSideLength",value:function(t,e,n){var r=t.distance(e),i=e.distance(n),o=n.distance(t),s=r;return i>s&&(s=i),o>s&&(s=o),s}},{key:"circumcentreDD",value:function(t,e,n){var r=lt.valueOf(t.x).subtract(n.x),i=lt.valueOf(t.y).subtract(n.y),o=lt.valueOf(e.x).subtract(n.x),s=lt.valueOf(e.y).subtract(n.y),a=lt.determinant(r,i,o,s).multiply(2),u=r.sqr().add(i.sqr()),l=o.sqr().add(s.sqr()),h=lt.determinant(i,u,s,l),c=lt.determinant(r,u,o,l),f=lt.valueOf(n.x).subtract(h.divide(a)).doubleValue(),g=lt.valueOf(n.y).add(c.divide(a)).doubleValue();return new z(f,g)}},{key:"isAcute",value:function(t,e,n){return!!On.isAcute(t,e,n)&&!!On.isAcute(e,n,t)&&!!On.isAcute(n,t,e)}},{key:"circumcentre",value:function(t,n,r){var i=r.x,o=r.y,s=t.x-i,a=t.y-o,u=n.x-i,l=n.y-o,h=2*e.det(s,a,u,l),c=e.det(a,s*s+a*a,l,u*u+l*l),f=e.det(s,s*s+a*a,u,u*u+l*l);return new z(i-c/h,o+f/h)}},{key:"perpendicularBisector",value:function(t,e){var n=e.x-t.x,r=e.y-t.y,i=new Vn(t.x+n/2,t.y+r/2,1),o=new Vn(t.x-r+n/2,t.y+n+r/2,1);return new Vn(i,o)}},{key:"angleBisector",value:function(t,e,n){var r=e.distance(t),i=r/(r+e.distance(n)),o=n.x-t.x,s=n.y-t.y;return new z(t.x+i*o,t.y+i*s)}},{key:"area3D",value:function(t,e,n){var r=e.x-t.x,i=e.y-t.y,o=e.getZ()-t.getZ(),s=n.x-t.x,a=n.y-t.y,u=n.getZ()-t.getZ(),l=i*u-o*a,h=o*s-r*u,c=r*a-i*s,f=l*l+h*h+c*c;return Math.sqrt(f)/2}},{key:"centroid",value:function(t,e,n){var r=(t.x+e.x+n.x)/3,i=(t.y+e.y+n.y)/3;return new z(r,i)}},{key:"inCentre",value:function(t,e,n){var r=e.distance(n),i=t.distance(n),o=t.distance(e),s=r+i+o,a=(r*t.x+i*e.x+o*n.x)/s,u=(r*t.y+i*e.y+o*n.y)/s;return new z(a,u)}}]),e}(),Bn=function(){function e(){t(this,e),e.constructor_.apply(this,arguments)}return n(e,[{key:"addRingSide",value:function(t,e,n,r,i){if(0===e&&t.length=zt.MINIMUM_VALID_SIZE&&ft.isCCW(t)&&(o=i,s=r,n=tt.opposite(n));var a=this._curveBuilder.getRingCurve(t,n,e);this.addCurve(a,o,s)}},{key:"addRingBothSides",value:function(t,e){this.addRingSide(t,e,tt.LEFT,Z.EXTERIOR,Z.INTERIOR),this.addRingSide(t,e,tt.RIGHT,Z.INTERIOR,Z.EXTERIOR)}},{key:"addPoint",value:function(t){if(this._distance<=0)return null;var e=t.getCoordinates(),n=this._curveBuilder.getLineCurve(e,this._distance);this.addCurve(n,Z.EXTERIOR,Z.INTERIOR)}},{key:"addPolygon",value:function(t){var e=this._distance,n=tt.LEFT;this._distance<0&&(e=-this._distance,n=tt.RIGHT);var r=t.getExteriorRing(),i=Wt.removeRepeatedPoints(r.getCoordinates());if(this._distance<0&&this.isErodedCompletely(r,this._distance))return null;if(this._distance<=0&&i.length<3)return null;this.addRingSide(i,e,n,Z.EXTERIOR,Z.INTERIOR);for(var o=0;o0&&this.isErodedCompletely(s,-this._distance)||this.addRingSide(a,e,tt.opposite(n),Z.INTERIOR,Z.EXTERIOR)}}},{key:"isTriangleErodedCompletely",value:function(t,e){var n=new Gn(t[0],t[1],t[2]),r=n.inCentre();return kt.pointToSegment(r,n.p0,n.p1)i}},{key:"addCollection",value:function(t){for(var e=0;e=this._max)throw new W;var t=this._parent.getGeometryN(this._index++);return t instanceof Bt?(this._subcollectionIterator=new e(t),this._subcollectionIterator.next()):t}},{key:"remove",value:function(){throw new J(this.getClass().getName())}},{key:"hasNext",value:function(){if(this._atStart)return!0;if(null!==this._subcollectionIterator){if(this._subcollectionIterator.hasNext())return!0;this._subcollectionIterator=null}return!(this._index>=this._max)}},{key:"interfaces_",get:function(){return[yn]}}],[{key:"constructor_",value:function(){this._parent=null,this._atStart=null,this._max=null,this._index=null,this._subcollectionIterator=null;var t=arguments[0];this._parent=t,this._atStart=!0,this._index=0,this._max=t.getNumGeometries()}},{key:"isAtomic",value:function(t){return!(t instanceof Bt)}}]),e}(),jn=function(){function e(){t(this,e),e.constructor_.apply(this,arguments)}return n(e,[{key:"locate",value:function(t){return e.locate(t,this._geom)}},{key:"interfaces_",get:function(){return[Yn]}}],[{key:"constructor_",value:function(){this._geom=null;var t=arguments[0];this._geom=t}},{key:"locatePointInPolygon",value:function(t,n){if(n.isEmpty())return Z.EXTERIOR;var r=n.getExteriorRing(),i=e.locatePointInRing(t,r);if(i!==Z.INTERIOR)return i;for(var o=0;o=0;n--){var r=this._edgeList.get(n),i=r.getSym();null===e&&(e=i),null!==t&&i.setNext(t),t=r}e.setNext(t)}},{key:"computeDepths",value:function(){if(1===arguments.length){var t=arguments[0],e=this.findIndex(t),n=t.getDepth(tt.LEFT),r=t.getDepth(tt.RIGHT),i=this.computeDepths(e+1,this._edgeList.size(),n);if(this.computeDepths(0,e,i)!==r)throw new pt("depth mismatch at "+t.getCoordinate())}else if(3===arguments.length){for(var o=arguments[1],s=arguments[2],a=arguments[0];a=0;i--){var o=this._resultAreaEdgeList.get(i),s=o.getSym();switch(null===e&&o.getEdgeRing()===t&&(e=o),r){case this._SCANNING_FOR_INCOMING:if(s.getEdgeRing()!==t)continue;n=s,r=this._LINKING_TO_OUTGOING;break;case this._LINKING_TO_OUTGOING:if(o.getEdgeRing()!==t)continue;n.setNextMin(o),r=this._SCANNING_FOR_INCOMING}}r===this._LINKING_TO_OUTGOING&&(V.isTrue(null!==e,"found null for first outgoing dirEdge"),V.isTrue(e.getEdgeRing()===t,"unable to link last incoming dirEdge"),n.setNextMin(e))}},{key:"getOutgoingDegree",value:function(){if(0===arguments.length){for(var t=0,e=this.iterator();e.hasNext();)e.next().isInResult()&&t++;return t}if(1===arguments.length){for(var n=arguments[0],r=0,i=this.iterator();i.hasNext();)i.next().getEdgeRing()===n&&r++;return r}}},{key:"getLabel",value:function(){return this._label}},{key:"findCoveredLineEdges",value:function(){for(var t=Z.NONE,e=this.iterator();e.hasNext();){var n=e.next(),r=n.getSym();if(!n.isLineEdge()){if(n.isInResult()){t=Z.INTERIOR;break}if(r.isInResult()){t=Z.EXTERIOR;break}}}if(t===Z.NONE)return null;for(var i=t,o=this.iterator();o.hasNext();){var s=o.next(),a=s.getSym();s.isLineEdge()?s.getEdge().setCovered(i===Z.INTERIOR):(s.isInResult()&&(i=Z.EXTERIOR),a.isInResult()&&(i=Z.INTERIOR))}}},{key:"computeLabelling",value:function(t){f(i(s.prototype),"computeLabelling",this).call(this,t),this._label=new Ae(Z.NONE);for(var e=this.iterator();e.hasNext();)for(var n=e.next().getEdge().getLabel(),r=0;r<2;r++){var o=n.getLocation(r);o!==Z.INTERIOR&&o!==Z.BOUNDARY||this._label.setLocation(r,Z.INTERIOR)}}}],[{key:"constructor_",value:function(){this._resultAreaEdgeList=null,this._label=null,this._SCANNING_FOR_INCOMING=1,this._LINKING_TO_OUTGOING=2}}]),s}(Xn),Zn=function(e){r(o,e);var i=c(o);function o(){return t(this,o),i.call(this)}return n(o,[{key:"createNode",value:function(t){return new Ge(t,new Un)}}]),o}(Qe),Hn=function(){function e(){t(this,e),e.constructor_.apply(this,arguments)}return n(e,[{key:"compareTo",value:function(t){var n=t;return e.compareOriented(this._pts,this._orientation,n._pts,n._orientation)}},{key:"interfaces_",get:function(){return[k]}}],[{key:"constructor_",value:function(){this._pts=null,this._orientation=null;var t=arguments[0];this._pts=t,this._orientation=e.orientation(t)}},{key:"orientation",value:function(t){return 1===Wt.increasingDirection(t)}},{key:"compareOriented",value:function(t,e,n,r){for(var i=e?1:-1,o=r?1:-1,s=e?t.length:-1,a=r?n.length:-1,u=e?0:t.length-1,l=r?0:n.length-1;;){var h=t[u].compareTo(n[l]);if(0!==h)return h;var c=(u+=i)===s,f=(l+=o)===a;if(c&&!f)return-1;if(!c&&f)return 1;if(c&&f)return 0}}}]),e}(),Wn=function(){function e(){t(this,e),e.constructor_.apply(this,arguments)}return n(e,[{key:"print",value:function(t){t.print("MULTILINESTRING ( ");for(var e=0;e0&&t.print(","),t.print("(");for(var r=n.getCoordinates(),i=0;i0&&t.print(","),t.print(r[i].x+" "+r[i].y);t.println(")")}t.print(") ")}},{key:"addAll",value:function(t){for(var e=t.iterator();e.hasNext();)this.add(e.next())}},{key:"findEdgeIndex",value:function(t){for(var e=0;et?1:this.diste?1:0}},{key:"interfaces_",get:function(){return[k]}}],[{key:"constructor_",value:function(){this.coord=null,this.segmentIndex=null,this.dist=null;var t=arguments[0],e=arguments[1],n=arguments[2];this.coord=new z(t),this.segmentIndex=e,this.dist=n}}]),e}(),$n=function(){function e(){t(this,e),e.constructor_.apply(this,arguments)}return n(e,[{key:"print",value:function(t){t.println("Intersections:");for(var e=this.iterator();e.hasNext();)e.next().print(t)}},{key:"iterator",value:function(){return this._nodeMap.values().iterator()}},{key:"addSplitEdges",value:function(t){this.addEndpoints();for(var e=this.iterator(),n=e.next();e.hasNext();){var r=e.next(),i=this.createSplitEdge(n,r);t.add(i),n=r}}},{key:"addEndpoints",value:function(){var t=this.edge.pts.length-1;this.add(this.edge.pts[0],0,0),this.add(this.edge.pts[t],t,0)}},{key:"createSplitEdge",value:function(t,e){var n=e.segmentIndex-t.segmentIndex+2,r=this.edge.pts[e.segmentIndex],i=e.dist>0||!e.coord.equals2D(r);i||n--;var o=new Array(n).fill(null),s=0;o[s++]=new z(t.coord);for(var a=t.segmentIndex+1;a<=e.segmentIndex;a++)o[s++]=this.edge.pts[a];return i&&(o[s]=e.coord),new or(o,new Ae(this.edge._label))}},{key:"add",value:function(t,e,n){var r=new Qn(t,e,n),i=this._nodeMap.get(r);return null!==i?i:(this._nodeMap.put(r,r),r)}},{key:"isIntersection",value:function(t){for(var e=this.iterator();e.hasNext();)if(e.next().coord.equals(t))return!0;return!1}}],[{key:"constructor_",value:function(){this._nodeMap=new Ze,this.edge=null;var t=arguments[0];this.edge=t}}]),e}(),tr=function(){function e(){t(this,e),e.constructor_.apply(this,arguments)}return n(e,[{key:"isIntersects",value:function(){return!this.isDisjoint()}},{key:"isCovers",value:function(){return(e.isTrue(this._matrix[Z.INTERIOR][Z.INTERIOR])||e.isTrue(this._matrix[Z.INTERIOR][Z.BOUNDARY])||e.isTrue(this._matrix[Z.BOUNDARY][Z.INTERIOR])||e.isTrue(this._matrix[Z.BOUNDARY][Z.BOUNDARY]))&&this._matrix[Z.EXTERIOR][Z.INTERIOR]===Mt.FALSE&&this._matrix[Z.EXTERIOR][Z.BOUNDARY]===Mt.FALSE}},{key:"isCoveredBy",value:function(){return(e.isTrue(this._matrix[Z.INTERIOR][Z.INTERIOR])||e.isTrue(this._matrix[Z.INTERIOR][Z.BOUNDARY])||e.isTrue(this._matrix[Z.BOUNDARY][Z.INTERIOR])||e.isTrue(this._matrix[Z.BOUNDARY][Z.BOUNDARY]))&&this._matrix[Z.INTERIOR][Z.EXTERIOR]===Mt.FALSE&&this._matrix[Z.BOUNDARY][Z.EXTERIOR]===Mt.FALSE}},{key:"set",value:function(){if(1===arguments.length)for(var t=arguments[0],e=0;e=0&&e>=0&&this.setAtLeast(t,e,n)}},{key:"isWithin",value:function(){return e.isTrue(this._matrix[Z.INTERIOR][Z.INTERIOR])&&this._matrix[Z.INTERIOR][Z.EXTERIOR]===Mt.FALSE&&this._matrix[Z.BOUNDARY][Z.EXTERIOR]===Mt.FALSE}},{key:"isTouches",value:function(t,n){return t>n?this.isTouches(n,t):(t===Mt.A&&n===Mt.A||t===Mt.L&&n===Mt.L||t===Mt.L&&n===Mt.A||t===Mt.P&&n===Mt.A||t===Mt.P&&n===Mt.L)&&this._matrix[Z.INTERIOR][Z.INTERIOR]===Mt.FALSE&&(e.isTrue(this._matrix[Z.INTERIOR][Z.BOUNDARY])||e.isTrue(this._matrix[Z.BOUNDARY][Z.INTERIOR])||e.isTrue(this._matrix[Z.BOUNDARY][Z.BOUNDARY]))}},{key:"isOverlaps",value:function(t,n){return t===Mt.P&&n===Mt.P||t===Mt.A&&n===Mt.A?e.isTrue(this._matrix[Z.INTERIOR][Z.INTERIOR])&&e.isTrue(this._matrix[Z.INTERIOR][Z.EXTERIOR])&&e.isTrue(this._matrix[Z.EXTERIOR][Z.INTERIOR]):t===Mt.L&&n===Mt.L&&1===this._matrix[Z.INTERIOR][Z.INTERIOR]&&e.isTrue(this._matrix[Z.INTERIOR][Z.EXTERIOR])&&e.isTrue(this._matrix[Z.EXTERIOR][Z.INTERIOR])}},{key:"isEquals",value:function(t,n){return t===n&&e.isTrue(this._matrix[Z.INTERIOR][Z.INTERIOR])&&this._matrix[Z.INTERIOR][Z.EXTERIOR]===Mt.FALSE&&this._matrix[Z.BOUNDARY][Z.EXTERIOR]===Mt.FALSE&&this._matrix[Z.EXTERIOR][Z.INTERIOR]===Mt.FALSE&&this._matrix[Z.EXTERIOR][Z.BOUNDARY]===Mt.FALSE}},{key:"toString",value:function(){for(var t=new Qt("123456789"),e=0;e<3;e++)for(var n=0;n<3;n++)t.setCharAt(3*e+n,Mt.toDimensionSymbol(this._matrix[e][n]));return t.toString()}},{key:"setAll",value:function(t){for(var e=0;e<3;e++)for(var n=0;n<3;n++)this._matrix[e][n]=t}},{key:"get",value:function(t,e){return this._matrix[t][e]}},{key:"transpose",value:function(){var t=this._matrix[1][0];return this._matrix[1][0]=this._matrix[0][1],this._matrix[0][1]=t,t=this._matrix[2][0],this._matrix[2][0]=this._matrix[0][2],this._matrix[0][2]=t,t=this._matrix[2][1],this._matrix[2][1]=this._matrix[1][2],this._matrix[1][2]=t,this}},{key:"matches",value:function(t){if(9!==t.length)throw new x("Should be length 9: "+t);for(var n=0;n<3;n++)for(var r=0;r<3;r++)if(!e.matches(this._matrix[n][r],t.charAt(3*n+r)))return!1;return!0}},{key:"add",value:function(t){for(var e=0;e<3;e++)for(var n=0;n<3;n++)this.setAtLeast(e,n,t.get(e,n))}},{key:"isDisjoint",value:function(){return this._matrix[Z.INTERIOR][Z.INTERIOR]===Mt.FALSE&&this._matrix[Z.INTERIOR][Z.BOUNDARY]===Mt.FALSE&&this._matrix[Z.BOUNDARY][Z.INTERIOR]===Mt.FALSE&&this._matrix[Z.BOUNDARY][Z.BOUNDARY]===Mt.FALSE}},{key:"isCrosses",value:function(t,n){return t===Mt.P&&n===Mt.L||t===Mt.P&&n===Mt.A||t===Mt.L&&n===Mt.A?e.isTrue(this._matrix[Z.INTERIOR][Z.INTERIOR])&&e.isTrue(this._matrix[Z.INTERIOR][Z.EXTERIOR]):t===Mt.L&&n===Mt.P||t===Mt.A&&n===Mt.P||t===Mt.A&&n===Mt.L?e.isTrue(this._matrix[Z.INTERIOR][Z.INTERIOR])&&e.isTrue(this._matrix[Z.EXTERIOR][Z.INTERIOR]):t===Mt.L&&n===Mt.L&&0===this._matrix[Z.INTERIOR][Z.INTERIOR]}},{key:"interfaces_",get:function(){return[b]}}],[{key:"constructor_",value:function(){if(this._matrix=null,0===arguments.length)this._matrix=Array(3).fill().map((function(){return Array(3)})),this.setAll(Mt.FALSE);else if(1===arguments.length)if("string"==typeof arguments[0]){var t=arguments[0];e.constructor_.call(this),this.set(t)}else if(arguments[0]instanceof e){var n=arguments[0];e.constructor_.call(this),this._matrix[Z.INTERIOR][Z.INTERIOR]=n._matrix[Z.INTERIOR][Z.INTERIOR],this._matrix[Z.INTERIOR][Z.BOUNDARY]=n._matrix[Z.INTERIOR][Z.BOUNDARY],this._matrix[Z.INTERIOR][Z.EXTERIOR]=n._matrix[Z.INTERIOR][Z.EXTERIOR],this._matrix[Z.BOUNDARY][Z.INTERIOR]=n._matrix[Z.BOUNDARY][Z.INTERIOR],this._matrix[Z.BOUNDARY][Z.BOUNDARY]=n._matrix[Z.BOUNDARY][Z.BOUNDARY],this._matrix[Z.BOUNDARY][Z.EXTERIOR]=n._matrix[Z.BOUNDARY][Z.EXTERIOR],this._matrix[Z.EXTERIOR][Z.INTERIOR]=n._matrix[Z.EXTERIOR][Z.INTERIOR],this._matrix[Z.EXTERIOR][Z.BOUNDARY]=n._matrix[Z.EXTERIOR][Z.BOUNDARY],this._matrix[Z.EXTERIOR][Z.EXTERIOR]=n._matrix[Z.EXTERIOR][Z.EXTERIOR]}}},{key:"matches",value:function(){if(Number.isInteger(arguments[0])&&"string"==typeof arguments[1]){var t=arguments[0],n=arguments[1];return n===Mt.SYM_DONTCARE||n===Mt.SYM_TRUE&&(t>=0||t===Mt.TRUE)||n===Mt.SYM_FALSE&&t===Mt.FALSE||n===Mt.SYM_P&&t===Mt.P||n===Mt.SYM_L&&t===Mt.L||n===Mt.SYM_A&&t===Mt.A}if("string"==typeof arguments[0]&&"string"==typeof arguments[1]){var r=arguments[1];return new e(arguments[0]).matches(r)}}},{key:"isTrue",value:function(t){return t>=0||t===Mt.TRUE}}]),e}(),er=function(){function e(){t(this,e),e.constructor_.apply(this,arguments)}return n(e,[{key:"size",value:function(){return this._size}},{key:"addAll",value:function(t){return null===t||0===t.length?null:(this.ensureCapacity(this._size+t.length),xt.arraycopy(t,0,this._data,this._size,t.length),void(this._size+=t.length))}},{key:"ensureCapacity",value:function(t){if(t<=this._data.length)return null;var e=Math.max(t,2*this._data.length);this._data=At.copyOf(this._data,e)}},{key:"toArray",value:function(){var t=new Array(this._size).fill(null);return xt.arraycopy(this._data,0,t,0,this._size),t}},{key:"add",value:function(t){this.ensureCapacity(this._size+1),this._data[this._size]=t,++this._size}}],[{key:"constructor_",value:function(){if(this._data=null,this._size=0,0===arguments.length)e.constructor_.call(this,10);else if(1===arguments.length){var t=arguments[0];this._data=new Array(t).fill(null)}}}]),e}(),nr=function(){function e(){t(this,e)}return n(e,[{key:"getChainStartIndices",value:function(t){var e=0,n=new er(Math.trunc(t.length/2));n.add(e);do{var r=this.findChainEnd(t,e);n.add(r),e=r}while(en?e:n}},{key:"getMinX",value:function(t){var e=this.pts[this.startIndex[t]].x,n=this.pts[this.startIndex[t+1]].x;return ee&&(r=1),this._depth[t][n]=r}}}},{key:"getDelta",value:function(t){return this._depth[t][tt.RIGHT]-this._depth[t][tt.LEFT]}},{key:"getLocation",value:function(t,e){return this._depth[t][e]<=0?Z.EXTERIOR:Z.INTERIOR}},{key:"toString",value:function(){return"A: "+this._depth[0][1]+","+this._depth[0][2]+" B: "+this._depth[1][1]+","+this._depth[1][2]}},{key:"add",value:function(){if(1===arguments.length)for(var t=arguments[0],n=0;n<2;n++)for(var r=1;r<3;r++){var i=t.getLocation(n,r);i!==Z.EXTERIOR&&i!==Z.INTERIOR||(this.isNull(n,r)?this._depth[n][r]=e.depthAtLocation(i):this._depth[n][r]+=e.depthAtLocation(i))}else if(3===arguments.length){var o=arguments[0],s=arguments[1];arguments[2]===Z.INTERIOR&&this._depth[o][s]++}}}],[{key:"constructor_",value:function(){this._depth=Array(2).fill().map((function(){return Array(3)}));for(var t=0;t<2;t++)for(var n=0;n<3;n++)this._depth[t][n]=e.NULL_VALUE}},{key:"depthAtLocation",value:function(t){return t===Z.EXTERIOR?0:t===Z.INTERIOR?1:e.NULL_VALUE}}]),e}();ir.NULL_VALUE=-1;var or=function(e){r(s,e);var o=c(s);function s(){var e;return t(this,s),e=o.call(this),s.constructor_.apply(l(e),arguments),e}return n(s,[{key:"getDepth",value:function(){return this._depth}},{key:"getCollapsedEdge",value:function(){var t=new Array(2).fill(null);return t[0]=this.pts[0],t[1]=this.pts[1],new s(t,Ae.toLineLabel(this._label))}},{key:"isIsolated",value:function(){return this._isIsolated}},{key:"getCoordinates",value:function(){return this.pts}},{key:"setIsolated",value:function(t){this._isIsolated=t}},{key:"setName",value:function(t){this._name=t}},{key:"equals",value:function(t){if(!(t instanceof s))return!1;var e=t;if(this.pts.length!==e.pts.length)return!1;for(var n=!0,r=!0,i=this.pts.length,o=0;o0?this.pts[0]:null;if(1===arguments.length){var t=arguments[0];return this.pts[t]}}},{key:"print",value:function(t){t.print("edge "+this._name+": "),t.print("LINESTRING (");for(var e=0;e0&&t.print(","),t.print(this.pts[e].x+" "+this.pts[e].y);t.print(") "+this._label+" "+this._depthDelta)}},{key:"computeIM",value:function(t){s.updateIM(this._label,t)}},{key:"isCollapsed",value:function(){return!!this._label.isArea()&&3===this.pts.length&&!!this.pts[0].equals(this.pts[2])}},{key:"isClosed",value:function(){return this.pts[0].equals(this.pts[this.pts.length-1])}},{key:"getMaximumSegmentIndex",value:function(){return this.pts.length-1}},{key:"getDepthDelta",value:function(){return this._depthDelta}},{key:"getNumPoints",value:function(){return this.pts.length}},{key:"printReverse",value:function(t){t.print("edge "+this._name+": ");for(var e=this.pts.length-1;e>=0;e--)t.print(this.pts[e]+" ");t.println("")}},{key:"getMonotoneChainEdge",value:function(){return null===this._mce&&(this._mce=new rr(this)),this._mce}},{key:"getEnvelope",value:function(){if(null===this._env){this._env=new X;for(var t=0;t0&&t.append(","),t.append(this.pts[e].x+" "+this.pts[e].y);return t.append(") "+this._label+" "+this._depthDelta),t.toString()}},{key:"isPointwiseEqual",value:function(t){if(this.pts.length!==t.pts.length)return!1;for(var e=0;er||this._maxyo;if(s)return!1;var a=this.intersectsToleranceSquare(t,e);return V.isTrue(!(s&&a),"Found bad envelope test"),a}},{key:"initCorners",value:function(t){var e=.5;this._minx=t.x-e,this._maxx=t.x+e,this._miny=t.y-e,this._maxy=t.y+e,this._corner[0]=new z(this._maxx,this._maxy),this._corner[1]=new z(this._minx,this._maxy),this._corner[2]=new z(this._minx,this._miny),this._corner[3]=new z(this._maxx,this._miny)}},{key:"intersects",value:function(t,e){return 1===this._scaleFactor?this.intersectsScaled(t,e):(this.copyScaled(t,this._p0Scaled),this.copyScaled(e,this._p1Scaled),this.intersectsScaled(this._p0Scaled,this._p1Scaled))}},{key:"scale",value:function(t){return Math.round(t*this._scaleFactor)}},{key:"getCoordinate",value:function(){return this._originalPt}},{key:"copyScaled",value:function(t,e){e.x=this.scale(t.x),e.y=this.scale(t.y)}},{key:"getSafeEnvelope",value:function(){if(null===this._safeEnv){var t=e.SAFE_ENV_EXPANSION_FACTOR/this._scaleFactor;this._safeEnv=new X(this._originalPt.x-t,this._originalPt.x+t,this._originalPt.y-t,this._originalPt.y+t)}return this._safeEnv}},{key:"intersectsPixelClosure",value:function(t,e){return this._li.computeIntersection(t,e,this._corner[0],this._corner[1]),!!(this._li.hasIntersection()||(this._li.computeIntersection(t,e,this._corner[1],this._corner[2]),this._li.hasIntersection()||(this._li.computeIntersection(t,e,this._corner[2],this._corner[3]),this._li.hasIntersection()||(this._li.computeIntersection(t,e,this._corner[3],this._corner[0]),this._li.hasIntersection()))))}},{key:"intersectsToleranceSquare",value:function(t,e){var n=!1,r=!1;return this._li.computeIntersection(t,e,this._corner[0],this._corner[1]),!!(this._li.isProper()||(this._li.computeIntersection(t,e,this._corner[1],this._corner[2]),this._li.isProper()||(this._li.hasIntersection()&&(n=!0),this._li.computeIntersection(t,e,this._corner[2],this._corner[3]),this._li.isProper()||(this._li.hasIntersection()&&(r=!0),this._li.computeIntersection(t,e,this._corner[3],this._corner[0]),this._li.isProper()||n&&r||t.equals(this._pt)||e.equals(this._pt)))))}},{key:"addSnappedNode",value:function(t,e){var n=t.getCoordinate(e),r=t.getCoordinate(e+1);return!!this.intersects(n,r)&&(t.addIntersection(this.getCoordinate(),e),!0)}}],[{key:"constructor_",value:function(){this._li=null,this._pt=null,this._originalPt=null,this._ptScaled=null,this._p0Scaled=null,this._p1Scaled=null,this._scaleFactor=null,this._minx=null,this._maxx=null,this._miny=null,this._maxy=null,this._corner=new Array(4).fill(null),this._safeEnv=null;var t=arguments[0],e=arguments[1],n=arguments[2];if(this._originalPt=t,this._pt=t,this._scaleFactor=e,this._li=n,e<=0)throw new x("Scale factor must be non-zero");1!==e&&(this._pt=new z(this.scale(t.x),this.scale(t.y)),this._p0Scaled=new z,this._p1Scaled=new z),this.initCorners(this._pt)}}]),e}();lr.SAFE_ENV_EXPANSION_FACTOR=.75;var hr=function(){function e(){t(this,e),e.constructor_.apply(this,arguments)}return n(e,[{key:"select",value:function(){if(1===arguments.length);else if(2===arguments.length){var t=arguments[1];arguments[0].getLineSegment(t,this.selectedSegment),this.select(this.selectedSegment)}}}],[{key:"constructor_",value:function(){this.selectedSegment=new bn}}]),e}(),cr=function(){function e(){t(this,e),e.constructor_.apply(this,arguments)}return n(e,[{key:"snap",value:function(){if(1===arguments.length){var e=arguments[0];return this.snap(e,null,-1)}if(3===arguments.length){var r=arguments[0],i=arguments[1],o=arguments[2],s=r.getSafeEnvelope(),a=new fr(r,i,o);return this._index.query(s,new(function(){function e(){t(this,e)}return n(e,[{key:"interfaces_",get:function(){return[hn]}},{key:"visitItem",value:function(t){t.select(s,a)}}]),e}())),a.isNodeAdded()}}}],[{key:"constructor_",value:function(){this._index=null;var t=arguments[0];this._index=t}}]),e}(),fr=function(e){r(s,e);var o=c(s);function s(){var e;return t(this,s),e=o.call(this),s.constructor_.apply(l(e),arguments),e}return n(s,[{key:"isNodeAdded",value:function(){return this._isNodeAdded}},{key:"select",value:function(){if(!(2===arguments.length&&Number.isInteger(arguments[1])&&arguments[0]instanceof In))return f(i(s.prototype),"select",this).apply(this,arguments);var t=arguments[1],e=arguments[0].getContext();if(this._parentEdge===e&&(t===this._hotPixelVertexIndex||t+1===this._hotPixelVertexIndex))return null;this._isNodeAdded|=this._hotPixel.addSnappedNode(e,t)}}],[{key:"constructor_",value:function(){this._hotPixel=null,this._parentEdge=null,this._hotPixelVertexIndex=null,this._isNodeAdded=!1;var t=arguments[0],e=arguments[1],n=arguments[2];this._hotPixel=t,this._parentEdge=e,this._hotPixelVertexIndex=n}}]),s}(hr);cr.HotPixelSnapAction=fr;var gr=function(){function e(){t(this,e),e.constructor_.apply(this,arguments)}return n(e,[{key:"processIntersections",value:function(t,e,n,r){if(t===n&&e===r)return null;var i=t.getCoordinates()[e],o=t.getCoordinates()[e+1],s=n.getCoordinates()[r],a=n.getCoordinates()[r+1];if(this._li.computeIntersection(i,o,s,a),this._li.hasIntersection()&&this._li.isInteriorIntersection()){for(var u=0;u=0;t--){try{this.bufferReducedPrecision(t)}catch(t){if(!(t instanceof pt))throw t;this._saveException=t}if(null!==this._resultGeometry)return null}throw this._saveException}if(1===arguments.length){var n=arguments[0],r=e.precisionScaleFactor(this._argGeom,this._distance,n),i=new ie(r);this.bufferFixedPrecision(i)}}},{key:"computeGeometry",value:function(){if(this.bufferOriginalPrecision(),null!==this._resultGeometry)return null;var t=this._argGeom.getFactory().getPrecisionModel();t.getType()===ie.FIXED?this.bufferFixedPrecision(t):this.bufferReducedPrecision()}},{key:"setQuadrantSegments",value:function(t){this._bufParams.setQuadrantSegments(t)}},{key:"bufferOriginalPrecision",value:function(){try{var t=new sr(this._bufParams);this._resultGeometry=t.buffer(this._argGeom,this._distance)}catch(t){if(!(t instanceof F))throw t;this._saveException=t}}},{key:"getResultGeometry",value:function(t){return this._distance=t,this.computeGeometry(),this._resultGeometry}},{key:"setEndCapStyle",value:function(t){this._bufParams.setEndCapStyle(t)}}],[{key:"constructor_",value:function(){if(this._argGeom=null,this._distance=null,this._bufParams=new y,this._resultGeometry=null,this._saveException=null,1===arguments.length){var t=arguments[0];this._argGeom=t}else if(2===arguments.length){var e=arguments[0],n=arguments[1];this._argGeom=e,this._bufParams=n}}},{key:"bufferOp",value:function(){if(2===arguments.length){var t=arguments[1];return new e(arguments[0]).getResultGeometry(t)}if(3===arguments.length){if(Number.isInteger(arguments[2])&&arguments[0]instanceof U&&"number"==typeof arguments[1]){var n=arguments[1],r=arguments[2],i=new e(arguments[0]);return i.setQuadrantSegments(r),i.getResultGeometry(n)}if(arguments[2]instanceof y&&arguments[0]instanceof U&&"number"==typeof arguments[1]){var o=arguments[1];return new e(arguments[0],arguments[2]).getResultGeometry(o)}}else if(4===arguments.length){var s=arguments[1],a=arguments[2],u=arguments[3],l=new e(arguments[0]);return l.setQuadrantSegments(a),l.setEndCapStyle(u),l.getResultGeometry(s)}}},{key:"precisionScaleFactor",value:function(t,e,n){var r=t.getEnvelopeInternal(),i=Et.max(Math.abs(r.getMaxX()),Math.abs(r.getMaxY()),Math.abs(r.getMinX()),Math.abs(r.getMinY()))+2*(e>0?e:0),o=n-Math.trunc(Math.log(i)/Math.log(10)+1);return Math.pow(10,o)}}]),e}();vr.CAP_ROUND=y.CAP_ROUND,vr.CAP_BUTT=y.CAP_FLAT,vr.CAP_FLAT=y.CAP_FLAT,vr.CAP_SQUARE=y.CAP_SQUARE,vr.MAX_PRECISION_DIGITS=12;var dr=["Point","MultiPoint","LineString","MultiLineString","Polygon","MultiPolygon"],yr=function(){function e(n){t(this,e),this.geometryFactory=n||new ae}return n(e,[{key:"read",value:function(t){var e,n=(e="string"==typeof t?JSON.parse(t):t).type;if(!mr[n])throw new Error("Unknown GeoJSON type: "+e.type);return-1!==dr.indexOf(n)?mr[n].call(this,e.coordinates):"GeometryCollection"===n?mr[n].call(this,e.geometries):mr[n].call(this,e)}},{key:"write",value:function(t){var e=t.getGeometryType();if(!_r[e])throw new Error("Geometry is not supported");return _r[e].call(this,t)}}]),e}(),mr={Feature:function(t){var e={};for(var n in t)e[n]=t[n];if(t.geometry){var r=t.geometry.type;if(!mr[r])throw new Error("Unknown GeoJSON type: "+t.type);e.geometry=this.read(t.geometry)}return t.bbox&&(e.bbox=mr.bbox.call(this,t.bbox)),e},FeatureCollection:function(t){var e={};if(t.features){e.features=[];for(var n=0;n1?0:t<-1?Xn:Math.acos(t)}function ir(t){return t>1?Un:t<-1?-Un:Math.asin(t)}function or(){}function sr(t,e){t&&ur.hasOwnProperty(t.type)&&ur[t.type](t,e)}var ar={Feature:function(t,e){sr(t.geometry,e)},FeatureCollection:function(t,e){for(var n=t.features,r=-1,i=n.length;++rXn?t-Hn:t<-Xn?t+Hn:t,e]}function xr(t){return function(e,n){return[(e+=t)>Xn?e-Hn:e<-Xn?e+Hn:e,n]}}function Er(t){var e=xr(t);return e.invert=xr(-t),e}function kr(t,e){var n=tr(t),r=er(t),i=tr(e),o=er(e);function s(t,e){var s=tr(e),a=tr(t)*s,u=er(t)*s,l=er(e),h=l*n+a*r;return[$n(u*i-h*o,a*n-l*r),ir(h*i+u*o)]}return s.invert=function(t,e){var s=tr(e),a=tr(t)*s,u=er(t)*s,l=er(e),h=l*i-u*o;return[$n(u*i+l*o,a*n+h*r),ir(h*n-a*r)]},s}function br(t,e){(e=fr(e))[0]-=t,yr(e);var n=rr(-e[1]);return((-e[2]<0?-n:n)+Hn-jn)%Hn}function wr(){var t,e=[];return{point:function(e,n){t.push([e,n])},lineStart:function(){e.push(t=[])},lineEnd:or,rejoin:function(){e.length>1&&e.push(e.pop().concat(e.shift()))},result:function(){var n=e;return e=[],t=null,n}}}function Ir(t,e){return Kn(t[0]-e[0])=0;--o)i.point((h=l[o])[0],h[1]);else r(f.x,f.p.x,-1,i);f=f.p}l=(f=f.o).z,g=!g}while(!f.v);i.lineEnd()}}}function Mr(t){if(e=t.length){for(var e,n,r=0,i=t[0];++re?1:t>=e?0:NaN}function Pr(t){for(var e,n,r,i=t.length,o=-1,s=0;++o=0;)for(e=(r=t[i]).length;--e>=0;)n[--s]=r[e];return n}Gn(),Gn(),Gn(),_r.invert=_r,function(t){var e;1===t.length&&(e=t,t=function(t,n){return Lr(e(t),n)})}(Lr);var Cr=1e9,Tr=-Cr;function Or(t,e,n,r){function i(i,o){return t<=i&&i<=n&&e<=o&&o<=r}function o(i,o,a,l){var h=0,c=0;if(null==i||(h=s(i,a))!==(c=s(o,a))||u(i,o)<0^a>0)do{l.point(0===h||3===h?t:n,h>1?r:e)}while((h=(h+a+4)%4)!==c);else l.point(o[0],o[1])}function s(r,i){return Kn(r[0]-t)0?0:3:Kn(r[0]-n)0?2:1:Kn(r[1]-e)0?1:0:i>0?3:2}function a(t,e){return u(t.x,e.x)}function u(t,e){var n=s(t,1),r=s(e,1);return n!==r?n-r:0===n?e[1]-t[1]:1===n?t[0]-e[0]:2===n?t[1]-e[1]:e[0]-t[0]}return function(s){var u,l,h,c,f,g,p,v,d,y,m,_=s,x=wr(),E={point:k,lineStart:function(){E.point=b,l&&l.push(h=[]);y=!0,d=!1,p=v=NaN},lineEnd:function(){u&&(b(c,f),g&&d&&x.rejoin(),u.push(x.result()));E.point=k,d&&_.lineEnd()},polygonStart:function(){_=x,u=[],l=[],m=!0},polygonEnd:function(){var e=function(){for(var e=0,n=0,i=l.length;nr&&(f-o)*(r-s)>(g-s)*(t-o)&&++e:g<=r&&(f-o)*(r-s)<(g-s)*(t-o)&&--e;return e}(),n=m&&e,i=(u=Pr(u)).length;(n||i)&&(s.polygonStart(),n&&(s.lineStart(),o(null,null,1,s),s.lineEnd()),i&&Sr(u,a,e,o,s),s.polygonEnd());_=s,u=l=h=null}};function k(t,e){i(t,e)&&_.point(t,e)}function b(o,s){var a=i(o,s);if(l&&h.push([o,s]),y)c=o,f=s,g=a,y=!1,a&&(_.lineStart(),_.point(o,s));else if(a&&d)_.point(o,s);else{var u=[p=Math.max(Tr,Math.min(Cr,p)),v=Math.max(Tr,Math.min(Cr,v))],x=[o=Math.max(Tr,Math.min(Cr,o)),s=Math.max(Tr,Math.min(Cr,s))];!function(t,e,n,r,i,o){var s,a=t[0],u=t[1],l=0,h=1,c=e[0]-a,f=e[1]-u;if(s=n-a,c||!(s>0)){if(s/=c,c<0){if(s0){if(s>h)return;s>l&&(l=s)}if(s=i-a,c||!(s<0)){if(s/=c,c<0){if(s>h)return;s>l&&(l=s)}else if(c>0){if(s0)){if(s/=f,f<0){if(s0){if(s>h)return;s>l&&(l=s)}if(s=o-u,f||!(s<0)){if(s/=f,f<0){if(s>h)return;s>l&&(l=s)}else if(f>0){if(s0&&(t[0]=a+l*c,t[1]=u+l*f),h<1&&(e[0]=a+h*c,e[1]=u+h*f),!0}}}}}(u,x,t,e,n,r)?a&&(_.lineStart(),_.point(o,s),m=!1):(d||(_.lineStart(),_.point(u[0],u[1])),_.point(x[0],x[1]),a||_.lineEnd(),m=!1)}p=o,v=s,d=a}return E}}var Rr=Gn();function Ar(t){return t}Gn(),Gn(),Gn();var Dr=1/0,Fr=Dr,qr=-Dr,Vr=qr,Gr={point:function(t,e){tqr&&(qr=t);eVr&&(Vr=e)},lineStart:or,lineEnd:or,polygonStart:or,polygonEnd:or,result:function(){var t=[[Dr,Fr],[qr,Vr]];return qr=Vr=-(Fr=Dr=1/0),t}};function Br(t,e,n,r){return function(i,o){var s,a,u,l=e(o),h=i.invert(r[0],r[1]),c=wr(),f=e(c),g=!1,p={point:v,lineStart:y,lineEnd:m,polygonStart:function(){p.point=_,p.lineStart=x,p.lineEnd=E,a=[],s=[]},polygonEnd:function(){p.point=v,p.lineStart=y,p.lineEnd=m,a=Pr(a);var t=function(t,e){var n=e[0],r=e[1],i=[er(n),-tr(n),0],o=0,s=0;Rr.reset();for(var a=0,u=t.length;a=0?1:-1,w=b*k,I=w>Xn,N=p*x;if(Rr.add($n(N*b*er(w),v*E+N*tr(w))),o+=I?k+b*Hn:k,I^f>=n^m>=n){var S=pr(fr(c),fr(y));yr(S);var M=pr(i,S);yr(M);var L=(I^k>=0?-1:1)*ir(M[2]);(r>L||r===L&&(S[0]||S[1]))&&(s+=I^k>=0?1:-1)}}return(o<-jn||o0){for(g||(o.polygonStart(),g=!0),o.lineStart(),t=0;t1&&2&i&&l.push(l.pop().concat(l.shift())),a.push(l.filter(Yr))}return p}}function Yr(t){return t.length>1}function zr(t,e){return((t=t.x)[0]<0?t[1]-Un-jn:Un-t[1])-((e=e.x)[0]<0?e[1]-Un-jn:Un-e[1])}Gn();var jr=Br((function(){return!0}),(function(t){var e,n=NaN,r=NaN,i=NaN;return{lineStart:function(){t.lineStart(),e=1},point:function(o,s){var a=o>0?Xn:-Xn,u=Kn(o-n);Kn(u-Xn)0?Un:-Un),t.point(i,r),t.lineEnd(),t.lineStart(),t.point(a,r),t.point(o,r),e=0):i!==a&&u>=Xn&&(Kn(n-i)jn?Qn((er(e)*(o=tr(r))*er(n)-er(r)*(i=tr(e))*er(t))/(i*o*s)):(e+r)/2}(n,r,o,s),t.point(i,r),t.lineEnd(),t.lineStart(),t.point(a,r),e=0),t.point(n=o,r=s),i=a},lineEnd:function(){t.lineEnd(),n=r=NaN},clean:function(){return 2-e}}}),(function(t,e,n,r){var i;if(null==t)i=n*Un,r.point(-Xn,i),r.point(0,i),r.point(Xn,i),r.point(Xn,0),r.point(Xn,-i),r.point(0,-i),r.point(-Xn,-i),r.point(-Xn,0),r.point(-Xn,i);else if(Kn(t[0]-e[0])>jn){var o=t[0]0,i=Kn(n)>jn;function o(t,e){return tr(t)*tr(e)>n}function s(t,e,r){var i=[1,0,0],o=pr(fr(t),fr(e)),s=gr(o,o),a=o[0],u=s-a*a;if(!u)return!r&&t;var l=n*s/u,h=-n*a/u,c=pr(i,o),f=dr(i,l);vr(f,dr(o,h));var g=c,p=gr(f,g),v=gr(g,g),d=p*p-v*(gr(f,f)-1);if(!(d<0)){var y=nr(d),m=dr(g,(-p-y)/v);if(vr(m,f),m=cr(m),!r)return m;var _,x=t[0],E=e[0],k=t[1],b=e[1];E0^m[1]<(Kn(m[0]-x)Xn^(x<=m[0]&&m[0]<=E)){var N=dr(g,(-p+y)/v);return vr(N,f),[m,cr(N)]}}}function a(e,n){var i=r?t:Xn-t,o=0;return e<-i?o|=1:e>i&&(o|=2),n<-i?o|=4:n>i&&(o|=8),o}return Br(o,(function(t){var e,n,u,l,h;return{lineStart:function(){l=u=!1,h=1},point:function(c,f){var g,p=[c,f],v=o(c,f),d=r?v?0:a(c,f):v?a(c+(c<0?Xn:-Xn),f):0;if(!e&&(l=u=v)&&t.lineStart(),v!==u&&(!(g=s(e,p))||Ir(e,g)||Ir(p,g))&&(p[0]+=jn,p[1]+=jn,v=o(p[0],p[1])),v!==u)h=0,v?(t.lineStart(),g=s(p,e),t.point(g[0],g[1])):(g=s(e,p),t.point(g[0],g[1]),t.lineEnd()),e=g;else if(i&&e&&r^v){var y;d&n||!(y=s(p,e,!0))||(h=0,r?(t.lineStart(),t.point(y[0][0],y[0][1]),t.point(y[1][0],y[1][1]),t.lineEnd()):(t.point(y[1][0],y[1][1]),t.lineEnd(),t.lineStart(),t.point(y[0][0],y[0][1])))}!v||e&&Ir(e,p)||t.point(p[0],p[1]),e=p,u=v,n=d},lineEnd:function(){u&&t.lineEnd(),e=null},clean:function(){return h|(l&&u)<<1}}}),(function(n,r,i,o){!function(t,e,n,r,i,o){if(n){var s=tr(e),a=er(e),u=r*n;null==i?(i=e+r*Hn,o=e-u/2):(i=br(s,i),o=br(s,o),(r>0?io)&&(i+=r*Hn));for(var l,h=i;r>0?h>o:h4*e&&v--){var x=s+f,E=a+g,k=u+p,b=nr(x*x+E*E+k*k),w=ir(k/=b),I=Kn(Kn(k)-1)e||Kn((y*L+m*P)/_-.5)>.3||s*f+a*g+u*p2?t[2]%360*Jn:0,M()):[d*Wn,y*Wn,m*Wn]},I.precision=function(t){return arguments.length?(w=Kr(S,b=t*t),L()):nr(b)},I.fitExtent=function(t,e){return Hr(I,t,e)},I.fitSize=function(t,e){return function(t,e,n){return Hr(t,[[0,0],e],n)}(I,t,e)},function(){return e=t.apply(this,arguments),I.invert=e.invert&&N,M()}}((function(){return t}))()}function ti(t){return function(e,n){var r=tr(e),i=tr(n),o=t(r*i);return[o*i*er(e),o*er(n)]}}function ei(t){return function(e,n){var r=nr(e*e+n*n),i=t(r),o=er(i),s=tr(i);return[$n(e*o,r*s),ir(r&&n*o/r)]}}ti((function(t){return nr(2/(1+t))})).invert=ei((function(t){return 2*ir(t/2)}));var ni=ti((function(t){return(t=rr(t))&&t/er(t)}));function ri(){return $r(ni).scale(79.4188).clipAngle(179.999)}function ii(t,e){return[t,e]}ni.invert=ei((function(t){return t})),ii.invert=ii;var oi=Vn.BufferOp,si=Vn.GeoJSONReader,ai=Vn.GeoJSONWriter;function ui(t,e,n,r){var i=t.properties||{},o="Feature"===t.type?t.geometry:t;if("GeometryCollection"===o.type){var s=[];return mt(t,(function(t){var i=ui(t,e,n,r);i&&s.push(i)})),C(s)}var a=function(t){var e=An(t).geometry.coordinates,n=[-e[0],-e[1]];return ri().rotate(n).scale(x)}(o),u={type:o.type,coordinates:hi(o.coordinates,a)},l=(new si).read(u),h=F(q(e,n),"meters"),c=oi.bufferOp(l,h,r);if(!li((c=(new ai).write(c)).coordinates))return b({type:c.type,coordinates:ci(c.coordinates,a)},i)}function li(t){return Array.isArray(t[0])?li(t[0]):isNaN(t[0])}function hi(t,e){return"object"!==m(t[0])?e(t):t.map((function(t){return hi(t,e)}))}function ci(t,e){return"object"!==m(t[0])?e.invert(t):t.map((function(t){return ci(t,e)}))}function fi(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=0,r=0,i=0;return mt(t,(function(t,o,s){var a=e.weight?null==s?void 0:s[e.weight]:void 0;if(!U(a=null==a?1:a))throw new Error("weight value must be a number for feature index "+o);(a=Number(a))>0&&ct(t,(function(t){n+=t[0]*a,r+=t[1]*a,i+=a}))})),I([n/i,r/i],e.properties,e)}function gi(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=0,r=0,i=0;return ct(t,(function(t){n+=t[0],r+=t[1],i++}),!0),I([n/i,r/i],e.properties)}function pi(t,e,n,r,i){var o=r.tolerance||.001,s=0,a=0,u=0,l=0;if(vt(n,(function(e){var n,r=null==(n=e.properties)?void 0:n.weight,i=null==r?1:r;if(!U(i=Number(i)))throw new Error("weight value must be a number");if(i>0){l+=1;var o=i*ut(e,t);0===o&&(o=1);var h=i/o;s+=e.geometry.coordinates[0]*h,a+=e.geometry.coordinates[1]*h,u+=h}})),l<1)throw new Error("no features to measure");var h=s/u,c=a/u;return 1===l||0===i||Math.abs(h-e[0])0&&void 0!==arguments[0]?arguments[0]:[],n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:mi;if(i(this,t),this.data=e,this.length=this.data.length,this.compare=n,this.length>0)for(var r=(this.length>>1)-1;r>=0;r--)this._down(r)}),[{key:"push",value:function(t){this.data.push(t),this.length++,this._up(this.length-1)}},{key:"pop",value:function(){if(0!==this.length){var t=this.data[0],e=this.data.pop();return this.length--,this.length>0&&(this.data[0]=e,this._down(0)),t}}},{key:"peek",value:function(){return this.data[0]}},{key:"_up",value:function(t){for(var e=this.data,n=this.compare,r=e[t];t>0;){var i=t-1>>1,o=e[i];if(n(r,o)>=0)break;e[t]=o,t=i}e[t]=r}},{key:"_down",value:function(t){for(var e=this.data,n=this.compare,r=this.length>>1,i=e[t];t=0)break;e[t]=s,t=o}e[t]=i}}])}();function mi(t,e){return te?1:0}var _i,xi,Ei,ki,bi,wi=_n(Object.freeze({__proto__:null,default:yi})),Ii={exports:{}};function Ni(){if(bi)return Ii.exports;bi=1;var t=(xi||(xi=1,_i=function(t,e,n,r){var i=t[0],o=t[1],s=!1;void 0===n&&(n=0),void 0===r&&(r=e.length);for(var a=(r-n)/2,u=0,l=a-1;uo!=g>o&&i<(f-h)*(o-c)/(g-c)+h&&(s=!s)}return s}),_i),e=(ki||(ki=1,Ei=function(t,e,n,r){var i=t[0],o=t[1],s=!1;void 0===n&&(n=0),void 0===r&&(r=e.length);for(var a=r-n,u=0,l=a-1;uo!=g>o&&i<(f-h)*(o-c)/(g-c)+h&&(s=!s)}return s}),Ei);return Ii.exports=function(n,r,i,o){return r.length>0&&Array.isArray(r[0])?e(n,r,i,o):t(n,r,i,o)},Ii.exports.nested=e,Ii.exports.flat=t,Ii.exports}var Si,Mi,Li={exports:{}};Li.exports;function Pi(){return Si||(Si=1,function(t,e){!function(t){var e=134217729,n=33306690738754706e-32;function r(t,e,n,r,i){var o,s,a,u,l=e[0],h=r[0],c=0,f=0;h>l==h>-l?(o=l,l=e[++c]):(o=h,h=r[++f]);var g=0;if(cl==h>-l?(a=o-((s=l+o)-l),l=e[++c]):(a=o-((s=h+o)-h),h=r[++f]),o=s,0!==a&&(i[g++]=a);cl==h>-l?(a=o-((s=o+l)-(u=s-o))+(l-u),l=e[++c]):(a=o-((s=o+h)-(u=s-o))+(h-u),h=r[++f]),o=s,0!==a&&(i[g++]=a);for(;c0!=m>0)return _;var x=Math.abs(y+m);return Math.abs(_)>=o*x?_:-function(t,i,o,g,p,v,d){var y,m,_,x,E,k,b,w,I,N,S,M,L,P,C,T,O,R,A=t-p,D=o-p,F=i-v,q=g-v;E=(C=(w=A-(b=(k=e*A)-(k-A)))*(N=q-(I=(k=e*q)-(k-q)))-((P=A*q)-b*I-w*I-b*N))-(S=C-(O=(w=F-(b=(k=e*F)-(k-F)))*(N=D-(I=(k=e*D)-(k-D)))-((T=F*D)-b*I-w*I-b*N))),u[0]=C-(S+E)+(E-O),E=(L=P-((M=P+S)-(E=M-P))+(S-E))-(S=L-T),u[1]=L-(S+E)+(E-T),E=(R=M+S)-M,u[2]=M-(R-E)+(S-E),u[3]=R;var V=function(t,e){for(var n=e[0],r=1;r=G||-V>=G)return V;if(y=t-(A+(E=t-A))+(E-p),_=o-(D+(E=o-D))+(E-p),m=i-(F+(E=i-F))+(E-v),x=g-(q+(E=g-q))+(E-v),0===y&&0===m&&0===_&&0===x)return V;if(G=a*d+n*Math.abs(V),(V+=A*x+q*y-(F*_+D*m))>=G||-V>=G)return V;E=(C=(w=y-(b=(k=e*y)-(k-y)))*(N=q-(I=(k=e*q)-(k-q)))-((P=y*q)-b*I-w*I-b*N))-(S=C-(O=(w=m-(b=(k=e*m)-(k-m)))*(N=D-(I=(k=e*D)-(k-D)))-((T=m*D)-b*I-w*I-b*N))),f[0]=C-(S+E)+(E-O),E=(L=P-((M=P+S)-(E=M-P))+(S-E))-(S=L-T),f[1]=L-(S+E)+(E-T),E=(R=M+S)-M,f[2]=M-(R-E)+(S-E),f[3]=R;var B=r(4,u,4,f,l);E=(C=(w=A-(b=(k=e*A)-(k-A)))*(N=x-(I=(k=e*x)-(k-x)))-((P=A*x)-b*I-w*I-b*N))-(S=C-(O=(w=F-(b=(k=e*F)-(k-F)))*(N=_-(I=(k=e*_)-(k-_)))-((T=F*_)-b*I-w*I-b*N))),f[0]=C-(S+E)+(E-O),E=(L=P-((M=P+S)-(E=M-P))+(S-E))-(S=L-T),f[1]=L-(S+E)+(E-T),E=(R=M+S)-M,f[2]=M-(R-E)+(S-E),f[3]=R;var Y=r(B,l,4,f,h);E=(C=(w=y-(b=(k=e*y)-(k-y)))*(N=x-(I=(k=e*x)-(k-x)))-((P=y*x)-b*I-w*I-b*N))-(S=C-(O=(w=m-(b=(k=e*m)-(k-m)))*(N=_-(I=(k=e*_)-(k-_)))-((T=m*_)-b*I-w*I-b*N))),f[0]=C-(S+E)+(E-O),E=(L=P-((M=P+S)-(E=M-P))+(S-E))-(S=L-T),f[1]=L-(S+E)+(E-T),E=(R=M+S)-M,f[2]=M-(R-E)+(S-E),f[3]=R;var z=r(Y,h,4,f,c);return c[z-1]}(t,i,g,p,v,d,x)},t.orient2dfast=function(t,e,n,r,i,o){return(e-o)*(n-i)-(t-i)*(r-o)},Object.defineProperty(t,"__esModule",{value:!0})}(e)}(0,Li.exports)),Li.exports}var Ci=function(){if(Mi)return vi.exports;Mi=1;var t=di,e=wi,n=Ni(),r=Pi().orient2d;function i(e,r,i){r=Math.max(0,void 0===r?2:r),i=i||0;var s=function(t){for(var e=t[0],r=t[0],i=t[0],o=t[0],s=0;si[0]&&(i=a),a[1]o[1]&&(o=a)}var u=[e,r,i,o],l=u.slice();for(s=0;s=2&&h(e[e.length-2],e[e.length-1],t[n])<=0;)e.pop();e.push(t[n])}for(var r=[],i=t.length-1;i>=0;i--){for(;r.length>=2&&h(r[r.length-2],r[r.length-1],t[i])<=0;)r.pop();r.push(t[i])}return r.pop(),e.pop(),e.concat(r)}(l)}(e),a=new t(16);a.toBBox=function(t){return{minX:t[0],minY:t[1],maxX:t[0],maxY:t[1]}},a.compareMinX=function(t,e){return t[0]-e[0]},a.compareMinY=function(t,e){return t[1]-e[1]},a.load(e);for(var u,l=[],p=0;pu||c.push({node:v,dist:d})}for(;c.length&&!c.peek().node.children;){var y=c.pop(),m=y.node,_=p(m,n,r),x=p(m,i,o);if(y.dist<_&&y.dist=e.minX&&t[0]<=e.maxX&&t[1]>=e.minY&&t[1]<=e.maxY}function l(t,e,n){for(var r,i,o,s,a=Math.min(t[0],e[0]),u=Math.min(t[1],e[1]),l=Math.max(t[0],e[0]),c=Math.max(t[1],e[1]),f=n.search({minX:a,minY:u,maxX:l,maxY:c}),g=0;g0!=h(r,i,s)>0&&h(o,s,r)>0!=h(o,s,i)>0)return!1;return!0}function h(t,e,n){return r(t[0],t[1],e[0],e[1],n[0],n[1])}function c(t){var e=t.p,n=t.next.p;return t.minX=Math.min(e[0],n[0]),t.minY=Math.min(e[1],n[1]),t.maxX=Math.max(e[0],n[0]),t.maxY=Math.max(e[1],n[1]),t}function f(t,e){var n={p:t,prev:null,next:null,minX:0,minY:0,maxX:0,maxY:0};return e?(n.next=e.next,n.prev=e,e.next.prev=n,e.next=n):(n.prev=n,n.next=n),n}function g(t,e){var n=t[0]-e[0],r=t[1]-e[1];return n*n+r*r}function p(t,e,n){var r=e[0],i=e[1],o=n[0]-r,s=n[1]-i;if(0!==o||0!==s){var a=((t[0]-r)*o+(t[1]-i)*s)/(o*o+s*s);a>1?(r=n[0],i=n[1]):a>0&&(r+=o*a,i+=s*a)}return(o=t[0]-r)*o+(s=t[1]-i)*s}function v(t,e,n,r,i,o,s,a){var u,l,h,c,f=n-t,g=r-e,p=s-i,v=a-o,d=t-i,y=e-o,m=f*f+g*g,_=f*p+g*v,x=p*p+v*v,E=f*d+g*y,k=p*d+v*y,b=m*x-_*_,w=b,I=b;0===b?(l=0,w=1,c=k,I=x):(c=m*k-_*E,(l=_*k-x*E)<0?(l=0,c=k,I=x):l>w&&(l=w,c=k+_,I=x)),c<0?(c=0,-E<0?l=0:-E>m?l=w:(l=-E,w=m)):c>I&&(c=I,-E+_<0?l=0:-E+_>m?l=w:(l=-E+_,w=m));var N=(1-(h=0===c?0:c/I))*i+h*s-((1-(u=0===l?0:l/w))*t+u*n),S=(1-h)*o+h*a-((1-u)*e+u*r);return N*N+S*S}function d(t,e){return t[0]===e[0]?t[1]-e[1]:t[0]-e[0]}return e.default&&(e=e.default),vi.exports=i,vi.exports.default=i,vi.exports}(),Ti=mn(Ci);function Oi(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};e.concavity=e.concavity||1/0;var n=[];if(ct(t,(function(t){n.push([t[0],t[1]])})),!n.length)return null;var r=Ti(n,e.concavity);return r.length>3?S([r]):null}function Ri(t,e){for(var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=n.steps||64,i=n.properties?n.properties:!Array.isArray(t)&&"Feature"===t.type&&t.properties?t.properties:{},o=[],s=0;s0;r.length0;){var a=t[Math.floor(Math.random()*o)],u=s?a.join("_"):""+a;n[u]||(n[u]=!0,r.push(a))}if(r.length0,u=t[Math.floor(Math.random()*s)];for(a&&u.join("_"),o.push(u);o.length0,y=[];if(s)u="kmrand"==s?r(t,e):"kmpp"==s?i(t,e):s;else for(var m={};u.lengthc&&(c=t[a].y);var g,p=l-u,v=c-h,d=p>v?p:v,y=.5*(l+u),m=.5*(c+h),_=[new so({__sentinel:!0,x:y-20*d,y:m-d},{__sentinel:!0,x:y,y:m+20*d},{__sentinel:!0,x:y+20*d,y:m-d})],x=[],E=[];a=t.length;for(;a--;){for(E.length=0,g=_.length;g--;)(p=t[a].x-_[g].x)>0&&p*p>_[g].r?(x.push(_[g]),_.splice(g,1)):p*p+(v=t[a].y-_[g].y)*v>_[g].r||(E.push(_[g].a,_[g].b,_[g].b,_[g].c,_[g].c,_[g].a),_.splice(g,1));for(uo(E),g=E.length;g;)n=E[--g],e=E[--g],r=t[a],i=n.x-e.x,o=n.y-e.y,s=2*(i*(r.y-n.y)-o*(r.x-n.x)),Math.abs(s)>f&&_.push(new so(e,n,r))}Array.prototype.push.apply(x,_),a=x.length;for(;a--;)(x[a].a.__sentinel||x[a].b.__sentinel||x[a].c.__sentinel)&&x.splice(a,1);return x}(t.features.map((function(t){var r={x:t.geometry.coordinates[0],y:t.geometry.coordinates[1]};return e?r.z=t.properties[e]:3===t.geometry.coordinates.length&&(n=!0,r.z=t.geometry.coordinates[2]),r}))).map((function(t){var e=[t.a.x,t.a.y],r=[t.b.x,t.b.y],i=[t.c.x,t.c.y],o={};return n?(e.push(t.a.z),r.push(t.b.z),i.push(t.c.z)):o={a:t.a.z,b:t.b.z,c:t.c.z},S([[e,r,i,e]],o)})))}var so=s((function t(e,n,r){i(this,t),this.a=e,this.b=n,this.c=r;var o,s,a=n.x-e.x,u=n.y-e.y,l=r.x-e.x,h=r.y-e.y,c=a*(e.x+n.x)+u*(e.y+n.y),f=l*(e.x+r.x)+h*(e.y+r.y),g=2*(a*(r.y-n.y)-u*(r.x-n.x));this.x=(h*c-u*f)/g,this.y=(a*f-l*c)/g,o=this.x-e.x,s=this.y-e.y,this.r=o*o+s*s}));function ao(t,e){return e.x-t.x}function uo(t){var e,n,r,i,o,s=t.length;t:for(;s;)for(n=t[--s],e=t[--s],r=s;r;)if(o=t[--r],e===(i=t[--r])&&n===o||e===o&&n===i){t.splice(s,2),t.splice(r,2),s-=2;continue t}}function lo(t){return t}function ho(t,e){var n=function(t){if(null==t)return lo;var e,n,r=t.scale[0],i=t.scale[1],o=t.translate[0],s=t.translate[1];return function(t,a){a||(e=n=0);var u=2,l=t.length,h=new Array(l);for(h[0]=(e+=t[0])*r+o,h[1]=(n+=t[1])*i+s;u1)for(var o,a,u=1,l=s(i[0]);ul&&(a=i[0],i[0]=i[u],i[u]=a,l=o);return i})).filter((function(t){return t.length>0}))}}var po=Object.prototype.hasOwnProperty;function vo(t,e,n,r,i,o){3===arguments.length&&(r=o=Array,i=null);for(var s=new r(t=1<=t)throw new Error("full hashmap");h=s[l=l+1&u]}return s[l]=r,a[l]=o,o},maybeSet:function(r,o){for(var l=e(r)&u,h=s[l],c=0;h!=i;){if(n(h,r))return a[l];if(++c>=t)throw new Error("full hashmap");h=s[l=l+1&u]}return s[l]=r,a[l]=o,o},get:function(r,o){for(var l=e(r)&u,h=s[l],c=0;h!=i;){if(n(h,r))return a[l];if(++c>=t)break;h=s[l=l+1&u]}return o},keys:function(){for(var t=[],e=0,n=s.length;e>7^xo[2]^xo[3])}function ko(t){var e,n,r,i,o=t.coordinates,s=t.lines,a=t.rings,u=function(){for(var t=vo(1.4*o.length,E,k,Int32Array,-1,Int32Array),e=new Int32Array(o.length),n=0,r=o.length;n=0){var o=c[n];i===e&&o===r||i===r&&o===e||(++g,f[n]=1)}else h[n]=e,c[n]=r}}function E(t){return Eo(o[t])}function k(t,e){return yo(o[t],o[e])}l=h=c=null;var b,w=function(t,e,n,r,i){3===arguments.length&&(r=Array,i=null);for(var o=new r(t=1<=t)throw new Error("full hashset");u=o[a=a+1&s]}return o[a]=r,!0},has:function(r){for(var a=e(r)&s,u=o[a],l=0;u!=i;){if(n(u,r))return!0;if(++l>=t)break;u=o[a=a+1&s]}return!1},values:function(){for(var t=[],e=0,n=o.length;e>1);er&&(r=o),si&&(i=s)}function u(t){t.forEach(a)}function l(t){t.forEach(u)}for(var h in t)o(t[h]);return r>=e&&i>=n?[e,n,r,i]:void 0}(t=Io(t)),r=function(t){var e,n,r,i,o=t.coordinates,s=t.lines,a=t.rings,u=s.length+a.length;for(delete t.lines,delete t.rings,r=0,i=s.length;r1&&void 0!==arguments[1]?arguments[1]:{};if(!Z(e=e||{}))throw new Error("options is invalid");var n=e.mutate;if("FeatureCollection"!==it(t))throw new Error("geojson must be a FeatureCollection");if(!t.features.length)throw new Error("geojson is empty");!1!==n&&void 0!==n||(t=Ai(t));var r=[],i=It(t,(function(t,e){var n=function(t,e){var n,r=t.geometry.coordinates,i=e.geometry.coordinates,o=Oo(r[0]),s=Oo(r[r.length-1]),a=Oo(i[0]),u=Oo(i[i.length-1]);if(o===u)n=i.concat(r.slice(1));else if(a===s)n=r.concat(i.slice(1));else if(o===a)n=r.slice(1).reverse().concat(i);else{if(s!==u)return null;n=r.concat(i.reverse().slice(1))}return L(n)}(t,e);return n||(r.push(t),e)}));return i&&r.push(i),r.length?1===r.length?r[0]:T(r.map((function(t){return t.coordinates}))):null}function Oo(t){return t[0].toString()+","+t[1].toString()}function Ro(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!Z(e=e||{}))throw new Error("options is invalid");var n=e.mutate;if("FeatureCollection"!==it(t))throw new Error("geojson must be a FeatureCollection");if(!t.features.length)throw new Error("geojson is empty");!1!==n&&void 0!==n||(t=Ai(t));var r=function(t){var e={};xt(t,(function(t){e[t.geometry.type]=!0}));var n=Object.keys(e);if(1===n.length)return n[0];return null}(t);if(!r)throw new Error("geojson must be homogenous");var i=t;switch(r){case"LineString":return To(i,e);case"Polygon":return function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if("FeatureCollection"!==it(t))throw new Error("geojson must be a FeatureCollection");if(!t.features.length)throw new Error("geojson is empty");!1!==e.mutate&&void 0!==e.mutate||(t=Ai(t));var n=[];xt(t,(function(t){n.push(t.geometry)}));var r=Lo({geoms:A(n).geometry});return fo(r,r.objects.geoms.geometries)}(i,e);default:throw new Error(r+" is not supported")}}var Ao=/^-?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i,Do=Math.ceil,Fo=Math.floor,qo="[BigNumber Error] ",Vo=qo+"Number primitive has more than 15 significant digits: ",Go=1e14,Bo=14,Yo=9007199254740991,zo=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8,1e9,1e10,1e11,1e12,1e13],jo=1e7,Xo=1e9;function Uo(t){var e=0|t;return t>0||t===e?e:e-1}function Zo(t){for(var e,n,r=1,i=t.length,o=t[0]+"";rl^n?1:-1;for(a=(u=i.length)<(l=o.length)?u:l,s=0;so[s]^n?1:-1;return u==l?0:u>l^n?1:-1}function Wo(t,e,n,r){if(tn||t!==Fo(t))throw Error(qo+(r||"Argument")+("number"==typeof t?tn?" out of range: ":" not an integer: ":" not a primitive number: ")+String(t))}function Jo(t){var e=t.c.length-1;return Uo(t.e/Bo)==e&&t.c[e]%2!=0}function Ko(t,e){return(t.length>1?t.charAt(0)+"."+t.slice(1):t)+(e<0?"e":"e+")+e}function Qo(t,e,n){var r,i;if(e<0){for(i=n+".";++e;i+=n);t=i+t}else if(++e>(r=t.length)){for(i=n,e-=r;--e;i+=n);t+=i}else ex?f.c=f.e=null:t.e<_?f.c=[f.e=0]:(f.e=t.e,f.c=t.c.slice()));if((l="number"==typeof t)&&0*t==0){if(f.s=1/t<0?(t=-t,-1):1,t===~~t){for(a=0,u=t;u>=10;u/=10,a++);return void(a>x?f.c=f.e=null:(f.e=a,f.c=[t]))}c=String(t)}else{if(!Ao.test(c=String(t)))return i(f,c,l);f.s=45==c.charCodeAt(0)?(c=c.slice(1),-1):1}(a=c.indexOf("."))>-1&&(c=c.replace(".","")),(u=c.search(/e/i))>0?(a<0&&(a=u),a+=+c.slice(u+1),c=c.substring(0,u)):a<0&&(a=c.length)}else{if(Wo(e,2,I.length,"Base"),10==e&&N)return C(f=new S(t),p+f.e+1,v);if(c=String(t),l="number"==typeof t){if(0*t!=0)return i(f,c,l,e);if(f.s=1/t<0?(c=c.slice(1),-1):1,S.DEBUG&&c.replace(/^0\.0*|\./,"").length>15)throw Error(Vo+t)}else f.s=45===c.charCodeAt(0)?(c=c.slice(1),-1):1;for(n=I.slice(0,e),a=u=0,h=c.length;ua){a=h;continue}}else if(!s&&(c==c.toUpperCase()&&(c=c.toLowerCase())||c==c.toLowerCase()&&(c=c.toUpperCase()))){s=!0,u=-1,a=0;continue}return i(f,String(t),l,e)}l=!1,(a=(c=r(c,e,10,f.s)).indexOf("."))>-1?c=c.replace(".",""):a=c.length}for(u=0;48===c.charCodeAt(u);u++);for(h=c.length;48===c.charCodeAt(--h););if(c=c.slice(u,++h)){if(h-=u,l&&S.DEBUG&&h>15&&(t>Yo||t!==Fo(t)))throw Error(Vo+f.s*t);if((a=a-u-1)>x)f.c=f.e=null;else if(a<_)f.c=[f.e=0];else{if(f.e=a,f.c=[],u=(a+1)%Bo,a<0&&(u+=Bo),u=y)?Ko(u,s):Qo(u,s,"0");else if(o=(t=C(new S(t),e,n)).e,a=(u=Zo(t.c)).length,1==r||2==r&&(e<=o||o<=d)){for(;aa){if(--e>0)for(u+=".";e--;u+="0");}else if((e+=o-a)>0)for(o+1==a&&(u+=".");e--;u+="0");return t.s<0&&i?"-"+u:u}function L(t,e){for(var n,r,i=1,o=new S(t[0]);i=10;i/=10,r++);return(n=r+n*Bo-1)>x?t.c=t.e=null:n<_?t.c=[t.e=0]:(t.e=n,t.c=e),t}function C(t,e,n,r){var i,o,s,a,u,l,h,c=t.c,f=zo;if(c){t:{for(i=1,a=c[0];a>=10;a/=10,i++);if((o=e-i)<0)o+=Bo,s=e,u=c[l=0],h=Fo(u/f[i-s-1]%10);else if((l=Do((o+1)/Bo))>=c.length){if(!r)break t;for(;c.length<=l;c.push(0));u=h=0,i=1,s=(o%=Bo)-Bo+1}else{for(u=a=c[l],i=1;a>=10;a/=10,i++);h=(s=(o%=Bo)-Bo+i)<0?0:Fo(u/f[i-s-1]%10)}if(r=r||e<0||null!=c[l+1]||(s<0?u:u%f[i-s-1]),r=n<4?(h||r)&&(0==n||n==(t.s<0?3:2)):h>5||5==h&&(4==n||r||6==n&&(o>0?s>0?u/f[i-s]:0:c[l-1])%10&1||n==(t.s<0?8:7)),e<1||!c[0])return c.length=0,r?(e-=t.e+1,c[0]=f[(Bo-e%Bo)%Bo],t.e=-e||0):c[0]=t.e=0,t;if(0==o?(c.length=l,a=1,l--):(c.length=l+1,a=f[Bo-o],c[l]=s>0?Fo(u/f[i-s]%f[s])*a:0),r)for(;;){if(0==l){for(o=1,s=c[0];s>=10;s/=10,o++);for(s=c[0]+=a,a=1;s>=10;s/=10,a++);o!=a&&(t.e++,c[0]==Go&&(c[0]=1));break}if(c[l]+=a,c[l]!=Go)break;c[l--]=0,a=1}for(o=c.length;0===c[--o];c.pop());}t.e>x?t.c=t.e=null:t.e<_&&(t.c=[t.e=0])}return t}function T(t){var e,n=t.e;return null===n?t.toString():(e=Zo(t.c),e=n<=d||n>=y?Ko(e,n):Qo(e,n,"0"),t.s<0?"-"+e:e)}return S.clone=t,S.ROUND_UP=0,S.ROUND_DOWN=1,S.ROUND_CEIL=2,S.ROUND_FLOOR=3,S.ROUND_HALF_UP=4,S.ROUND_HALF_DOWN=5,S.ROUND_HALF_EVEN=6,S.ROUND_HALF_CEIL=7,S.ROUND_HALF_FLOOR=8,S.EUCLID=9,S.config=S.set=function(t){var e,n;if(null!=t){if("object"!=m(t))throw Error(qo+"Object expected: "+t);if(t.hasOwnProperty(e="DECIMAL_PLACES")&&(Wo(n=t[e],0,Xo,e),p=n),t.hasOwnProperty(e="ROUNDING_MODE")&&(Wo(n=t[e],0,8,e),v=n),t.hasOwnProperty(e="EXPONENTIAL_AT")&&((n=t[e])&&n.pop?(Wo(n[0],-Xo,0,e),Wo(n[1],0,Xo,e),d=n[0],y=n[1]):(Wo(n,-Xo,Xo,e),d=-(y=n<0?-n:n))),t.hasOwnProperty(e="RANGE"))if((n=t[e])&&n.pop)Wo(n[0],-Xo,-1,e),Wo(n[1],1,Xo,e),_=n[0],x=n[1];else{if(Wo(n,-Xo,Xo,e),!n)throw Error(qo+e+" cannot be zero: "+n);_=-(x=n<0?-n:n)}if(t.hasOwnProperty(e="CRYPTO")){if((n=t[e])!==!!n)throw Error(qo+e+" not true or false: "+n);if(n){if("undefined"==typeof crypto||!crypto||!crypto.getRandomValues&&!crypto.randomBytes)throw E=!n,Error(qo+"crypto unavailable");E=n}else E=n}if(t.hasOwnProperty(e="MODULO_MODE")&&(Wo(n=t[e],0,9,e),k=n),t.hasOwnProperty(e="POW_PRECISION")&&(Wo(n=t[e],0,Xo,e),b=n),t.hasOwnProperty(e="FORMAT")){if("object"!=m(n=t[e]))throw Error(qo+e+" not an object: "+n);w=n}if(t.hasOwnProperty(e="ALPHABET")){if("string"!=typeof(n=t[e])||/^.?$|[+\-.\s]|(.).*\1/.test(n))throw Error(qo+e+" invalid: "+n);N="0123456789"==n.slice(0,10),I=n}}return{DECIMAL_PLACES:p,ROUNDING_MODE:v,EXPONENTIAL_AT:[d,y],RANGE:[_,x],CRYPTO:E,MODULO_MODE:k,POW_PRECISION:b,FORMAT:w,ALPHABET:I}},S.isBigNumber=function(t){if(!t||!0!==t._isBigNumber)return!1;if(!S.DEBUG)return!0;var e,n,r=t.c,i=t.e,o=t.s;t:if("[object Array]"=={}.toString.call(r)){if((1===o||-1===o)&&i>=-Xo&&i<=Xo&&i===Fo(i)){if(0===r[0]){if(0===i&&1===r.length)return!0;break t}if((e=(i+1)%Bo)<1&&(e+=Bo),String(r[0]).length==e){for(e=0;e=Go||n!==Fo(n))break t;if(0!==n)return!0}}}else if(null===r&&null===i&&(null===o||1===o||-1===o))return!0;throw Error(qo+"Invalid BigNumber: "+t)},S.maximum=S.max=function(){return L(arguments,-1)},S.minimum=S.min=function(){return L(arguments,1)},S.random=(o=9007199254740992,s=Math.random()*o&2097151?function(){return Fo(Math.random()*o)}:function(){return 8388608*(1073741824*Math.random()|0)+(8388608*Math.random()|0)},function(t){var e,n,r,i,o,a=0,u=[],l=new S(g);if(null==t?t=p:Wo(t,0,Xo),i=Do(t/Bo),E)if(crypto.getRandomValues){for(e=crypto.getRandomValues(new Uint32Array(i*=2));a>>11))>=9e15?(n=crypto.getRandomValues(new Uint32Array(2)),e[a]=n[0],e[a+1]=n[1]):(u.push(o%1e14),a+=2);a=i/2}else{if(!crypto.randomBytes)throw E=!1,Error(qo+"crypto unavailable");for(e=crypto.randomBytes(i*=7);a=9e15?crypto.randomBytes(7).copy(e,a):(u.push(o%1e14),a+=7);a=i/7}if(!E)for(;a=10;o/=10,a++);an-1&&(null==s[i+1]&&(s[i+1]=0),s[i+1]+=s[i]/n|0,s[i]%=n)}return s.reverse()}return function(r,i,o,s,a){var u,l,h,c,f,g,d,y,m=r.indexOf("."),_=p,x=v;for(m>=0&&(c=b,b=0,r=r.replace(".",""),g=(y=new S(i)).pow(r.length-m),b=c,y.c=e(Qo(Zo(g.c),g.e,"0"),10,o,t),y.e=y.c.length),h=c=(d=e(r,i,o,a?(u=I,t):(u=t,I))).length;0==d[--c];d.pop());if(!d[0])return u.charAt(0);if(m<0?--h:(g.c=d,g.e=h,g.s=s,d=(g=n(g,y,_,x,o)).c,f=g.r,h=g.e),m=d[l=h+_+1],c=o/2,f=f||l<0||null!=d[l+1],f=x<4?(null!=m||f)&&(0==x||x==(g.s<0?3:2)):m>c||m==c&&(4==x||f||6==x&&1&d[l-1]||x==(g.s<0?8:7)),l<1||!d[0])r=f?Qo(u.charAt(1),-_,u.charAt(0)):u.charAt(0);else{if(d.length=l,f)for(--o;++d[--l]>o;)d[l]=0,l||(++h,d=[1].concat(d));for(c=d.length;!d[--c];);for(m=0,r="";m<=c;r+=u.charAt(d[m++]));r=Qo(r,h,u.charAt(0))}return r}}(),n=function(){function t(t,e,n){var r,i,o,s,a=0,u=t.length,l=e%jo,h=e/jo|0;for(t=t.slice();u--;)a=((i=l*(o=t[u]%jo)+(r=h*o+(s=t[u]/jo|0)*l)%jo*jo+a)/n|0)+(r/jo|0)+h*s,t[u]=i%n;return a&&(t=[a].concat(t)),t}function e(t,e,n,r){var i,o;if(n!=r)o=n>r?1:-1;else for(i=o=0;ie[i]?1:-1;break}return o}function n(t,e,n,r){for(var i=0;n--;)t[n]-=i,i=t[n]1;t.splice(0,1));}return function(r,i,o,s,a){var u,l,h,c,f,g,p,v,d,y,m,_,x,E,k,b,w,I=r.s==i.s?1:-1,N=r.c,M=i.c;if(!(N&&N[0]&&M&&M[0]))return new S(r.s&&i.s&&(N?!M||N[0]!=M[0]:M)?N&&0==N[0]||!M?0*I:I/0:NaN);for(d=(v=new S(I)).c=[],I=o+(l=r.e-i.e)+1,a||(a=Go,l=Uo(r.e/Bo)-Uo(i.e/Bo),I=I/Bo|0),h=0;M[h]==(N[h]||0);h++);if(M[h]>(N[h]||0)&&l--,I<0)d.push(1),c=!0;else{for(E=N.length,b=M.length,h=0,I+=2,(f=Fo(a/(M[0]+1)))>1&&(M=t(M,f,a),N=t(N,f,a),b=M.length,E=N.length),x=b,m=(y=N.slice(0,b)).length;m=a/2&&k++;do{if(f=0,(u=e(M,y,b,m))<0){if(_=y[0],b!=m&&(_=_*a+(y[1]||0)),(f=Fo(_/k))>1)for(f>=a&&(f=a-1),p=(g=t(M,f,a)).length,m=y.length;1==e(g,y,p,m);)f--,n(g,b=10;I/=10,h++);C(v,o+(v.e=h+l*Bo-1)+1,s,c)}else v.e=l,v.r=+c;return v}}(),a=/^(-?)0([xbo])(?=\w[\w.]*$)/i,u=/^([^.]+)\.$/,l=/^\.([^.]+)$/,h=/^-?(Infinity|NaN)$/,c=/^\s*\+(?=[\w.])|^\s+|\s+$/g,i=function(t,e,n,r){var i,o=n?e:e.replace(c,"");if(h.test(o))t.s=isNaN(o)?null:o<0?-1:1;else{if(!n&&(o=o.replace(a,(function(t,e,n){return i="x"==(n=n.toLowerCase())?16:"b"==n?2:8,r&&r!=i?t:e})),r&&(i=r,o=o.replace(u,"$1").replace(l,"0.$1")),e!=o))return new S(o,i);if(S.DEBUG)throw Error(qo+"Not a"+(r?" base "+r:"")+" number: "+e);t.s=null}t.c=t.e=null},f.absoluteValue=f.abs=function(){var t=new S(this);return t.s<0&&(t.s=1),t},f.comparedTo=function(t,e){return Ho(this,new S(t,e))},f.decimalPlaces=f.dp=function(t,e){var n,r,i,o=this;if(null!=t)return Wo(t,0,Xo),null==e?e=v:Wo(e,0,8),C(new S(o),t+o.e+1,e);if(!(n=o.c))return null;if(r=((i=n.length-1)-Uo(this.e/Bo))*Bo,i=n[i])for(;i%10==0;i/=10,r--);return r<0&&(r=0),r},f.dividedBy=f.div=function(t,e){return n(this,new S(t,e),p,v)},f.dividedToIntegerBy=f.idiv=function(t,e){return n(this,new S(t,e),0,1)},f.exponentiatedBy=f.pow=function(t,e){var n,r,i,o,s,a,u,l,h=this;if((t=new S(t)).c&&!t.isInteger())throw Error(qo+"Exponent not an integer: "+T(t));if(null!=e&&(e=new S(e)),s=t.e>14,!h.c||!h.c[0]||1==h.c[0]&&!h.e&&1==h.c.length||!t.c||!t.c[0])return l=new S(Math.pow(+T(h),s?t.s*(2-Jo(t)):+T(t))),e?l.mod(e):l;if(a=t.s<0,e){if(e.c?!e.c[0]:!e.s)return new S(NaN);(r=!a&&h.isInteger()&&e.isInteger())&&(h=h.mod(e))}else{if(t.e>9&&(h.e>0||h.e<-1||(0==h.e?h.c[0]>1||s&&h.c[1]>=24e7:h.c[0]<8e13||s&&h.c[0]<=9999975e7)))return o=h.s<0&&Jo(t)?-0:0,h.e>-1&&(o=1/o),new S(a?1/o:o);b&&(o=Do(b/Bo+2))}for(s?(n=new S(.5),a&&(t.s=1),u=Jo(t)):u=(i=Math.abs(+T(t)))%2,l=new S(g);;){if(u){if(!(l=l.times(h)).c)break;o?l.c.length>o&&(l.c.length=o):r&&(l=l.mod(e))}if(i){if(0===(i=Fo(i/2)))break;u=i%2}else if(C(t=t.times(n),t.e+1,1),t.e>14)u=Jo(t);else{if(0===(i=+T(t)))break;u=i%2}h=h.times(h),o?h.c&&h.c.length>o&&(h.c.length=o):r&&(h=h.mod(e))}return r?l:(a&&(l=g.div(l)),e?l.mod(e):o?C(l,b,v,undefined):l)},f.integerValue=function(t){var e=new S(this);return null==t?t=v:Wo(t,0,8),C(e,e.e+1,t)},f.isEqualTo=f.eq=function(t,e){return 0===Ho(this,new S(t,e))},f.isFinite=function(){return!!this.c},f.isGreaterThan=f.gt=function(t,e){return Ho(this,new S(t,e))>0},f.isGreaterThanOrEqualTo=f.gte=function(t,e){return 1===(e=Ho(this,new S(t,e)))||0===e},f.isInteger=function(){return!!this.c&&Uo(this.e/Bo)>this.c.length-2},f.isLessThan=f.lt=function(t,e){return Ho(this,new S(t,e))<0},f.isLessThanOrEqualTo=f.lte=function(t,e){return-1===(e=Ho(this,new S(t,e)))||0===e},f.isNaN=function(){return!this.s},f.isNegative=function(){return this.s<0},f.isPositive=function(){return this.s>0},f.isZero=function(){return!!this.c&&0==this.c[0]},f.minus=function(t,e){var n,r,i,o,s=this,a=s.s;if(e=(t=new S(t,e)).s,!a||!e)return new S(NaN);if(a!=e)return t.s=-e,s.plus(t);var u=s.e/Bo,l=t.e/Bo,h=s.c,c=t.c;if(!u||!l){if(!h||!c)return h?(t.s=-e,t):new S(c?s:NaN);if(!h[0]||!c[0])return c[0]?(t.s=-e,t):new S(h[0]?s:3==v?-0:0)}if(u=Uo(u),l=Uo(l),h=h.slice(),a=u-l){for((o=a<0)?(a=-a,i=h):(l=u,i=c),i.reverse(),e=a;e--;i.push(0));i.reverse()}else for(r=(o=(a=h.length)<(e=c.length))?a:e,a=e=0;e0)for(;e--;h[n++]=0);for(e=Go-1;r>a;){if(h[--r]=0;){for(n=0,f=_[i]%d,g=_[i]/d|0,o=i+(s=u);o>i;)n=((l=f*(l=m[--s]%d)+(a=g*l+(h=m[s]/d|0)*f)%d*d+p[o]+n)/v|0)+(a/d|0)+g*h,p[o--]=l%v;p[o]=n}return n?++r:p.splice(0,1),P(t,p,r)},f.negated=function(){var t=new S(this);return t.s=-t.s||null,t},f.plus=function(t,e){var n,r=this,i=r.s;if(e=(t=new S(t,e)).s,!i||!e)return new S(NaN);if(i!=e)return t.s=-e,r.minus(t);var o=r.e/Bo,s=t.e/Bo,a=r.c,u=t.c;if(!o||!s){if(!a||!u)return new S(i/0);if(!a[0]||!u[0])return u[0]?t:new S(a[0]?r:0*i)}if(o=Uo(o),s=Uo(s),a=a.slice(),i=o-s){for(i>0?(s=o,n=u):(i=-i,n=a),n.reverse();i--;n.push(0));n.reverse()}for((i=a.length)-(e=u.length)<0&&(n=u,u=a,a=n,e=i),i=0;e;)i=(a[--e]=a[e]+u[e]+i)/Go|0,a[e]=Go===a[e]?0:a[e]%Go;return i&&(a=[i].concat(a),++s),P(t,a,s)},f.precision=f.sd=function(t,e){var n,r,i,o=this;if(null!=t&&t!==!!t)return Wo(t,1,Xo),null==e?e=v:Wo(e,0,8),C(new S(o),t,e);if(!(n=o.c))return null;if(r=(i=n.length-1)*Bo+1,i=n[i]){for(;i%10==0;i/=10,r--);for(i=n[0];i>=10;i/=10,r++);}return t&&o.e+1>r&&(r=o.e+1),r},f.shiftedBy=function(t){return Wo(t,-9007199254740991,Yo),this.times("1e"+t)},f.squareRoot=f.sqrt=function(){var t,e,r,i,o,s=this,a=s.c,u=s.s,l=s.e,h=p+4,c=new S("0.5");if(1!==u||!a||!a[0])return new S(!u||u<0&&(!a||a[0])?NaN:a?s:1/0);if(0==(u=Math.sqrt(+T(s)))||u==1/0?(((e=Zo(a)).length+l)%2==0&&(e+="0"),u=Math.sqrt(+e),l=Uo((l+1)/2)-(l<0||l%2),r=new S(e=u==1/0?"5e"+l:(e=u.toExponential()).slice(0,e.indexOf("e")+1)+l)):r=new S(u+""),r.c[0])for((u=(l=r.e)+h)<3&&(u=0);;)if(o=r,r=c.times(o.plus(n(s,o,h,1))),Zo(o.c).slice(0,u)===(e=Zo(r.c)).slice(0,u)){if(r.e0&&p>0){for(o=p%a||a,h=g.substr(0,o);o0&&(h+=l+g.slice(o)),f&&(h="-"+h)}r=c?h+(n.decimalSeparator||"")+((u=+n.fractionGroupSize)?c.replace(new RegExp("\\d{"+u+"}\\B","g"),"$&"+(n.fractionGroupSeparator||"")):c):h}return(n.prefix||"")+r+(n.suffix||"")},f.toFraction=function(t){var e,r,i,o,s,a,u,l,h,c,f,p,d=this,y=d.c;if(null!=t&&(!(u=new S(t)).isInteger()&&(u.c||1!==u.s)||u.lt(g)))throw Error(qo+"Argument "+(u.isInteger()?"out of range: ":"not an integer: ")+T(u));if(!y)return new S(d);for(e=new S(g),h=r=new S(g),i=l=new S(g),p=Zo(y),s=e.e=p.length-d.e-1,e.c[0]=zo[(a=s%Bo)<0?Bo+a:a],t=!t||u.comparedTo(e)>0?s>0?e:h:u,a=x,x=1/0,u=new S(p),l.c[0]=0;c=n(u,e,0,1),1!=(o=r.plus(c.times(i))).comparedTo(t);)r=i,i=o,h=l.plus(c.times(o=h)),l=o,e=u.minus(c.times(o=e)),u=o;return o=n(t.minus(r),i,0,1),l=l.plus(o.times(h)),r=r.plus(o.times(i)),l.s=h.s=d.s,f=n(h,i,s*=2,v).minus(d).abs().comparedTo(n(l,r,s,v).minus(d).abs())<1?[h,i]:[l,r],x=a,f},f.toNumber=function(){return+T(this)},f.toPrecision=function(t,e){return null!=t&&Wo(t,1,Xo),M(this,t,e,2)},f.toString=function(t){var e,n=this,i=n.s,o=n.e;return null===o?i?(e="Infinity",i<0&&(e="-"+e)):e="NaN":(null==t?e=o<=d||o>=y?Ko(Zo(n.c),o):Qo(Zo(n.c),o,"0"):10===t&&N?e=Qo(Zo((n=C(new S(n),p+o+1,v)).c),n.e,"0"):(Wo(t,2,I.length,"Base"),e=r(Qo(Zo(n.c),o,"0"),10,t,i,!0)),i<0&&n.c[0]&&(e="-"+e)),e},f.valueOf=f.toJSON=function(){return T(this)},f._isBigNumber=!0,f[Symbol.toStringTag]="BigNumber",f[Symbol.for("nodejs.util.inspect.custom")]=f.valueOf,null!=e&&S.set(e),S}(),ts=function(t){function e(t){return i(this,e),r(this,e,[t])}return h(e,t),s(e)}(s((function t(e){i(this,t),u(this,"key",void 0),u(this,"left",null),u(this,"right",null),this.key=e}))),es=function(){return s((function t(){i(this,t),u(this,"size",0),u(this,"modificationCount",0),u(this,"splayCount",0)}),[{key:"splay",value:function(t){var e=this.root;if(null==e)return this.compare(t,t),-1;for(var n,r=null,i=null,o=null,s=null,a=e,u=this.compare;;)if((n=u(a.key,t))>0){var l=a.left;if(null==l)break;if((n=u(l.key,t))>0&&(a.left=l.right,l.right=a,null==(l=(a=l).left)))break;null==r?i=a:r.left=a,r=a,a=l}else{if(!(n<0))break;var h=a.right;if(null==h)break;if((n=u(h.key,t))<0&&(a.right=h.left,h.left=a,null==(h=(a=h).right)))break;null==o?s=a:o.right=a,o=a,a=h}return null!=o&&(o.right=a.left,a.left=s),null!=r&&(r.left=a.right,a.right=i),this.root!==a&&(this.root=a,this.splayCount++),n}},{key:"splayMin",value:function(t){for(var e=t,n=e.left;null!=n;){var r=n;e.left=r.right,r.right=e,n=(e=r).left}return e}},{key:"splayMax",value:function(t){for(var e=t,n=e.right;null!=n;){var r=n;e.right=r.left,r.left=e,n=(e=r).right}return e}},{key:"_delete",value:function(t){if(null==this.root)return null;if(0!=this.splay(t))return null;var e=this.root,n=e,r=e.left;if(this.size--,null==r)this.root=e.right;else{var i=e.right;(e=this.splayMax(r)).right=i,this.root=e}return this.modificationCount++,n}},{key:"addNewRoot",value:function(t,e){this.size++,this.modificationCount++;var n=this.root;null!=n?(e<0?(t.left=n,t.right=n.right,n.right=null):(t.right=n,t.left=n.left,n.left=null),this.root=t):this.root=t}},{key:"_first",value:function(){var t=this.root;return null==t?null:(this.root=this.splayMin(t),this.root)}},{key:"_last",value:function(){var t=this.root;return null==t?null:(this.root=this.splayMax(t),this.root)}},{key:"clear",value:function(){this.root=null,this.size=0,this.modificationCount++}},{key:"has",value:function(t){return this.validKey(t)&&0==this.splay(t)}},{key:"defaultCompare",value:function(){return function(t,e){return te?1:0}}},{key:"wrap",value:function(){var t=this;return{getRoot:function(){return t.root},setRoot:function(e){t.root=e},getSize:function(){return t.size},getModificationCount:function(){return t.modificationCount},getSplayCount:function(){return t.splayCount},setSplayCount:function(e){t.splayCount=e},splay:function(e){return t.splay(e)},has:function(e){return t.has(e)}}}}])}(),ns=function(t){function e(t,n){var o;return i(this,e),u(o=r(this,e),"root",null),u(o,"compare",void 0),u(o,"validKey",void 0),u(o,Symbol.toStringTag,"[object Set]"),o.compare=null!=t?t:o.defaultCompare(),o.validKey=null!=n?n:function(t){return null!=t&&null!=t},o}return h(e,t),s(e,[{key:"delete",value:function(t){return!!this.validKey(t)&&null!=this._delete(t)}},{key:"deleteAll",value:function(t){var e,n=a(t);try{for(n.s();!(e=n.n()).done;){var r=e.value;this.delete(r)}}catch(t){n.e(t)}finally{n.f()}}},{key:"forEach",value:function(t){for(var e,n=this[Symbol.iterator]();!(e=n.next()).done;)t(e.value,e.value,this)}},{key:"add",value:function(t){var e=this.splay(t);return 0!=e&&this.addNewRoot(new ts(t),e),this}},{key:"addAndReturn",value:function(t){var e=this.splay(t);return 0!=e&&this.addNewRoot(new ts(t),e),this.root.key}},{key:"addAll",value:function(t){var e,n=a(t);try{for(n.s();!(e=n.n()).done;){var r=e.value;this.add(r)}}catch(t){n.e(t)}finally{n.f()}}},{key:"isEmpty",value:function(){return null==this.root}},{key:"isNotEmpty",value:function(){return null!=this.root}},{key:"single",value:function(){if(0==this.size)throw"Bad state: No element";if(this.size>1)throw"Bad state: Too many element";return this.root.key}},{key:"first",value:function(){if(0==this.size)throw"Bad state: No element";return this._first().key}},{key:"last",value:function(){if(0==this.size)throw"Bad state: No element";return this._last().key}},{key:"lastBefore",value:function(t){if(null==t)throw"Invalid arguments(s)";if(null==this.root)return null;if(this.splay(t)<0)return this.root.key;var e=this.root.left;if(null==e)return null;for(var n=e.right;null!=n;)n=(e=n).right;return e.key}},{key:"firstAfter",value:function(t){if(null==t)throw"Invalid arguments(s)";if(null==this.root)return null;if(this.splay(t)>0)return this.root.key;var e=this.root.right;if(null==e)return null;for(var n=e.left;null!=n;)n=(e=n).left;return e.key}},{key:"retainAll",value:function(t){var n,r=new e(this.compare,this.validKey),i=this.modificationCount,o=a(t);try{for(o.s();!(n=o.n()).done;){var s=n.value;if(i!=this.modificationCount)throw"Concurrent modification during iteration.";this.validKey(s)&&0==this.splay(s)&&r.add(this.root.key)}}catch(t){o.e(t)}finally{o.f()}r.size!=this.size&&(this.root=r.root,this.size=r.size,this.modificationCount++)}},{key:"lookup",value:function(t){return this.validKey(t)?0!=this.splay(t)?null:this.root.key:null}},{key:"intersection",value:function(t){var n,r=new e(this.compare,this.validKey),i=a(this);try{for(i.s();!(n=i.n()).done;){var o=n.value;t.has(o)&&r.add(o)}}catch(t){i.e(t)}finally{i.f()}return r}},{key:"difference",value:function(t){var n,r=new e(this.compare,this.validKey),i=a(this);try{for(i.s();!(n=i.n()).done;){var o=n.value;t.has(o)||r.add(o)}}catch(t){i.e(t)}finally{i.f()}return r}},{key:"union",value:function(t){var e=this.clone();return e.addAll(t),e}},{key:"clone",value:function(){var t=new e(this.compare,this.validKey);return t.size=this.size,t.root=this.copyNode(this.root),t}},{key:"copyNode",value:function(t){if(null==t)return null;var e=new ts(t.key);return function t(e,n){var r,i;do{if(r=e.left,i=e.right,null!=r){var o=new ts(r.key);n.left=o,t(r,o)}if(null!=i){var s=new ts(i.key);n.right=s,e=i,n=s}}while(null!=i)}(t,e),e}},{key:"toSet",value:function(){return this.clone()}},{key:"entries",value:function(){return new os(this.wrap())}},{key:"keys",value:function(){return this[Symbol.iterator]()}},{key:"values",value:function(){return this[Symbol.iterator]()}},{key:Symbol.iterator,value:function(){return new is(this.wrap())}}])}(es),rs=function(){return s((function t(e){i(this,t),u(this,"tree",void 0),u(this,"path",new Array),u(this,"modificationCount",null),u(this,"splayCount",void 0),this.tree=e,this.splayCount=e.getSplayCount()}),[{key:Symbol.iterator,value:function(){return this}},{key:"next",value:function(){return this.moveNext()?{done:!1,value:this.current()}:{done:!0,value:null}}},{key:"current",value:function(){if(!this.path.length)return null;var t=this.path[this.path.length-1];return this.getValue(t)}},{key:"rebuildPath",value:function(t){this.path.splice(0,this.path.length),this.tree.splay(t),this.path.push(this.tree.getRoot()),this.splayCount=this.tree.getSplayCount()}},{key:"findLeftMostDescendent",value:function(t){for(;null!=t;)this.path.push(t),t=t.left}},{key:"moveNext",value:function(){if(this.modificationCount!=this.tree.getModificationCount()){if(null==this.modificationCount){this.modificationCount=this.tree.getModificationCount();for(var t=this.tree.getRoot();null!=t;)this.path.push(t),t=t.left;return this.path.length>0}throw"Concurrent modification during iteration."}if(!this.path.length)return!1;this.splayCount!=this.tree.getSplayCount()&&this.rebuildPath(this.path[this.path.length-1].key);var e=this.path[this.path.length-1],n=e.right;if(null!=n){for(;null!=n;)this.path.push(n),n=n.left;return!0}for(this.path.pop();this.path.length&&this.path[this.path.length-1].right===e;)e=this.path.pop();return this.path.length>0}}])}(),is=function(t){function e(){return i(this,e),r(this,e,arguments)}return h(e,t),s(e,[{key:"getValue",value:function(t){return t.key}}])}(rs),os=function(t){function e(){return i(this,e),r(this,e,arguments)}return h(e,t),s(e,[{key:"getValue",value:function(t){return[t.key,t.key]}}])}(rs),ss=function(t){return function(){return t}},as=function(t){var e=t?function(e,n){return n.minus(e).abs().isLessThanOrEqualTo(t)}:ss(!1);return function(t,n){return e(t,n)?0:t.comparedTo(n)}};function us(t){var e=t?function(e,n,r,i,o){return e.exponentiatedBy(2).isLessThanOrEqualTo(i.minus(n).exponentiatedBy(2).plus(o.minus(r).exponentiatedBy(2)).times(t))}:ss(!1);return function(t,n,r){var i=t.x,o=t.y,s=r.x,a=r.y,u=o.minus(a).times(n.x.minus(s)).minus(i.minus(s).times(n.y.minus(a)));return e(u,i,o,s,a)?0:u.comparedTo(0)}}var ls=function(t){return t},hs=function(t){if(t){var e=new ns(as(t)),n=new ns(as(t)),r=function(t,e){return e.addAndReturn(t)},i=function(t){return{x:r(t.x,e),y:r(t.y,n)}};return i({x:new $o(0),y:new $o(0)}),i}return ls},cs=function(t){return{set:function(t){fs=cs(t)},reset:function(){return cs(t)},compare:as(t),snap:hs(t),orient:us(t)}},fs=cs(),gs=function(t,e){return t.ll.x.isLessThanOrEqualTo(e.x)&&e.x.isLessThanOrEqualTo(t.ur.x)&&t.ll.y.isLessThanOrEqualTo(e.y)&&e.y.isLessThanOrEqualTo(t.ur.y)},ps=function(t,e){if(e.ur.x.isLessThan(t.ll.x)||t.ur.x.isLessThan(e.ll.x)||e.ur.y.isLessThan(t.ll.y)||t.ur.y.isLessThan(e.ll.y))return null;var n=t.ll.x.isLessThan(e.ll.x)?e.ll.x:t.ll.x,r=t.ur.x.isLessThan(e.ur.x)?t.ur.x:e.ur.x;return{ll:{x:n,y:t.ll.y.isLessThan(e.ll.y)?e.ll.y:t.ll.y},ur:{x:r,y:t.ur.y.isLessThan(e.ur.y)?t.ur.y:e.ur.y}}},vs=function(t,e){return t.x.times(e.y).minus(t.y.times(e.x))},ds=function(t,e){return t.x.times(e.x).plus(t.y.times(e.y))},ys=function(t){return ds(t,t).sqrt()},ms=function(t,e,n){var r={x:e.x.minus(t.x),y:e.y.minus(t.y)},i={x:n.x.minus(t.x),y:n.y.minus(t.y)};return ds(i,r).div(ys(i)).div(ys(r))},_s=function(t,e,n){return e.y.isZero()?null:{x:t.x.plus(e.x.div(e.y).times(n.minus(t.y))),y:n}},xs=function(t,e,n){return e.x.isZero()?null:{x:n,y:t.y.plus(e.y.div(e.x).times(n.minus(t.x)))}},Es=function(){function t(e,n){i(this,t),u(this,"point",void 0),u(this,"isLeft",void 0),u(this,"segment",void 0),u(this,"otherSE",void 0),u(this,"consumedBy",void 0),void 0===e.events?e.events=[this]:e.events.push(this),this.point=e,this.isLeft=n}return s(t,[{key:"link",value:function(t){if(t.point===this.point)throw new Error("Tried to link already linked events");for(var e=t.point.events,n=0,r=e.length;n0&&(t=r)}for(var i=t.segment.prevInResult(),o=i?i.prevInResult():null;;){if(!i)return null;if(!o)return i.ringOut;var s,a;if(o.ringOut!==i.ringOut)return(null===(s=o.ringOut)||void 0===s?void 0:s.enclosingRing())!==i.ringOut?i.ringOut:null===(a=i.ringOut)||void 0===a?void 0:a.enclosingRing();i=o.prevInResult(),o=i?i.prevInResult():null}}}],[{key:"factory",value:function(e){for(var n=[],r=0,i=e.length;r1&&void 0!==arguments[1]?arguments[1]:Ls.compare;i(this,t),u(this,"queue",void 0),u(this,"tree",void 0),u(this,"segments",void 0),this.queue=e,this.tree=new ns(n),this.segments=[]}),[{key:"process",value:function(t){var e=t.segment,n=[];if(t.consumedBy)return t.isLeft?this.queue.delete(t.otherSE):this.tree.delete(e),n;t.isLeft&&this.tree.add(e);var r=e,i=e;do{r=this.tree.lastBefore(r)}while(null!=r&&null!=r.consumedBy);do{i=this.tree.firstAfter(i)}while(null!=i&&null!=i.consumedBy);if(t.isLeft){var o=null;if(r){var s=r.getIntersection(e);if(null!==s&&(e.isAnEndpoint(s)||(o=s),!r.isAnEndpoint(s)))for(var a=this._splitSafely(r,s),u=0,l=a.length;u0?(this.tree.delete(e),n.push(t)):(this.segments.push(e),e.prev=r)}else{if(r&&i){var _=r.getIntersection(i);if(null!==_){if(!r.isAnEndpoint(_))for(var x=this._splitSafely(r,_),E=0,k=x.length;E0&&a.swapEvents(),Es.comparePoints(this.leftSE.point,this.rightSE.point)>0&&this.swapEvents(),r&&(i.checkForConsuming(),o.checkForConsuming()),n}},{key:"swapEvents",value:function(){var t=this.rightSE;this.rightSE=this.leftSE,this.leftSE=t,this.leftSE.isLeft=!0,this.rightSE.isLeft=!1;for(var e=0,n=this.windings.length;e0){var o=n;n=r,r=o}if(n.prev===r){var s=n;n=r,r=s}for(var a=0,u=r.rings.length;a0)return-1;var c=e.comparePoint(t.rightSE.point);return 0!==c?c:-1}if(n.isGreaterThan(r)){if(s.isLessThan(a)&&s.isLessThan(l))return-1;if(s.isGreaterThan(a)&&s.isGreaterThan(l))return 1;var f=e.comparePoint(t.leftSE.point);if(0!==f)return f;var g=t.comparePoint(e.rightSE.point);return g<0?1:g>0?-1:1}if(s.isLessThan(a))return-1;if(s.isGreaterThan(a))return 1;if(i.isLessThan(o)){var p=e.comparePoint(t.rightSE.point);if(0!==p)return p}if(i.isGreaterThan(o)){var v=t.comparePoint(e.rightSE.point);if(v<0)return 1;if(v>0)return-1}if(!i.eq(o)){var d=u.minus(s),y=i.minus(n),m=l.minus(a),_=o.minus(r);if(d.isGreaterThan(y)&&m.isLessThan(_))return 1;if(d.isLessThan(y)&&m.isGreaterThan(_))return-1}return i.isGreaterThan(o)?1:i.isLessThan(o)||u.isLessThan(l)?-1:u.isGreaterThan(l)?1:t.ide.id?1:0}},{key:"fromRing",value:function(e,n,r){var i,o,s,a=Es.comparePoints(e,n);if(a<0)i=e,o=n,s=1;else{if(!(a>0))throw new Error("Tried to create degenerate segment at [".concat(e.x,", ").concat(e.y,"]"));i=n,o=e,s=-1}return new t(new Es(i,!0),new Es(o,!1),[r],[s])}}])}(),Ps=function(){return s((function t(e,n,r){if(i(this,t),u(this,"poly",void 0),u(this,"isExterior",void 0),u(this,"segments",void 0),u(this,"bbox",void 0),!Array.isArray(e)||0===e.length)throw new Error("Input geometry is not a valid Polygon or MultiPolygon");if(this.poly=n,this.isExterior=r,this.segments=[],"number"!=typeof e[0][0]||"number"!=typeof e[0][1])throw new Error("Input geometry is not a valid Polygon or MultiPolygon");var o=fs.snap({x:new $o(e[0][0]),y:new $o(e[0][1])});this.bbox={ll:{x:o.x,y:o.y},ur:{x:o.x,y:o.y}};for(var s=o,a=1,l=e.length;a1?e-1:0),r=1;r1?e-1:0),r=1;r1?e-1:0),r=1;r1?e-1:0),r=1;r2&&void 0!==arguments[2]?arguments[2]:2,r=K(t),i=K(e),o=r[0]-i[0],s=r[1]-i[1];return 1===n?Math.abs(o)+Math.abs(s):Math.pow(Math.pow(o,n)+Math.pow(s,n),1/n)}function Gs(t,e){var n,r,i=(e=e||{}).threshold||1e4,o=e.p||2,s=null!=(n=e.binary)&&n,a=e.alpha||-1,u=null!=(r=e.standardization)&&r,l=[];vt(t,(function(t){l.push(gi(t))}));for(var h=[],c=0;c3&&void 0!==arguments[3]?arguments[3]:{},i=e<0,o=j(Math.abs(e),r.units,"meters");i&&(o=-Math.abs(o));var s=K(t),a=function(t,e,n,r){r=void 0===r?x:Number(r);var i=e/r,o=t[0]*Math.PI/180,s=z(t[1]),a=z(n),u=i*Math.cos(a),l=s+u;Math.abs(l)>Math.PI/2&&(l=l>0?Math.PI-l:-Math.PI-l);var h=Math.log(Math.tan(l/2+Math.PI/4)/Math.tan(s/2+Math.PI/4)),c=Math.abs(h)>1e-11?u/h:Math.cos(s),f=i*Math.sin(a)/c;return[(180*(o+f)/Math.PI+540)%360-180,180*l/Math.PI]}(s,o,n);return a[0]+=a[0]-s[0]>180?-360:s[0]-a[0]>180?360:0,I(a,r.properties)}function Ys(t,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=K(t),i=K(e);i[0]+=i[0]-r[0]>180?-360:r[0]-i[0]>180?360:0;var o=function(t,e,n){var r=n=void 0===n?x:Number(n),i=t[1]*Math.PI/180,o=e[1]*Math.PI/180,s=o-i,a=Math.abs(e[0]-t[0])*Math.PI/180;a>Math.PI&&(a-=2*Math.PI);var u=Math.log(Math.tan(o/2+Math.PI/4)/Math.tan(i/2+Math.PI/4)),l=Math.abs(u)>1e-11?s/u:Math.cos(i);return Math.sqrt(s*s+l*l*a*a)*r}(r,i);return j(o,"meters",n.units)}function zs(t,e,n){if(!Z(n=n||{}))throw new Error("options is invalid");var r=n.pivot,i=n.mutate;if(!t)throw new Error("geojson is required");if(null==e||isNaN(e))throw new Error("angle is required");if(0===e)return t;var o=null!=r?r:gi(t);return!1!==i&&void 0!==i||(t=Ai(t)),ct(t,(function(t){var n=lt(o,t)+e,r=Ys(o,t),i=Q(Bs(o,r,n));t[0]=i[0],t[1]=i[1]})),t}function js(t,e,n,r){var i=(r=r||{}).steps||64,o=r.units||"kilometers",s=r.angle||0,a=r.pivot||t,u=r.properties||{};if(!t)throw new Error("center is required");if(!e)throw new Error("xSemiAxis is required");if(!n)throw new Error("ySemiAxis is required");if(!Z(r))throw new Error("options must be an object");if(!U(i))throw new Error("steps must be a number");if(!U(s))throw new Error("angle must be a number");var l=K(t);if("degrees"!==o){var h=Bs(t,e,90,{units:o}),c=Bs(t,n,0,{units:o});e=K(h)[0]-l[0],n=K(c)[1]-l[1]}for(var f=[],g=0;g=-270&&(v=-v),p<-180&&p>=-360&&(d=-d),"degrees"===o){var y=z(s),m=v*Math.cos(y)+d*Math.sin(y),_=d*Math.cos(y)-v*Math.sin(y);v=m,d=_}f.push([v+l[0],d+l[1]])}return f.push(f[0]),"degrees"===o?S([f],u):zs(S([f],u),s,{pivot:a})}function Xs(t){var e=t*Math.PI/180;return Math.tan(e)}function Us(t){return Vt(Rt(t))}function Zs(t){var e=[];return"FeatureCollection"===t.type?vt(t,(function(t){ct(t,(function(n){e.push(I(n,t.properties))}))})):"Feature"===t.type?ct(t,(function(n){e.push(I(n,t.properties))})):ct(t,(function(t){e.push(I(t))})),C(e)}var Hs=Math.PI/180,Ws=180/Math.PI,Js=function(t,e){this.lon=t,this.lat=e,this.x=Hs*t,this.y=Hs*e};Js.prototype.view=function(){return String(this.lon).slice(0,4)+","+String(this.lat).slice(0,4)},Js.prototype.antipode=function(){var t=-1*this.lat,e=this.lon<0?180+this.lon:-1*(180-this.lon);return new Js(e,t)};var Ks=function(){this.coords=[],this.length=0};Ks.prototype.move_to=function(t){this.length++,this.coords.push(t)};var Qs=function(t){this.properties=t||{},this.geometries=[]};Qs.prototype.json=function(){if(this.geometries.length<=0)return{geometry:{type:"LineString",coordinates:null},type:"Feature",properties:this.properties};if(1===this.geometries.length)return{geometry:{type:"LineString",coordinates:this.geometries[0].coords},type:"Feature",properties:this.properties};for(var t=[],e=0;e1&&void 0!==arguments[1]?arguments[1]:{},n=[];if(mt(t,(function(t){n.push(t.coordinates)})),n.length<2)throw new Error("Must specify at least 2 geometries");var r=Rs.apply(Fs,[n[0]].concat(d(n.slice(1))));return 0===r.length?null:1===r.length?S(r[0],e.properties):R(r,e.properties)}function ea(t,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=JSON.stringify(n.properties||{}),i=v(t,4),o=i[0],s=i[1],a=i[2],u=i[3],l=(s+u)/2,h=(o+a)/2,c=2*e/ut([o,l],[a,l],n)*(a-o),f=2*e/ut([h,s],[h,u],n)*(u-s),g=c/2,p=2*g,d=Math.sqrt(3)/2*f,y=a-o,m=u-s,_=3/4*p,x=d,E=(y-p)/(p-g/2),k=Math.floor(E),b=(k*_-g/2-y)/2-g/2+_/2,w=Math.floor((m-d)/d),I=(m-w*d)/2,N=w*d-m>d/2;N&&(I-=d/4);for(var S=[],M=[],L=0;L<6;L++){var P=2*Math.PI/6*L;S.push(Math.cos(P)),M.push(Math.sin(P))}for(var T=[],O=0;O<=k;O++)for(var R=0;R<=w;R++){var A=O%2==1;if((0!==R||!A)&&(0!==R||!N)){var D=O*_+o-b,F=R*x+s+I;if(A&&(F-=d/2),!0===n.triangles)ra([D,F],c/2,f/2,JSON.parse(r),S,M).forEach((function(t){n.mask?ta(C([n.mask,t]))&&T.push(t):T.push(t)}));else{var q=na([D,F],c/2,f/2,JSON.parse(r),S,M);n.mask?ta(C([n.mask,q]))&&T.push(q):T.push(q)}}}return C(T)}function na(t,e,n,r,i,o){for(var s=[],a=0;a<6;a++){var u=t[0]+e*i[a],l=t[1]+n*o[a];s.push([u,l])}return s.push(s[0].slice()),S([s],r)}function ra(t,e,n,r,i,o){for(var s=[],a=0;a<6;a++){var u=[];u.push(t),u.push([t[0]+e*i[a],t[1]+n*o[a]]),u.push([t[0]+e*i[(a+1)%6],t[1]+n*o[(a+1)%6]]),u.push(t),s.push(S([u],r))}return s}function ia(t,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};n.mask&&!n.units&&(n.units="kilometers");for(var r=[],i=t[0],o=t[1],s=t[2],a=t[3],u=e/ut([i,o],[s,o],n)*(s-i),l=e/ut([i,o],[i,a],n)*(a-o),h=s-i,c=a-o,f=Math.floor(h/u),g=(c-Math.floor(c/l)*l)/2,p=i+(h-f*u)/2;p<=s;){for(var v=o+g;v<=a;){var d=I([p,v],n.properties);n.mask?Cn(d,n.mask)&&r.push(d):r.push(d),v+=l}p+=u}return C(r)}function oa(t,e,n){for(var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},i=[],o=t[0],s=t[1],a=t[2],u=t[3],l=a-o,h=j(e,r.units,"degrees"),c=u-s,f=j(n,r.units,"degrees"),g=Math.floor(Math.abs(l)/h),p=Math.floor(Math.abs(c)/f),v=(c-p*f)/2,d=o+(l-g*h)/2,y=0;y2&&void 0!==arguments[2]?arguments[2]:{})}function aa(t,e){for(var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=[],i=e/ut([t[0],t[1]],[t[2],t[1]],n)*(t[2]-t[0]),o=e/ut([t[0],t[1]],[t[0],t[3]],n)*(t[3]-t[1]),s=0,a=t[0];a<=t[2];){for(var u=0,l=t[1];l<=t[3];){var h=null,c=null;s%2==0&&u%2==0?(h=S([[[a,l],[a,l+o],[a+i,l],[a,l]]],n.properties),c=S([[[a,l+o],[a+i,l+o],[a+i,l],[a,l+o]]],n.properties)):s%2==0&&u%2==1?(h=S([[[a,l],[a+i,l+o],[a+i,l],[a,l]]],n.properties),c=S([[[a,l],[a,l+o],[a+i,l+o],[a,l]]],n.properties)):u%2==0&&s%2==1?(h=S([[[a,l],[a,l+o],[a+i,l+o],[a,l]]],n.properties),c=S([[[a,l],[a+i,l+o],[a+i,l],[a,l]]],n.properties)):u%2==1&&s%2==1&&(h=S([[[a,l],[a,l+o],[a+i,l],[a,l]]],n.properties),c=S([[[a,l+o],[a+i,l+o],[a+i,l],[a,l+o]]],n.properties)),n.mask?(ta(C([n.mask,h]))&&r.push(h),ta(C([n.mask,c]))&&r.push(c)):(r.push(h),r.push(c)),l+=o,u++}s++,a+=i}return C(r)} +/*! + * MarchingSquaresJS + * version 1.3.3 + * https://github.com/RaumZeit/MarchingSquares.js + * + * @license GNU Affero General Public License. + * Copyright (c) 2015-2019 Ronny Lorenz + */ +function ua(t,e,n){return tr&&(i=n,n=r,r=i),tr?(t-r)/(t-e):(t-n)/(t-e)}function ha(t,e,n,r){return t1){for(;0!==o;)o>>=1,a++;r===1<1){for(;0!==s;)s>>=1,u++;i===1<0&&(this.childB=new da(t,e+o,n,r-o,s),this.lowerBound=Math.min(this.lowerBound,this.childB.lowerBound),this.upperBound=Math.max(this.upperBound,this.childB.upperBound),i-s>0&&(this.childC=new da(t,e+o,n+s,r-o,i-s),this.lowerBound=Math.min(this.lowerBound,this.childC.lowerBound),this.upperBound=Math.max(this.upperBound,this.childC.upperBound))),i-s>0&&(this.childD=new da(t,e,n+s,o,i-s),this.lowerBound=Math.min(this.lowerBound,this.childD.lowerBound),this.upperBound=Math.max(this.upperBound,this.childD.upperBound))}}function ya(t){var e,n;if(!t)throw new Error("data is required");if(!Array.isArray(t)||!Array.isArray(t[0]))throw new Error("data must be scalar field, i.e. array of arrays");if(t.length<2)throw new Error("data must contain at least two rows");if((n=t[0].length)<2)throw new Error("data must contain at least two columns");for(e=1;e=e||t[s][r-1]>=e){n=!1;break}if(n&&(t[i-1][0]>=e||t[i-1][r-1]>=e)&&(n=!1),n)for(o=0;o=e||t[i-1][o]>e){n=!1;break}return n}(t,n.threshold)&&(n.linearRing?_.push([[0,0],[0,x],[E,x],[E,0],[0,0]]):_.push([[0,0],[0,x],[E,x],[E,0]])),e.forEach((function(t,N){t.forEach((function(t,S){for(r=null,i=0;i<4;i++)if(r=k[i],"object"===m(t.edges[r])){for(a=[],o=t.edges[r],u=r,l=N,h=S,c=!1,f=[N+o.path[0][0],S+o.path[0][1]],a.push(f);!c&&"object"===m((s=e[l][h]).edges[u]);)if(o=s.edges[u],delete s.edges[u],(g=o.path[1])[0]+=l,g[1]+=h,a.push(g),u=o.move.enter,l+=o.move.x,h+=o.move.y,void 0===e[l]||void 0===e[l][h]){if(!n.linearRing)break;if(p=0,v=0,l===E?(l--,p=0):l<0?(l++,p=2):h===x?(h--,p=3):h<0&&(h++,p=1),l===N&&h===S&&p===I[r]){c=!0,u=r;break}for(;;){if(d=!1,v>4)throw new Error("Direction change counter overflow! This should never happen!");if(void 0!==e[l]&&void 0!==e[l][h]&&(s=e[l][h],y=k[p],"object"===m(s.edges[y]))){o=s.edges[y],a.push(pa(l,h,p,o.path)),u=y,d=!0;break}if(d)break;if(a.push(va(l,h,p)),h+=w[p],void 0!==e[l+=b[p]]&&void 0!==e[l][h]||(0===p&&h<0||1===p&&l<0||2===p&&h===x||3===p&&l===E)&&(l-=b[p],h-=w[p],p=(p+1)%4,v++),l===N&&h===S&&p===I[r]){c=!0,u=r;break}}}!n.linearRing||a[a.length-1][0]===f[0]&&a[a.length-1][1]===f[1]||a.push(f),_.push(a)}}))})),_}(h,c,r)}a?g.push(f):g=f,"function"==typeof r.successCallback&&r.successCallback(g,t)})),g}function _a(t,e,n,r){var i,o,s,a,u,l,h=0,c=t[n+1][e],f=t[n+1][e+1],g=t[n][e+1],p=t[n][e],v=r.threshold;if(!(isNaN(p)||isNaN(g)||isNaN(f)||isNaN(c))){switch(h|=c>=v?8:0,h|=f>=v?4:0,h|=g>=v?2:0,l={cval:h=+(h|=p>=v?1:0),polygons:[],edges:{},x0:p,x1:g,x2:f,x3:c},h){case 0:r.polygons&&l.polygons.push([[0,0],[0,1],[1,1],[1,0]]);break;case 15:break;case 14:i=r.interpolate(p,c,v),a=r.interpolate(p,g,v),r.polygons_full&&(l.edges.left={path:[[0,i],[a,0]],move:{x:0,y:-1,enter:"top"}}),r.polygons&&l.polygons.push([[0,0],[0,i],[a,0]]);break;case 13:a=r.interpolate(p,g,v),o=r.interpolate(g,f,v),r.polygons_full&&(l.edges.bottom={path:[[a,0],[1,o]],move:{x:1,y:0,enter:"left"}}),r.polygons&&l.polygons.push([[a,0],[1,o],[1,0]]);break;case 11:o=r.interpolate(g,f,v),s=r.interpolate(c,f,v),r.polygons_full&&(l.edges.right={path:[[1,o],[s,1]],move:{x:0,y:1,enter:"bottom"}}),r.polygons&&l.polygons.push([[1,o],[s,1],[1,1]]);break;case 7:i=r.interpolate(p,c,v),s=r.interpolate(c,f,v),r.polygons_full&&(l.edges.top={path:[[s,1],[0,i]],move:{x:-1,y:0,enter:"right"}}),r.polygons&&l.polygons.push([[s,1],[0,i],[0,1]]);break;case 1:i=r.interpolate(p,c,v),a=r.interpolate(p,g,v),r.polygons_full&&(l.edges.bottom={path:[[a,0],[0,i]],move:{x:-1,y:0,enter:"right"}}),r.polygons&&l.polygons.push([[a,0],[0,i],[0,1],[1,1],[1,0]]);break;case 2:a=r.interpolate(p,g,v),o=r.interpolate(g,f,v),r.polygons_full&&(l.edges.right={path:[[1,o],[a,0]],move:{x:0,y:-1,enter:"top"}}),r.polygons&&l.polygons.push([[0,0],[0,1],[1,1],[1,o],[a,0]]);break;case 4:o=r.interpolate(g,f,v),s=r.interpolate(c,f,v),r.polygons_full&&(l.edges.top={path:[[s,1],[1,o]],move:{x:1,y:0,enter:"left"}}),r.polygons&&l.polygons.push([[0,0],[0,1],[s,1],[1,o],[1,0]]);break;case 8:i=r.interpolate(p,c,v),s=r.interpolate(c,f,v),r.polygons_full&&(l.edges.left={path:[[0,i],[s,1]],move:{x:0,y:1,enter:"bottom"}}),r.polygons&&l.polygons.push([[0,0],[0,i],[s,1],[1,1],[1,0]]);break;case 12:i=r.interpolate(p,c,v),o=r.interpolate(g,f,v),r.polygons_full&&(l.edges.left={path:[[0,i],[1,o]],move:{x:1,y:0,enter:"left"}}),r.polygons&&l.polygons.push([[0,0],[0,i],[1,o],[1,0]]);break;case 9:a=r.interpolate(p,g,v),s=r.interpolate(c,f,v),r.polygons_full&&(l.edges.bottom={path:[[a,0],[s,1]],move:{x:0,y:1,enter:"bottom"}}),r.polygons&&l.polygons.push([[a,0],[s,1],[1,1],[1,0]]);break;case 3:i=r.interpolate(p,c,v),o=r.interpolate(g,f,v),r.polygons_full&&(l.edges.right={path:[[1,o],[0,i]],move:{x:-1,y:0,enter:"right"}}),r.polygons&&l.polygons.push([[0,i],[0,1],[1,1],[1,o]]);break;case 6:a=r.interpolate(p,g,v),s=r.interpolate(c,f,v),r.polygons_full&&(l.edges.top={path:[[s,1],[a,0]],move:{x:0,y:-1,enter:"top"}}),r.polygons&&l.polygons.push([[0,0],[0,1],[s,1],[a,0]]);break;case 10:i=r.interpolate(p,c,v),o=r.interpolate(g,f,v),a=r.interpolate(p,g,v),s=r.interpolate(c,f,v),u=(p+g+f+c)/4,r.polygons_full&&(uf&&(v>h&&ph&&vu&&(u=d)}var y=[];if(a&&u0&&Math.abs(x-n[_-1][0])>f){var E=parseFloat(n[_-1][0]),k=parseFloat(n[_-1][1]),b=parseFloat(n[_][0]),w=parseFloat(n[_][1]);if(E>-180&&E-180&&n[_-1][0]h&&E<180&&-180===b&&_+1h&&n[_-1][0]<180){m.push([180,n[_][1]]),_++,m.push([n[_][0],n[_][1]]);continue}if(Eh){var I=E;E=b,b=I;var N=k;k=w,w=N}if(E>h&&b=180&&Eh?180:-180,M]),(m=[]).push([n[_-1][0]>h?-180:180,M]),y.push(m)}else m=[],y.push(m);m.push([x,n[_][1]])}else m.push([n[_][0],n[_][1]])}}else{var L=[];y.push(L);for(var P=0;Pe||this.upperBound=e)&&r.push({x:this.x,y:this.y})),r},da.prototype.cellsBelowThreshold=function(t,e){var n=[];return e=void 0===e||e,this.lowerBound>t||(this.childA||this.childB||this.childC||this.childD?(this.childA&&(n=n.concat(this.childA.cellsBelowThreshold(t,e))),this.childB&&(n=n.concat(this.childB.cellsBelowThreshold(t,e))),this.childD&&(n=n.concat(this.childD.cellsBelowThreshold(t,e))),this.childC&&(n=n.concat(this.childC.cellsBelowThreshold(t,e)))):(e||this.upperBound>=t)&&n.push({x:this.x,y:this.y})),n};var xa={square:function(t,e,n,r,i,o){o.polygons&&t.polygons.push([[0,0],[0,1],[1,1],[1,0]])},triangle_bl:function(t,e,n,r,i,o){var s=o.interpolate(e,n,o.minV,o.maxV),a=o.interpolate(e,i,o.minV,o.maxV);o.polygons_full&&(t.edges.lb={path:[[0,a],[s,0]],move:{x:0,y:-1,enter:"tl"}}),o.polygons&&t.polygons.push([[0,a],[s,0],[0,0]])},triangle_br:function(t,e,n,r,i,o){var s=o.interpolate(e,n,o.minV,o.maxV),a=o.interpolate(n,r,o.minV,o.maxV);o.polygons_full&&(t.edges.br={path:[[s,0],[1,a]],move:{x:1,y:0,enter:"lb"}}),o.polygons&&t.polygons.push([[s,0],[1,a],[1,0]])},triangle_tr:function(t,e,n,r,i,o){var s=o.interpolate(n,r,o.minV,o.maxV),a=o.interpolate(i,r,o.minV,o.maxV);o.polygons_full&&(t.edges.rt={path:[[1,s],[a,1]],move:{x:0,y:1,enter:"br"}}),o.polygons&&t.polygons.push([[1,s],[a,1],[1,1]])},triangle_tl:function(t,e,n,r,i,o){var s=o.interpolate(i,r,o.minV,o.maxV),a=o.interpolate(e,i,o.minV,o.maxV);o.polygons_full&&(t.edges.tl={path:[[s,1],[0,a]],move:{x:-1,y:0,enter:"rt"}}),o.polygons&&t.polygons.push([[0,a],[0,1],[s,1]])},tetragon_t:function(t,e,n,r,i,o){var s=o.interpolate(n,r,o.minV,o.maxV),a=o.interpolate(e,i,o.minV,o.maxV);o.polygons_full&&(t.edges.rt={path:[[1,s],[0,a]],move:{x:-1,y:0,enter:"rt"}}),o.polygons&&t.polygons.push([[0,a],[0,1],[1,1],[1,s]])},tetragon_r:function(t,e,n,r,i,o){var s=o.interpolate(e,n,o.minV,o.maxV),a=o.interpolate(i,r,o.minV,o.maxV);o.polygons_full&&(t.edges.br={path:[[s,0],[a,1]],move:{x:0,y:1,enter:"br"}}),o.polygons&&t.polygons.push([[s,0],[a,1],[1,1],[1,0]])},tetragon_b:function(t,e,n,r,i,o){var s=o.interpolate(e,i,o.minV,o.maxV),a=o.interpolate(n,r,o.minV,o.maxV);o.polygons_full&&(t.edges.lb={path:[[0,s],[1,a]],move:{x:1,y:0,enter:"lb"}}),o.polygons&&t.polygons.push([[0,0],[0,s],[1,a],[1,0]])},tetragon_l:function(t,e,n,r,i,o){var s=o.interpolate(i,r,o.minV,o.maxV),a=o.interpolate(e,n,o.minV,o.maxV);o.polygons_full&&(t.edges.tl={path:[[s,1],[a,0]],move:{x:0,y:-1,enter:"tl"}}),o.polygons&&t.polygons.push([[0,0],[0,1],[s,1],[a,0]])},tetragon_bl:function(t,e,n,r,i,o){var s=o.interpolate_a(e,n,o.minV,o.maxV),a=o.interpolate_b(e,n,o.minV,o.maxV),u=o.interpolate_a(e,i,o.minV,o.maxV),l=o.interpolate_b(e,i,o.minV,o.maxV);o.polygons_full&&(t.edges.bl={path:[[s,0],[0,u]],move:{x:-1,y:0,enter:"rb"}},t.edges.lt={path:[[0,l],[a,0]],move:{x:0,y:-1,enter:"tr"}}),o.polygons&&t.polygons.push([[s,0],[0,u],[0,l],[a,0]])},tetragon_br:function(t,e,n,r,i,o){var s=o.interpolate_a(e,n,o.minV,o.maxV),a=o.interpolate_b(e,n,o.minV,o.maxV),u=o.interpolate_a(n,r,o.minV,o.maxV),l=o.interpolate_b(n,r,o.minV,o.maxV);o.polygons_full&&(t.edges.bl={path:[[s,0],[1,l]],move:{x:1,y:0,enter:"lt"}},t.edges.rb={path:[[1,u],[a,0]],move:{x:0,y:-1,enter:"tr"}}),o.polygons&&t.polygons.push([[s,0],[1,l],[1,u],[a,0]])},tetragon_tr:function(t,e,n,r,i,o){var s=o.interpolate_a(i,r,o.minV,o.maxV),a=o.interpolate_b(i,r,o.minV,o.maxV),u=o.interpolate_b(n,r,o.minV,o.maxV),l=o.interpolate_a(n,r,o.minV,o.maxV);o.polygons_full&&(t.edges.rb={path:[[1,l],[s,1]],move:{x:0,y:1,enter:"bl"}},t.edges.tr={path:[[a,1],[1,u]],move:{x:1,y:0,enter:"lt"}}),o.polygons&&t.polygons.push([[1,l],[s,1],[a,1],[1,u]])},tetragon_tl:function(t,e,n,r,i,o){var s=o.interpolate_a(i,r,o.minV,o.maxV),a=o.interpolate_b(i,r,o.minV,o.maxV),u=o.interpolate_b(e,i,o.minV,o.maxV),l=o.interpolate_a(e,i,o.minV,o.maxV);o.polygons_full&&(t.edges.tr={path:[[a,1],[0,l]],move:{x:-1,y:0,enter:"rb"}},t.edges.lt={path:[[0,u],[s,1]],move:{x:0,y:1,enter:"bl"}}),o.polygons&&t.polygons.push([[a,1],[0,l],[0,u],[s,1]])},tetragon_lr:function(t,e,n,r,i,o){var s=o.interpolate_a(e,i,o.minV,o.maxV),a=o.interpolate_b(e,i,o.minV,o.maxV),u=o.interpolate_b(n,r,o.minV,o.maxV),l=o.interpolate_a(n,r,o.minV,o.maxV);o.polygons_full&&(t.edges.lt={path:[[0,a],[1,u]],move:{x:1,y:0,enter:"lt"}},t.edges.rb={path:[[1,l],[0,s]],move:{x:-1,y:0,enter:"rb"}}),o.polygons&&t.polygons.push([[0,s],[0,a],[1,u],[1,l]])},tetragon_tb:function(t,e,n,r,i,o){var s=o.interpolate_a(i,r,o.minV,o.maxV),a=o.interpolate_b(i,r,o.minV,o.maxV),u=o.interpolate_b(e,n,o.minV,o.maxV),l=o.interpolate_a(e,n,o.minV,o.maxV);o.polygons_full&&(t.edges.tr={path:[[a,1],[u,0]],move:{x:0,y:-1,enter:"tr"}},t.edges.bl={path:[[l,0],[s,1]],move:{x:0,y:1,enter:"bl"}}),o.polygons&&t.polygons.push([[l,0],[s,1],[a,1],[u,0]])},pentagon_tr:function(t,e,n,r,i,o){var s=o.interpolate(i,r,o.minV,o.maxV),a=o.interpolate(n,r,o.minV,o.maxV);o.polygons_full&&(t.edges.tl={path:[[s,1],[1,a]],move:{x:1,y:0,enter:"lb"}}),o.polygons&&t.polygons.push([[0,0],[0,1],[s,1],[1,a],[1,0]])},pentagon_tl:function(t,e,n,r,i,o){var s=o.interpolate(e,i,o.minV,o.maxV),a=o.interpolate(i,r,o.minV,o.maxV);o.polygons_full&&(t.edges.lb={path:[[0,s],[a,1]],move:{x:0,y:1,enter:"br"}}),o.polygons&&t.polygons.push([[0,0],[0,s],[a,1],[1,1],[1,0]])},pentagon_br:function(t,e,n,r,i,o){var s=o.interpolate(e,n,o.minV,o.maxV),a=o.interpolate(n,r,o.minV,o.maxV);o.polygons_full&&(t.edges.rt={path:[[1,a],[s,0]],move:{x:0,y:-1,enter:"tl"}}),o.polygons&&t.polygons.push([[0,0],[0,1],[1,1],[1,a],[s,0]])},pentagon_bl:function(t,e,n,r,i,o){var s=o.interpolate(e,i,o.minV,o.maxV),a=o.interpolate(e,n,o.minV,o.maxV);o.polygons_full&&(t.edges.br={path:[[a,0],[0,s]],move:{x:-1,y:0,enter:"rt"}}),o.polygons&&t.polygons.push([[0,s],[0,1],[1,1],[1,0],[a,0]])},pentagon_tr_rl:function(t,e,n,r,i,o){var s=o.interpolate(e,i,o.minV,o.maxV),a=o.interpolate(i,r,o.minV,o.maxV),u=o.interpolate_b(n,r,o.minV,o.maxV),l=o.interpolate_a(n,r,o.minV,o.maxV);o.polygons_full&&(t.edges.tl={path:[[a,1],[1,u]],move:{x:1,y:0,enter:"lt"}},t.edges.rb={path:[[1,l],[0,s]],move:{x:-1,y:0,enter:"rt"}}),o.polygons&&t.polygons.push([[0,s],[0,1],[a,1],[1,u],[1,l]])},pentagon_rb_bt:function(t,e,n,r,i,o){var s=o.interpolate(n,r,o.minV,o.maxV),a=o.interpolate_b(e,n,o.minV,o.maxV),u=o.interpolate_a(e,n,o.minV,o.maxV),l=o.interpolate(i,r,o.minV,o.maxV);o.polygons_full&&(t.edges.rt={path:[[1,s],[a,0]],move:{x:0,y:-1,enter:"tr"}},t.edges.bl={path:[[u,0],[l,1]],move:{x:0,y:1,enter:"br"}}),o.polygons&&t.polygons.push([[l,1],[1,1],[1,s],[a,0],[u,0]])},pentagon_bl_lr:function(t,e,n,r,i,o){var s=o.interpolate(e,n,o.minV,o.maxV),a=o.interpolate_a(e,i,o.minV,o.maxV),u=o.interpolate_b(e,i,o.minV,o.maxV),l=o.interpolate(n,r,o.minV,o.maxV);o.polygons_full&&(t.edges.br={path:[[s,0],[0,a]],move:{x:-1,y:0,enter:"rb"}},t.edges.lt={path:[[0,u],[1,l]],move:{x:1,y:0,enter:"lb"}}),o.polygons&&t.polygons.push([[s,0],[0,a],[0,u],[1,l],[1,0]])},pentagon_lt_tb:function(t,e,n,r,i,o){var s=o.interpolate(e,i,o.minV,o.maxV),a=o.interpolate_a(i,r,o.minV,o.maxV),u=o.interpolate_b(i,r,o.minV,o.maxV),l=o.interpolate(e,n,o.minV,o.maxV);o.polygons_full&&(t.edges.lb={path:[[0,s],[a,1]],move:{x:0,y:1,enter:"bl"}},t.edges.tr={path:[[u,1],[l,0]],move:{x:0,y:-1,enter:"tl"}}),o.polygons&&t.polygons.push([[0,0],[0,s],[a,1],[u,1],[l,0]])},pentagon_bl_tb:function(t,e,n,r,i,o){var s=o.interpolate(e,i,o.minV,o.maxV),a=o.interpolate(i,r,o.minV,o.maxV),u=o.interpolate_b(e,n,o.minV,o.maxV),l=o.interpolate_a(e,n,o.minV,o.maxV);o.polygons_full&&(t.edges.bl={path:[[l,0],[0,s]],move:{x:-1,y:0,enter:"rt"}},t.edges.tl={path:[[a,1],[u,0]],move:{x:0,y:-1,enter:"tr"}}),o.polygons&&t.polygons.push([[0,s],[0,1],[a,1],[u,0],[l,0]])},pentagon_lt_rl:function(t,e,n,r,i,o){var s=o.interpolate_a(e,i,o.minV,o.maxV),a=o.interpolate_b(e,i,o.minV,o.maxV),u=o.interpolate(i,r,o.minV,o.maxV),l=o.interpolate(n,i,o.minV,o.maxV);o.polygons_full&&(t.edges.lt={path:[[0,a],[u,1]],move:{x:0,y:1,enter:"br"}},t.edges.rt={path:[[1,l],[0,s]],move:{x:-1,y:0,enter:"rb"}}),o.polygons&&t.polygons.push([[0,s],[0,a],[u,1],[1,1],[1,l]])},pentagon_tr_bt:function(t,e,n,r,i,o){var s=o.interpolate_a(i,r,o.minV,o.maxV),a=o.interpolate_b(i,r,o.minV,o.maxV),u=o.interpolate(n,r,o.minV,o.maxV),l=o.interpolate(e,n,o.minV,o.maxV);o.polygons_full&&(t.edges.br={path:[[l,0],[s,1]],move:{x:0,y:1,enter:"bl"}},t.edges.tr={path:[[a,1],[1,u]],move:{x:1,y:0,enter:"lb"}}),o.polygons&&t.polygons.push([[s,1],[a,1],[1,u],[1,0],[l,0]])},pentagon_rb_lr:function(t,e,n,r,i,o){var s=o.interpolate(e,i,o.minV,o.maxV),a=o.interpolate_b(n,r,o.minV,o.maxV),u=o.interpolate_a(n,r,o.minV,o.maxV),l=o.interpolate(e,n,o.minV,o.maxV);o.polygons_full&&(t.edges.lb={path:[[0,s],[1,a]],move:{x:1,y:0,enter:"lt"}},t.edges.rb={path:[[1,u],[l,0]],move:{x:0,y:-1,enter:"tl"}}),o.polygons&&t.polygons.push([[0,0],[0,s],[1,a],[1,u],[l,0]])},hexagon_lt_tr:function(t,e,n,r,i,o){var s=o.interpolate(e,i,o.minV,o.maxV),a=o.interpolate_a(i,r,o.minV,o.maxV),u=o.interpolate_b(i,r,o.minV,o.maxV),l=o.interpolate(n,r,o.minV,o.maxV);o.polygons_full&&(t.edges.lb={path:[[0,s],[a,1]],move:{x:0,y:1,enter:"bl"}},t.edges.tr={path:[[u,1],[1,l]],move:{x:1,y:0,enter:"lb"}}),o.polygons&&t.polygons.push([[0,0],[0,s],[a,1],[u,1],[1,l],[1,0]])},hexagon_bl_lt:function(t,e,n,r,i,o){var s=o.interpolate(e,n,o.minV,o.maxV),a=o.interpolate_a(e,i,o.minV,o.maxV),u=o.interpolate_b(e,i,o.minV,o.maxV),l=o.interpolate(i,r,o.minV,o.maxV);o.polygons_full&&(t.edges.br={path:[[s,0],[0,a]],move:{x:-1,y:0,enter:"rb"}},t.edges.lt={path:[[0,u],[l,1]],move:{x:0,y:1,enter:"br"}}),o.polygons&&t.polygons.push([[s,0],[0,a],[0,u],[l,1],[1,1],[1,0]])},hexagon_bl_rb:function(t,e,n,r,i,o){var s=o.interpolate_a(e,n,o.minV,o.maxV),a=o.interpolate_b(e,n,o.minV,o.maxV),u=o.interpolate(e,i,o.minV,o.maxV),l=o.interpolate(n,r,o.minV,o.maxV);o.polygons_full&&(t.edges.bl={path:[[s,0],[0,u]],move:{x:-1,y:0,enter:"rt"}},t.edges.rt={path:[[1,l],[a,0]],move:{x:0,y:-1,enter:"tr"}}),o.polygons&&t.polygons.push([[s,0],[0,u],[0,1],[1,1],[1,l],[a,0]])},hexagon_tr_rb:function(t,e,n,r,i,o){var s=o.interpolate(e,n,o.minV,o.maxV),a=o.interpolate(i,r,o.minV,o.maxV),u=o.interpolate_b(n,r,o.minV,o.maxV),l=o.interpolate_a(n,r,o.minV,o.maxV);o.polygons_full&&(t.edges.tl={path:[[a,1],[1,u]],move:{x:1,y:0,enter:"lt"}},t.edges.rb={path:[[1,l],[s,0]],move:{x:0,y:-1,enter:"tl"}}),o.polygons&&t.polygons.push([[0,0],[0,1],[a,1],[1,u],[1,l],[s,0]])},hexagon_lt_rb:function(t,e,n,r,i,o){var s=o.interpolate(e,i,o.minV,o.maxV),a=o.interpolate(i,r,o.minV,o.maxV),u=o.interpolate(n,r,o.minV,o.maxV),l=o.interpolate(e,n,o.minV,o.maxV);o.polygons_full&&(t.edges.lb={path:[[0,s],[a,1]],move:{x:0,y:1,enter:"br"}},t.edges.rt={path:[[1,u],[l,0]],move:{x:0,y:-1,enter:"tl"}}),o.polygons&&t.polygons.push([[0,0],[0,s],[a,1],[1,1],[1,u],[l,0]])},hexagon_bl_tr:function(t,e,n,r,i,o){var s=o.interpolate(e,n,o.minV,o.maxV),a=o.interpolate(e,i,o.minV,o.maxV),u=o.interpolate(i,r,o.minV,o.maxV),l=o.interpolate(n,r,o.minV,o.maxV);o.polygons_full&&(t.edges.br={path:[[s,0],[0,a]],move:{x:-1,y:0,enter:"rt"}},t.edges.tl={path:[[u,1],[1,l]],move:{x:1,y:0,enter:"lb"}}),o.polygons&&t.polygons.push([[s,0],[0,a],[0,1],[u,1],[1,l],[1,0]])},heptagon_tr:function(t,e,n,r,i,o){var s=o.interpolate_a(e,n,o.minV,o.maxV),a=o.interpolate_b(e,n,o.minV,o.maxV),u=o.interpolate_a(e,i,o.minV,o.maxV),l=o.interpolate_b(e,i,o.minV,o.maxV),h=o.interpolate(i,r,o.minV,o.maxV),c=o.interpolate(n,r,o.minV,o.maxV);o.polygons_full&&(t.edges.bl={path:[[s,0],[0,u]],move:{x:-1,y:0,enter:"rb"}},t.edges.lt={path:[[0,l],[h,1]],move:{x:0,y:1,enter:"br"}},t.edges.rt={path:[[1,c],[a,0]],move:{x:0,y:-1,enter:"tr"}}),o.polygons&&t.polygons.push([[s,0],[0,u],[0,l],[h,1],[1,1],[1,c],[a,0]])},heptagon_bl:function(t,e,n,r,i,o){var s=o.interpolate(e,n,o.minV,o.maxV),a=o.interpolate(e,i,o.minV,o.maxV),u=o.interpolate_a(i,r,o.minV,o.maxV),l=o.interpolate_b(i,r,o.minV,o.maxV),h=o.interpolate_b(n,r,o.minV,o.maxV),c=o.interpolate_a(n,r,o.minV,o.maxV);o.polygons_full&&(t.edges.lb={path:[[0,a],[u,1]],move:{x:0,y:1,enter:"bl"}},t.edges.tr={path:[[l,1],[1,h]],move:{x:1,y:0,enter:"lt"}},t.edges.rb={path:[[1,c],[s,0]],move:{x:0,y:-1,enter:"tl"}}),o.polygons&&t.polygons.push([[0,0],[0,a],[u,1],[l,1],[1,h],[1,c],[s,0]])},heptagon_tl:function(t,e,n,r,i,o){var s=o.interpolate_a(e,n,o.minV,o.maxV),a=o.interpolate_b(e,n,o.minV,o.maxV),u=o.interpolate(e,i,o.minV,o.maxV),l=o.interpolate(i,r,o.minV,o.maxV),h=o.interpolate_b(n,r,o.minV,o.maxV),c=o.interpolate_a(n,r,o.minV,o.maxV);o.polygons_full&&(t.edges.bl={path:[[s,0],[0,u]],move:{x:-1,y:0,enter:"rt"}},t.edges.tl={path:[[l,1],[1,h]],move:{x:1,y:0,enter:"lt"}},t.edges.rb={path:[[1,c],[a,0]],move:{x:0,y:-1,enter:"tr"}}),o.polygons&&t.polygons.push([[s,0],[0,u],[0,1],[l,1],[1,h],[1,c],[a,0]])},heptagon_br:function(t,e,n,r,i,o){var s=o.interpolate(e,n,o.minV,o.maxV),a=o.interpolate_a(e,i,o.minV,o.maxV),u=o.interpolate_b(e,i,o.minV,o.maxV),l=o.interpolate_a(i,r,o.minV,o.maxV),h=o.interpolate_b(i,r,o.minV,o.maxV),c=o.interpolate(n,r,o.minV,o.maxV);o.polygons_full&&(t.edges.br={path:[[s,0],[0,a]],move:{x:-1,y:0,enter:"rb"}},t.edges.lt={path:[[0,u],[l,1]],move:{x:0,y:1,enter:"bl"}},t.edges.tr={path:[[h,1],[1,c]],move:{x:1,y:0,enter:"lb"}}),o.polygons&&t.polygons.push([[s,0],[0,a],[0,u],[l,1],[h,1],[1,c],[1,0]])},octagon:function(t,e,n,r,i,o){var s=o.interpolate_a(e,n,o.minV,o.maxV),a=o.interpolate_b(e,n,o.minV,o.maxV),u=o.interpolate_a(e,i,o.minV,o.maxV),l=o.interpolate_b(e,i,o.minV,o.maxV),h=o.interpolate_a(i,r,o.minV,o.maxV),c=o.interpolate_b(i,r,o.minV,o.maxV),f=o.interpolate_b(n,r,o.minV,o.maxV),g=o.interpolate_a(n,r,o.minV,o.maxV);o.polygons_full&&(t.edges.bl={path:[[s,0],[0,u]],move:{x:-1,y:0,enter:"rb"}},t.edges.lt={path:[[0,l],[h,1]],move:{x:0,y:1,enter:"bl"}},t.edges.tr={path:[[c,1],[1,f]],move:{x:1,y:0,enter:"lt"}},t.edges.rb={path:[[1,g],[a,0]],move:{x:0,y:-1,enter:"tr"}}),o.polygons&&t.polygons.push([[s,0],[0,u],[0,l],[h,1],[c,1],[1,f],[1,g],[a,0]])}};function Ea(t,e,n,r){var i,o,s,a=!1,u=null,l=null,h=null,c=null,f=!1,g=[],p=[],v=[];if(!t)throw new Error("data is required");if(null==e)throw new Error("lowerBound is required");if(null==n)throw new Error("bandWidth is required");if(s=function(t){var e,n,r,i,o;for(i=new fa,t=t||{},o=Object.keys(i),e=0;en||t[a][i-1]n){r=!1;break}if(r&&(t[o-1][0]n||t[o-1][i-1]n)&&(r=!1),r)for(s=0;sn||t[o-1][s]n){r=!1;break}return r}(t,n.minV,n.maxV)&&(n.linearRing?x.push([[0,0],[0,E],[k,E],[k,0],[0,0]]):x.push([[0,0],[0,E],[k,E],[k,0]])),e.forEach((function(t,M){t.forEach((function(t,L){for(r=null,o=0;o<8;o++)if(r=N[o],"object"===m(t.edges[r])){for(i=[],s=t.edges[r],l=r,h=M,c=L,f=!1,g=[M+s.path[0][0],L+s.path[0][1]],i.push(g);!f&&"object"===m((p=e[h][c]).edges[l]);)if(s=p.edges[l],delete p.edges[l],(y=s.path[1])[0]+=h,y[1]+=c,i.push(y),l=s.move.enter,h+=s.move.x,c+=s.move.y,void 0===e[h]||void 0===e[h][c]){if(v=0,d=0,h===k)h--,v=0;else if(h<0)h++,v=2;else if(c===E)c--,v=3;else{if(!(c<0))throw new Error("Left the grid somewhere in the interior!");c++,v=1}if(h===M&&c===L&&v===S[r]){f=!0,l=r;break}for(;;){if(_=!1,d>4)throw new Error("Direction change counter overflow! This should never happen!");if(void 0!==e[h]&&void 0!==e[h][c])for(p=e[h][c],a=0;ao?2:sf?128:64,s|=uf?32:16,s|=lf?8:4,o=0,i={cval:s=+(s|=hf?2:1),polygons:[],edges:{},x0:h,x1:l,x2:u,x3:a,x:e,y:n},s){case 85:xa.square(i,h,l,u,a,r);case 0:case 170:break;case 169:xa.triangle_bl(i,h,l,u,a,r);break;case 166:xa.triangle_br(i,h,l,u,a,r);break;case 154:xa.triangle_tr(i,h,l,u,a,r);break;case 106:xa.triangle_tl(i,h,l,u,a,r);break;case 1:xa.triangle_bl(i,h,l,u,a,r);break;case 4:xa.triangle_br(i,h,l,u,a,r);break;case 16:xa.triangle_tr(i,h,l,u,a,r);break;case 64:xa.triangle_tl(i,h,l,u,a,r);break;case 168:xa.tetragon_bl(i,h,l,u,a,r);break;case 162:xa.tetragon_br(i,h,l,u,a,r);break;case 138:xa.tetragon_tr(i,h,l,u,a,r);break;case 42:xa.tetragon_tl(i,h,l,u,a,r);break;case 2:xa.tetragon_bl(i,h,l,u,a,r);break;case 8:xa.tetragon_br(i,h,l,u,a,r);break;case 32:xa.tetragon_tr(i,h,l,u,a,r);break;case 128:xa.tetragon_tl(i,h,l,u,a,r);break;case 5:xa.tetragon_b(i,h,l,u,a,r);break;case 20:xa.tetragon_r(i,h,l,u,a,r);break;case 80:xa.tetragon_t(i,h,l,u,a,r);break;case 65:xa.tetragon_l(i,h,l,u,a,r);break;case 165:xa.tetragon_b(i,h,l,u,a,r);break;case 150:xa.tetragon_r(i,h,l,u,a,r);break;case 90:xa.tetragon_t(i,h,l,u,a,r);break;case 105:xa.tetragon_l(i,h,l,u,a,r);break;case 160:xa.tetragon_lr(i,h,l,u,a,r);break;case 130:xa.tetragon_tb(i,h,l,u,a,r);break;case 10:xa.tetragon_lr(i,h,l,u,a,r);break;case 40:xa.tetragon_tb(i,h,l,u,a,r);break;case 101:xa.pentagon_tr(i,h,l,u,a,r);break;case 149:xa.pentagon_tl(i,h,l,u,a,r);break;case 86:xa.pentagon_bl(i,h,l,u,a,r);break;case 89:xa.pentagon_br(i,h,l,u,a,r);break;case 69:xa.pentagon_tr(i,h,l,u,a,r);break;case 21:xa.pentagon_tl(i,h,l,u,a,r);break;case 84:xa.pentagon_bl(i,h,l,u,a,r);break;case 81:xa.pentagon_br(i,h,l,u,a,r);break;case 96:xa.pentagon_tr_rl(i,h,l,u,a,r);break;case 24:xa.pentagon_rb_bt(i,h,l,u,a,r);break;case 6:xa.pentagon_bl_lr(i,h,l,u,a,r);break;case 129:xa.pentagon_lt_tb(i,h,l,u,a,r);break;case 74:xa.pentagon_tr_rl(i,h,l,u,a,r);break;case 146:xa.pentagon_rb_bt(i,h,l,u,a,r);break;case 164:xa.pentagon_bl_lr(i,h,l,u,a,r);break;case 41:xa.pentagon_lt_tb(i,h,l,u,a,r);break;case 66:xa.pentagon_bl_tb(i,h,l,u,a,r);break;case 144:xa.pentagon_lt_rl(i,h,l,u,a,r);break;case 36:xa.pentagon_tr_bt(i,h,l,u,a,r);break;case 9:xa.pentagon_rb_lr(i,h,l,u,a,r);break;case 104:xa.pentagon_bl_tb(i,h,l,u,a,r);break;case 26:xa.pentagon_lt_rl(i,h,l,u,a,r);break;case 134:xa.pentagon_tr_bt(i,h,l,u,a,r);break;case 161:xa.pentagon_rb_lr(i,h,l,u,a,r);break;case 37:xa.hexagon_lt_tr(i,h,l,u,a,r);break;case 148:xa.hexagon_bl_lt(i,h,l,u,a,r);break;case 82:xa.hexagon_bl_rb(i,h,l,u,a,r);break;case 73:xa.hexagon_tr_rb(i,h,l,u,a,r);break;case 133:xa.hexagon_lt_tr(i,h,l,u,a,r);break;case 22:xa.hexagon_bl_lt(i,h,l,u,a,r);break;case 88:xa.hexagon_bl_rb(i,h,l,u,a,r);break;case 97:xa.hexagon_tr_rb(i,h,l,u,a,r);break;case 145:case 25:xa.hexagon_lt_rb(i,h,l,u,a,r);break;case 70:case 100:xa.hexagon_bl_tr(i,h,l,u,a,r);break;case 17:0===(o=ka(h,l,u,a,c,f))?(xa.triangle_bl(i,h,l,u,a,r),xa.triangle_tr(i,h,l,u,a,r)):xa.hexagon_lt_rb(i,h,l,u,a,r);break;case 68:0===(o=ka(h,l,u,a,c,f))?(xa.triangle_tl(i,h,l,u,a,r),xa.triangle_br(i,h,l,u,a,r)):xa.hexagon_bl_tr(i,h,l,u,a,r);break;case 153:2===(o=ka(h,l,u,a,c,f))?(xa.triangle_bl(i,h,l,u,a,r),xa.triangle_tr(i,h,l,u,a,r)):xa.hexagon_lt_rb(i,h,l,u,a,r);break;case 102:2===(o=ka(h,l,u,a,c,f))?(xa.triangle_tl(i,h,l,u,a,r),xa.triangle_br(i,h,l,u,a,r)):xa.hexagon_bl_tr(i,h,l,u,a,r);break;case 152:2===(o=ka(h,l,u,a,c,f))?(xa.triangle_tr(i,h,l,u,a,r),xa.tetragon_bl(i,h,l,u,a,r)):xa.heptagon_tr(i,h,l,u,a,r);break;case 137:2===(o=ka(h,l,u,a,c,f))?(xa.triangle_bl(i,h,l,u,a,r),xa.tetragon_tr(i,h,l,u,a,r)):xa.heptagon_bl(i,h,l,u,a,r);break;case 98:2===(o=ka(h,l,u,a,c,f))?(xa.triangle_tl(i,h,l,u,a,r),xa.tetragon_br(i,h,l,u,a,r)):xa.heptagon_tl(i,h,l,u,a,r);break;case 38:2===(o=ka(h,l,u,a,c,f))?(xa.triangle_br(i,h,l,u,a,r),xa.tetragon_tl(i,h,l,u,a,r)):xa.heptagon_br(i,h,l,u,a,r);break;case 18:0===(o=ka(h,l,u,a,c,f))?(xa.triangle_tr(i,h,l,u,a,r),xa.tetragon_bl(i,h,l,u,a,r)):xa.heptagon_tr(i,h,l,u,a,r);break;case 33:0===(o=ka(h,l,u,a,c,f))?(xa.triangle_bl(i,h,l,u,a,r),xa.tetragon_tr(i,h,l,u,a,r)):xa.heptagon_bl(i,h,l,u,a,r);break;case 72:0===(o=ka(h,l,u,a,c,f))?(xa.triangle_tl(i,h,l,u,a,r),xa.tetragon_br(i,h,l,u,a,r)):xa.heptagon_tl(i,h,l,u,a,r);break;case 132:0===(o=ka(h,l,u,a,c,f))?(xa.triangle_br(i,h,l,u,a,r),xa.tetragon_tl(i,h,l,u,a,r)):xa.heptagon_br(i,h,l,u,a,r);break;case 136:0===(o=ka(h,l,u,a,c,f))?(xa.tetragon_tl(i,h,l,u,a,r),xa.tetragon_br(i,h,l,u,a,r)):1===o?xa.octagon(i,h,l,u,a,r):(xa.tetragon_bl(i,h,l,u,a,r),xa.tetragon_tr(i,h,l,u,a,r));break;case 34:0===(o=ka(h,l,u,a,c,f))?(xa.tetragon_bl(i,h,l,u,a,r),xa.tetragon_tr(i,h,l,u,a,r)):1===o?xa.octagon(i,h,l,u,a,r):(xa.tetragon_tl(i,h,l,u,a,r),xa.tetragon_br(i,h,l,u,a,r))}return i}}var wa=Object.defineProperty,Ia=Object.getOwnPropertySymbols,Na=Object.prototype.hasOwnProperty,Sa=Object.prototype.propertyIsEnumerable,Ma=function(t,e,n){return e in t?wa(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n},La=function(t,e){for(var n in e||(e={}))Na.call(e,n)&&Ma(t,n,e[n]);if(Ia){var r,i=a(Ia(e));try{for(i.s();!(r=i.n()).done;){n=r.value;Sa.call(e,n)&&Ma(t,n,e[n])}}catch(t){i.e(t)}finally{i.f()}}return t};function Pa(t,e){if(!Z(e=e||{}))throw new Error("options is invalid");var n=e.zProperty||"elevation",r=e.flip,i=e.flags;nt(t,"Point","input must contain Points");for(var o=function(t,e){var n={};vt(t,(function(t){var e=Q(t)[1];n[e]||(n[e]=[]),n[e].push(t)}));var r=Object.keys(n).map((function(t){return n[t].sort((function(t,e){return Q(t)[0]-Q(e)[0]}))})),i=r.sort((function(t,n){return e?Q(t[0])[1]-Q(n[0])[1]:Q(n[0])[1]-Q(t[0])[1]}));return i}(t,r),s=[],a=0;a=0&&l<=1&&(f.onLine1=!0),h>=0&&h<=1&&(f.onLine2=!0),!(!f.onLine1||!f.onLine2)&&[f.x,f.y])}function za(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return bt(t,(function(t,n){var r=n.geometry.coordinates;return t+ut(r[0],r[1],e)}),0)}function ja(t,e,n,r){var i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{},o=i.steps||64,s=Xa(n),a=Xa(r),u=Array.isArray(t)||"Feature"!==t.type?{}:t.properties;if(s===a)return L(Ri(t,e,i).geometry.coordinates[0],u);for(var l=s,h=s=h&&c===i.length-1);c++){if(h>e&&0===o.length){if(!(s=e-h))return o.push(i[c]),L(o);a=st(i[c],i[c-1])-180,u=at(i[c],s,a,r),o.push(u.geometry.coordinates)}if(h>=n)return(s=n-h)?(a=st(i[c],i[c-1])-180,u=at(i[c],s,a,r),o.push(u.geometry.coordinates),L(o)):(o.push(i[c]),L(o));if(h>=e&&o.push(i[c]),c===i.length-1)return L(o);h+=ut(i[c],i[c+1],r)}if(h0){var a=r[e-1],u=Wa(n,a);!1!==u&&(a[1]=u,n[0]=u),s.push(a[0]),e===o.length-2&&(s.push(n[0]),s.push(n[1]))}2===o.length&&(s.push(n[0]),s.push(n[1]))}var l,h,c,f,g,p,v,d})),L(s,t.properties)}function Ka(t){var e=t[0],n=t[1],r=t[2],i=t[3];if(ut(t.slice(0,2),[r,n])>=ut(t.slice(0,2),[e,i])){var o=(n+i)/2;return[e,o-(r-e)/2,r,o+(r-e)/2]}var s=(e+r)/2;return[s-(i-n)/2,n,s+(i-n)/2,i]}function Qa(t,e){if(!Z(e=null!=e?e:{}))throw new Error("options is invalid");var n=e.precision,r=e.coordinates,i=e.mutate;if(n=null==n||isNaN(n)?6:n,r=null==r||isNaN(r)?3:r,!t)throw new Error(" is required");if("number"!=typeof n)throw new Error(" must be a number");if("number"!=typeof r)throw new Error(" must be a number");!1!==i&&void 0!==i||(t=JSON.parse(JSON.stringify(t)));var o=Math.pow(10,n);return ct(t,(function(t){!function(t,e,n){t.length>n&&t.splice(n,t.length);for(var r=0;r1&&n.push(L(l)),C(n)}function eu(t,e){if(!e.features.length)throw new Error("lines must contain features");if(1===e.features.length)return e.features[0];var n,r=1/0;return vt(e,(function(e){var i=fn(e,t).properties.dist;iu?(a.unshift(t),u=e):a.push(t)}else a.push(t)})),S(a,e);default:throw new Error("geometry type "+s+" is not supported")}}function iu(t){var e=t[0],n=e[0],r=e[1],i=t[t.length-1],o=i[0],s=i[1];return n===o&&r===s||t.push(e),t}function ou(t){return R(t)}function su(t){var e=[[[180,90],[-180,90],[-180,-90],[180,-90],[180,90]]];return t&&(e="Feature"===t.type?t.geometry.coordinates:t.coordinates),S(e)}function au(t){var e,n=0,r=a(t);try{for(r.s();!(e=r.n()).done;){n+=e.value}}catch(t){r.e(t)}finally{r.f()}return n/t.length}var uu=Object.defineProperty,lu=Object.defineProperties,hu=Object.getOwnPropertyDescriptors,cu=Object.getOwnPropertySymbols,fu=Object.prototype.hasOwnProperty,gu=Object.prototype.propertyIsEnumerable,pu=function(t,e,n){return e in t?uu(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n},vu=function(t,e){for(var n in e||(e={}))fu.call(e,n)&&pu(t,n,e[n]);if(cu){var r,i=a(cu(e));try{for(i.s();!(r=i.n()).done;){n=r.value;gu.call(e,n)&&pu(t,n,e[n])}}catch(t){i.e(t)}finally{i.f()}}return t},du=function(t,e){return lu(t,hu(e))};function yu(t,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(!t)throw new Error("targetPoint is required");if(!e)throw new Error("points is required");var r=1/0,i=0;vt(e,(function(e,o){var s=ut(t,e,n);s2&&void 0!==arguments[2]?arguments[2]:{},o=null!=(n=i.method)?n:"geodesic",s=null!=(r=i.units)?r:"kilometers";if(!t)throw new Error("pt is required");if(Array.isArray(t)?t=I(t):"Point"===t.type?t=b(t):et(t,"Point","point"),!e)throw new Error("line is required");Array.isArray(e)?e=L(e):"LineString"===e.type?e=b(e):et(e,"LineString","line");var a=1/0,u=t.geometry.coordinates;return kt(e,(function(t){if(t){var e=t.geometry.coordinates[0],n=t.geometry.coordinates[1],r=function(t,e,n,r){if("geodesic"===r.method){return fn(L([e,n]).geometry,t,{units:"degrees"}).properties.dist}var i=[n[0]-e[0],n[1]-e[1]],o=[t[0]-e[0],t[1]-e[1]],s=_u(o,i);if(s<=0)return Ys(t,e,{units:"degrees"});var a=_u(i,i);if(a<=s)return Ys(t,n,{units:"degrees"});var u=s/a,l=[e[0]+u*i[0],e[1]+u*i[1]];return Ys(t,l,{units:"degrees"})}(u,e,n,{method:o});r0)-(t<0)||+t}(r*(n[1]-e[1])-o*i)}function Lu(t,e){return e.geometry.coordinates[0].every((function(e){return zt(I(e),t)}))}var Pu=function(){return s((function t(e){i(this,t),this.id=t.buildId(e),this.coordinates=e,this.innerEdges=[],this.outerEdges=[],this.outerEdgesSorted=!1}),[{key:"removeInnerEdge",value:function(t){this.innerEdges=this.innerEdges.filter((function(e){return e.from.id!==t.from.id}))}},{key:"removeOuterEdge",value:function(t){this.outerEdges=this.outerEdges.filter((function(e){return e.to.id!==t.to.id}))}},{key:"addOuterEdge",value:function(t){this.outerEdges.push(t),this.outerEdgesSorted=!1}},{key:"sortOuterEdges",value:function(){var t=this;this.outerEdgesSorted||(this.outerEdges.sort((function(e,n){var r=e.to,i=n.to;if(r.coordinates[0]-t.coordinates[0]>=0&&i.coordinates[0]-t.coordinates[0]<0)return 1;if(r.coordinates[0]-t.coordinates[0]<0&&i.coordinates[0]-t.coordinates[0]>=0)return-1;if(r.coordinates[0]-t.coordinates[0]==0&&i.coordinates[0]-t.coordinates[0]==0)return r.coordinates[1]-t.coordinates[1]>=0||i.coordinates[1]-t.coordinates[1]>=0?r.coordinates[1]-i.coordinates[1]:i.coordinates[1]-r.coordinates[1];var o=Mu(t.coordinates,r.coordinates,i.coordinates);return o<0?1:o>0?-1:Math.pow(r.coordinates[0]-t.coordinates[0],2)+Math.pow(r.coordinates[1]-t.coordinates[1],2)-(Math.pow(i.coordinates[0]-t.coordinates[0],2)+Math.pow(i.coordinates[1]-t.coordinates[1],2))})),this.outerEdgesSorted=!0)}},{key:"getOuterEdges",value:function(){return this.sortOuterEdges(),this.outerEdges}},{key:"getOuterEdge",value:function(t){return this.sortOuterEdges(),this.outerEdges[t]}},{key:"addInnerEdge",value:function(t){this.innerEdges.push(t)}}],[{key:"buildId",value:function(t){return t.join(",")}}])}(),Cu=function(){function t(e,n){i(this,t),this.from=e,this.to=n,this.next=void 0,this.label=void 0,this.symetric=void 0,this.ring=void 0,this.from.addOuterEdge(this),this.to.addInnerEdge(this)}return s(t,[{key:"getSymetric",value:function(){return this.symetric||(this.symetric=new t(this.to,this.from),this.symetric.symetric=this),this.symetric}},{key:"deleteEdge",value:function(){this.from.removeOuterEdge(this),this.to.removeInnerEdge(this)}},{key:"isEqual",value:function(t){return this.from.id===t.from.id&&this.to.id===t.to.id}},{key:"toString",value:function(){return"Edge { ".concat(this.from.id," -> ").concat(this.to.id," }")}},{key:"toLineString",value:function(){return L([this.from.coordinates,this.to.coordinates])}},{key:"compareTo",value:function(t){return Mu(t.from.coordinates,t.to.coordinates,this.to.coordinates)}}])}(),Tu=function(){return s((function t(){i(this,t),this.edges=[],this.polygon=void 0,this.envelope=void 0}),[{key:"push",value:function(t){this.edges.push(t),this.polygon=this.envelope=void 0}},{key:"get",value:function(t){return this.edges[t]}},{key:"length",get:function(){return this.edges.length}},{key:"forEach",value:function(t){this.edges.forEach(t)}},{key:"map",value:function(t){return this.edges.map(t)}},{key:"some",value:function(t){return this.edges.some(t)}},{key:"isValid",value:function(){return!0}},{key:"isHole",value:function(){var t=this,e=this.edges.reduce((function(e,n,r){return n.from.coordinates[1]>t.edges[e].from.coordinates[1]&&(e=r),e}),0),n=(0===e?this.length:e)-1,r=(e+1)%this.length,i=Mu(this.edges[n].from.coordinates,this.edges[e].from.coordinates,this.edges[r].from.coordinates);return 0===i?this.edges[n].from.coordinates[0]>this.edges[r].from.coordinates[0]:i>0}},{key:"toMultiPoint",value:function(){return O(this.edges.map((function(t){return t.from.coordinates})))}},{key:"toPolygon",value:function(){if(this.polygon)return this.polygon;var t=this.edges.map((function(t){return t.from.coordinates}));return t.push(this.edges[0].from.coordinates),this.polygon=S([t])}},{key:"getEnvelope",value:function(){return this.envelope?this.envelope:this.envelope=Us(this.toPolygon())}},{key:"inside",value:function(t){return zt(t,this.toPolygon())}}],[{key:"findEdgeRingContaining",value:function(t,e){var n,r,i=t.getEnvelope();return e.forEach((function(e){var o,s,u,l,h,c,f=e.getEnvelope();if((r&&(n=r.getEnvelope()),s=i,u=(o=f).geometry.coordinates[0].map((function(t){return t[0]})),l=o.geometry.coordinates[0].map((function(t){return t[1]})),h=s.geometry.coordinates[0].map((function(t){return t[0]})),c=s.geometry.coordinates[0].map((function(t){return t[1]})),Math.max.apply(null,u)!==Math.max.apply(null,h)||Math.max.apply(null,l)!==Math.max.apply(null,c)||Math.min.apply(null,u)!==Math.min.apply(null,h)||Math.min.apply(null,l)!==Math.min.apply(null,c))&&Lu(f,i)){var g,p,v=a(t.map((function(t){return t.from.coordinates})));try{var d=function(){var t=p.value;e.some((function(e){return n=t,r=e.from.coordinates,n[0]===r[0]&&n[1]===r[1];var n,r}))||(g=t)};for(v.s();!(p=v.n()).done;)d()}catch(t){v.e(t)}finally{v.f()}g&&e.inside(I(g))&&(r&&!Lu(n,f)||(r=e))}})),r}}])}();var Ou=function(){function t(){i(this,t),this.edges=[],this.nodes={}}return s(t,[{key:"getNode",value:function(t){var e=Pu.buildId(t),n=this.nodes[e];return n||(n=this.nodes[e]=new Pu(t)),n}},{key:"addEdge",value:function(t,e){var n=new Cu(t,e),r=n.getSymetric();this.edges.push(n),this.edges.push(r)}},{key:"deleteDangles",value:function(){var t=this;Object.keys(this.nodes).map((function(e){return t.nodes[e]})).forEach((function(e){return t._removeIfDangle(e)}))}},{key:"_removeIfDangle",value:function(t){var e=this;if(t.innerEdges.length<=1){var n=t.getOuterEdges().map((function(t){return t.to}));this.removeNode(t),n.forEach((function(t){return e._removeIfDangle(t)}))}}},{key:"deleteCutEdges",value:function(){var t=this;this._computeNextCWEdges(),this._findLabeledEdgeRings(),this.edges.forEach((function(e){e.label===e.symetric.label&&(t.removeEdge(e.symetric),t.removeEdge(e))}))}},{key:"_computeNextCWEdges",value:function(t){var e=this;void 0===t?Object.keys(this.nodes).forEach((function(t){return e._computeNextCWEdges(e.nodes[t])})):t.getOuterEdges().forEach((function(e,n){t.getOuterEdge((0===n?t.getOuterEdges().length:n)-1).symetric.next=e}))}},{key:"_computeNextCCWEdges",value:function(t,e){for(var n,r,i=t.getOuterEdges(),o=i.length-1;o>=0;--o){var s=i[o],a=s.symetric,u=void 0,l=void 0;s.label===e&&(u=s),a.label===e&&(l=a),u&&l&&(l&&(r=l),u&&(r&&(r.next=u,r=void 0),n||(n=u)))}r&&(r.next=n)}},{key:"_findLabeledEdgeRings",value:function(){var t=[],e=0;return this.edges.forEach((function(n){if(!(n.label>=0)){t.push(n);var r=n;do{r.label=e,r=r.next}while(!n.isEqual(r));e++}})),t}},{key:"getEdgeRings",value:function(){var t=this;this._computeNextCWEdges(),this.edges.forEach((function(t){t.label=void 0})),this._findLabeledEdgeRings().forEach((function(e){t._findIntersectionNodes(e).forEach((function(n){t._computeNextCCWEdges(n,e.label)}))}));var e=[];return this.edges.forEach((function(n){n.ring||e.push(t._findEdgeRing(n))})),e}},{key:"_findIntersectionNodes",value:function(t){var e=[],n=t,r=function(){var r=0;n.from.getOuterEdges().forEach((function(e){e.label===t.label&&++r})),r>1&&e.push(n.from),n=n.next};do{r()}while(!t.isEqual(n));return e}},{key:"_findEdgeRing",value:function(t){var e=t,n=new Tu;do{n.push(e),e.ring=n,e=e.next}while(!t.isEqual(e));return n}},{key:"removeNode",value:function(t){var e=this;t.getOuterEdges().forEach((function(t){return e.removeEdge(t)})),t.innerEdges.forEach((function(t){return e.removeEdge(t)})),delete this.nodes[t.id]}},{key:"removeEdge",value:function(t){this.edges=this.edges.filter((function(e){return!e.isEqual(t)})),t.deleteEdge()}}],[{key:"fromGeoJson",value:function(e){!function(t){if(!t)throw new Error("No geojson passed");if("FeatureCollection"!==t.type&&"GeometryCollection"!==t.type&&"MultiLineString"!==t.type&&"LineString"!==t.type&&"Feature"!==t.type)throw new Error("Invalid input type '".concat(t.type,"'. Geojson must be FeatureCollection, GeometryCollection, LineString, MultiLineString or Feature"))}(e);var n=new t;return xt(e,(function(t){et(t,"LineString","Graph::fromGeoJson"),ft(t,(function(t,e){if(t){var r=n.getNode(t),i=n.getNode(e);n.addEdge(r,i)}return e}))})),n}}])}();function Ru(t,e){var n,r;ct(t,(function(t,i,o,s,a){if(r!==a)e.push([]);else{var u=n[0],l=n[1],h=t[0],c=t[1];e[a].push([.75*u+.25*h,.75*l+.25*c]),e[a].push([.25*u+.75*h,.25*l+.75*c])}n=t,r=a}),!1),e.forEach((function(t){t.push(t[0])}))}function Au(t,e){var n,r,i;ct(t,(function(t,o,s,a,u){if(r!==a)e.push([[]]);else if(i!==u)e[a].push([]);else{var l=n[0],h=n[1],c=t[0],f=t[1];e[a][u].push([.75*l+.25*c,.75*h+.25*f]),e[a][u].push([.25*l+.75*c,.25*h+.75*f])}n=t,r=a,i=u}),!1),e.forEach((function(t){t.forEach((function(t){t.push(t[0])}))}))}function Du(t,e,n,r,i){for(var o=0;o0?qu(e,s,r)<0||(r=s):n>0&&u<=0&&(Fu(e,s,i)||(i=s)),n=u}return[r,i]}function Fu(t,e,n){return qu(t,e,n)>0}function qu(t,e,n){return(e[0]-t[0])*(n[1]-t[1])-(n[0]-t[0])*(e[1]-t[1])}function Vu(t){return Bu(t,"mercator",arguments.length>1&&void 0!==arguments[1]?arguments[1]:{})}function Gu(t){return Bu(t,"wgs84",arguments.length>1&&void 0!==arguments[1]?arguments[1]:{})}function Bu(t,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=(n=n||{}).mutate;if(!t)throw new Error("geojson is required");return Array.isArray(t)&&U(t[0])?t="mercator"===e?Yu(t):zu(t):(!0!==r&&(t=Ai(t)),ct(t,(function(t){var n="mercator"===e?Yu(t):zu(t);t[0]=n[0],t[1]=n[1]}))),t}function Yu(t){var e=Math.PI/180,n=6378137,r=20037508.342789244,i=Math.abs(t[0])<=180?t[0]:t[0]-360*function(t){return t<0?-1:t>0?1:0}(t[0]),o=[n*i*e,n*Math.log(Math.tan(.25*Math.PI+.5*t[1]*e))];return o[0]>r&&(o[0]=r),o[0]<-r&&(o[0]=-r),o[1]>r&&(o[1]=r),o[1]<-r&&(o[1]=-r),o}function zu(t){var e=180/Math.PI,n=6378137;return[t[0]*e/n,(.5*Math.PI-2*Math.atan(Math.exp(-t[1]/n)))*e]}var ju=Object.freeze({__proto__:null,toMercator:Vu,toWgs84:Gu});var Xu={20:1.07275,15:1.13795,10:1.22385,5:1.3581,2:1.51743,1:1.62762};function Uu(t,e){return e[0]<=t[0]&&e[1]<=t[1]&&e[2]>=t[0]&&e[3]>=t[1]}function Zu(t){var e=[];return function t(n){return 0===n||1===n?1:e[n]>0?e[n]:e[n]=t(n-1)*n}(t)}function Hu(t){return Ju(t),Wu(t)}function Wu(t){return Array.isArray(t)?el(t):t&&t.bbox?el(t.bbox):[360*tl(),180*tl()]}function Ju(t){null!=t&&(Array.isArray(t)?H(t):null!=t.bbox&&H(t.bbox))}function Ku(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};Ju(e.bbox),null==t&&(t=1);for(var n=[],r=0;r1&&void 0!==arguments[1]?arguments[1]:{};Ju(e.bbox),null==t&&(t=1),void 0!==e.bbox&&null!==e.bbox||(e.bbox=[-180,-90,180,90]),U(e.num_vertices)&&void 0!==e.num_vertices||(e.num_vertices=10),U(e.max_radial_length)&&void 0!==e.max_radial_length||(e.max_radial_length=10);var n=Math.abs(e.bbox[0]-e.bbox[2]),r=Math.abs(e.bbox[1]-e.bbox[3]),i=Math.min(n/2,r/2);if(e.max_radial_length>i)throw new Error("max_radial_length is greater than the radius of the bbox");for(var o=[e.bbox[0]+e.max_radial_length,e.bbox[1]+e.max_radial_length,e.bbox[2]-e.max_radial_length,e.bbox[3]-e.max_radial_length],s=[],a=function(){var t,n=[],r=d(Array(e.num_vertices+1)).map(Math.random);r.forEach((function(t,e,n){n[e]=e>0?t+n[e-1]:t})),r.forEach((function(t){t=2*t*Math.PI/r[r.length-1];var i=Math.random();n.push([i*(e.max_radial_length||10)*Math.sin(t),i*(e.max_radial_length||10)*Math.cos(t)])})),n[n.length-1]=n[0],n=n.reverse().map((t=Wu(o),function(e){return[e[0]+t[0],e[1]+t[1]]})),s.push(S([n]))},u=0;u1&&void 0!==arguments[1]?arguments[1]:{};if(!Z(e=e||{}))throw new Error("options is invalid");var n=e.bbox;Ju(n);var r=e.num_vertices,i=e.max_length,o=e.max_rotation;null==t&&(t=1),(!U(r)||void 0===r||r<2)&&(r=10),U(i)&&void 0!==i||(i=1e-4),U(o)&&void 0!==o||(o=Math.PI/8);for(var s=[],a=0;a0;){var l=a.pop();if(l===n)return ll(l);l.closed=!0;for(var h=t.neighbors(l),c=0,f=h.length;c1?(r=n[0],i=n[1]):a>0&&(r+=o*a,i+=s*a)}return(o=t[0]-r)*o+(s=t[1]-i)*s}function dl(t,e,n,r,i){for(var o,s=r,a=e+1;as&&(o=a,s=u)}s>r&&(o-e>1&&dl(t,e,o,r,i),i.push(t[o]),n-o>1&&dl(t,o,n,r,i))}function yl(t,e){var n=t.length-1,r=[t[0]];return dl(t,0,n,e,r),r.push(t[n]),r}function ml(t,e,n){if(t.length<=2)return t;var r=void 0!==e?e*e:1;return t=n?t:function(t,e){for(var n,r,i,o,s,a=t[0],u=[a],l=1,h=t.length;le&&(u.push(n),a=n);return a!==n&&u.push(n),u}(t,r),t=yl(t,r)}function _l(t,e,n){return t.map((function(t){if(t.length<4)throw new Error("invalid polygon");for(var r=e,i=ml(t,r,n);!xl(i);)i=ml(t,r-=.01*r,n);return i[i.length-1][0]===i[0][0]&&i[i.length-1][1]===i[0][1]||i.push(i[0]),i}))}function xl(t){return!(t.length<3)&&!(3===t.length&&t[2][0]===t[0][0]&&t[2][1]===t[0][1])}function El(t,e){return{x:t[0]-e[0],y:t[1]-e[1]}}cl.prototype.init=function(){this.dirtyNodes=[];for(var t=0;t0&&(this.content[0]=e,this.bubbleUp(0)),t},remove:function(t){var e=this.content.indexOf(t),n=this.content.pop();e!==this.content.length-1&&(this.content[e]=n,this.scoreFunction(n)0;){var n=(t+1>>1)-1,r=this.content[n];if(!(this.scoreFunction(e)80*i){o=a=t[0],s=h=t[1];for(var _=i;_a&&(a=c),g>h&&(h=g);p=0!==(p=Math.max(a-o,h-s))?32767/p:0}return r(y,m,i,o,s,p,0),m}function e(t,e,n,r,i){var o,s;if(i===I(t,e,n,r)>0)for(o=e;o=e;o-=r)s=k(o,t[o],t[o+1],s);return s&&d(s,s.next)&&(b(s),s=s.next),s}function n(t,e){if(!t)return t;e||(e=t);var n,r=t;do{if(n=!1,r.steiner||!d(r,r.next)&&0!==v(r.prev,r,r.next))r=r.next;else{if(b(r),(r=e=r.prev)===r.next)break;n=!0}}while(n||r!==e);return e}function r(t,e,u,l,h,f,g){if(t){!g&&f&&function(t,e,n,r){var i=t;do{0===i.z&&(i.z=c(i.x,i.y,e,n,r)),i.prevZ=i.prev,i.nextZ=i.next,i=i.next}while(i!==t);i.prevZ.nextZ=null,i.prevZ=null,function(t){var e,n,r,i,o,s,a,u,l=1;do{for(n=t,t=null,o=null,s=0;n;){for(s++,r=n,a=0,e=0;e0||u>0&&r;)0!==a&&(0===u||!r||n.z<=r.z)?(i=n,n=n.nextZ,a--):(i=r,r=r.nextZ,u--),o?o.nextZ=i:t=i,i.prevZ=o,o=i;n=r}o.nextZ=null,l*=2}while(s>1)}(i)}(t,l,h,f);for(var p,v,d=t;t.prev!==t.next;)if(p=t.prev,v=t.next,f?o(t,l,h,f):i(t))e.push(p.i/u|0),e.push(t.i/u|0),e.push(v.i/u|0),b(t),t=v.next,d=v.next;else if((t=v)===d){g?1===g?r(t=s(n(t),e,u),e,u,l,h,f,2):2===g&&a(t,e,u,l,h,f):r(n(t),e,u,l,h,f,1);break}}}function i(t){var e=t.prev,n=t,r=t.next;if(v(e,n,r)>=0)return!1;for(var i=e.x,o=n.x,s=r.x,a=e.y,u=n.y,l=r.y,h=io?i>s?i:s:o>s?o:s,p=a>u?a>l?a:l:u>l?u:l,d=r.next;d!==e;){if(d.x>=h&&d.x<=f&&d.y>=c&&d.y<=p&&g(i,a,o,u,s,l,d.x,d.y)&&v(d.prev,d,d.next)>=0)return!1;d=d.next}return!0}function o(t,e,n,r){var i=t.prev,o=t,s=t.next;if(v(i,o,s)>=0)return!1;for(var a=i.x,u=o.x,l=s.x,h=i.y,f=o.y,p=s.y,d=au?a>l?a:l:u>l?u:l,_=h>f?h>p?h:p:f>p?f:p,x=c(d,y,e,n,r),E=c(m,_,e,n,r),k=t.prevZ,b=t.nextZ;k&&k.z>=x&&b&&b.z<=E;){if(k.x>=d&&k.x<=m&&k.y>=y&&k.y<=_&&k!==i&&k!==s&&g(a,h,u,f,l,p,k.x,k.y)&&v(k.prev,k,k.next)>=0)return!1;if(k=k.prevZ,b.x>=d&&b.x<=m&&b.y>=y&&b.y<=_&&b!==i&&b!==s&&g(a,h,u,f,l,p,b.x,b.y)&&v(b.prev,b,b.next)>=0)return!1;b=b.nextZ}for(;k&&k.z>=x;){if(k.x>=d&&k.x<=m&&k.y>=y&&k.y<=_&&k!==i&&k!==s&&g(a,h,u,f,l,p,k.x,k.y)&&v(k.prev,k,k.next)>=0)return!1;k=k.prevZ}for(;b&&b.z<=E;){if(b.x>=d&&b.x<=m&&b.y>=y&&b.y<=_&&b!==i&&b!==s&&g(a,h,u,f,l,p,b.x,b.y)&&v(b.prev,b,b.next)>=0)return!1;b=b.nextZ}return!0}function s(t,e,r){var i=t;do{var o=i.prev,s=i.next.next;!d(o,s)&&y(o,i,i.next,s)&&x(o,s)&&x(s,o)&&(e.push(o.i/r|0),e.push(i.i/r|0),e.push(s.i/r|0),b(i),b(i.next),i=t=s),i=i.next}while(i!==t);return n(i)}function a(t,e,i,o,s,a){var u=t;do{for(var l=u.next.next;l!==u.prev;){if(u.i!==l.i&&p(u,l)){var h=E(u,l);return u=n(u,u.next),h=n(h,h.next),r(u,e,i,o,s,a,0),void r(h,e,i,o,s,a,0)}l=l.next}u=u.next}while(u!==t)}function u(t,e){return t.x-e.x}function l(t,e){var r=function(t,e){var n,r=e,i=t.x,o=t.y,s=-1/0;do{if(o<=r.y&&o>=r.next.y&&r.next.y!==r.y){var a=r.x+(o-r.y)*(r.next.x-r.x)/(r.next.y-r.y);if(a<=i&&a>s&&(s=a,n=r.x=r.x&&r.x>=c&&i!==r.x&&g(on.x||r.x===n.x&&h(n,r)))&&(n=r,p=u)),r=r.next}while(r!==l);return n}(t,e);if(!r)return e;var i=E(r,t);return n(i,i.next),n(r,r.next)}function h(t,e){return v(t.prev,t,e.prev)<0&&v(e.next,t,t.next)<0}function c(t,e,n,r,i){return(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=(t-n)*i|0)|t<<8))|t<<4))|t<<2))|t<<1))|(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=(e-r)*i|0)|e<<8))|e<<4))|e<<2))|e<<1))<<1}function f(t){var e=t,n=t;do{(e.x=(t-s)*(o-a)&&(t-s)*(r-a)>=(n-s)*(e-a)&&(n-s)*(o-a)>=(i-s)*(r-a)}function p(t,e){return t.next.i!==e.i&&t.prev.i!==e.i&&!function(t,e){var n=t;do{if(n.i!==t.i&&n.next.i!==t.i&&n.i!==e.i&&n.next.i!==e.i&&y(n,n.next,t,e))return!0;n=n.next}while(n!==t);return!1}(t,e)&&(x(t,e)&&x(e,t)&&function(t,e){var n=t,r=!1,i=(t.x+e.x)/2,o=(t.y+e.y)/2;do{n.y>o!=n.next.y>o&&n.next.y!==n.y&&i<(n.next.x-n.x)*(o-n.y)/(n.next.y-n.y)+n.x&&(r=!r),n=n.next}while(n!==t);return r}(t,e)&&(v(t.prev,t,e.prev)||v(t,e.prev,e))||d(t,e)&&v(t.prev,t,t.next)>0&&v(e.prev,e,e.next)>0)}function v(t,e,n){return(e.y-t.y)*(n.x-e.x)-(e.x-t.x)*(n.y-e.y)}function d(t,e){return t.x===e.x&&t.y===e.y}function y(t,e,n,r){var i=_(v(t,e,n)),o=_(v(t,e,r)),s=_(v(n,r,t)),a=_(v(n,r,e));return i!==o&&s!==a||(!(0!==i||!m(t,n,e))||(!(0!==o||!m(t,r,e))||(!(0!==s||!m(n,t,r))||!(0!==a||!m(n,e,r)))))}function m(t,e,n){return e.x<=Math.max(t.x,n.x)&&e.x>=Math.min(t.x,n.x)&&e.y<=Math.max(t.y,n.y)&&e.y>=Math.min(t.y,n.y)}function _(t){return t>0?1:t<0?-1:0}function x(t,e){return v(t.prev,t,t.next)<0?v(t,e,t.next)>=0&&v(t,t.prev,e)>=0:v(t,e,t.prev)<0||v(t,t.next,e)<0}function E(t,e){var n=new w(t.i,t.x,t.y),r=new w(e.i,e.x,e.y),i=t.next,o=e.prev;return t.next=e,e.prev=t,n.next=i,i.prev=n,r.next=n,n.prev=r,o.next=r,r.prev=o,r}function k(t,e,n,r){var i=new w(t,e,n);return r?(i.next=r.next,i.prev=r,r.next.prev=i,r.next=i):(i.prev=i,i.next=i),i}function b(t){t.next.prev=t.prev,t.prev.next=t.next,t.prevZ&&(t.prevZ.nextZ=t.nextZ),t.nextZ&&(t.nextZ.prevZ=t.prevZ)}function w(t,e,n){this.i=t,this.x=e,this.y=n,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}function I(t,e,n,r){for(var i=0,o=e,s=n-r;o0&&(r+=t[i-1].length,n.holes.push(r))}return n},bl.exports}(),Il=mn(wl);function Nl(t){var e=function(t){for(var e=t[0][0].length,n={vertices:[],holes:[],dimensions:e},r=0,i=0;i0&&(r+=t[i-1].length,n.holes.push(r))}return n}(t),n=Il(e.vertices,e.holes,2),r=[],i=[];n.forEach((function(t,r){var o=n[r];i.push([e.vertices[2*o],e.vertices[2*o+1]])}));for(var o=0;o=1||u<=0||l>=1||l<=0))){var v=p,d=!o[v];d&&(o[v]=!0),e?i.push(e(p,t,n,h,c,u,s,a,f,g,l,d)):i.push(p)}}function v(t,e){var n,i,o,s,a=r[t][e],u=r[t][e+1];return a[0]f[e.isect].coord?-1:1}));for(l=[];x.length>0;){var I=x.pop(),N=I.isect,M=I.parent,L=I.winding,P=l.length,T=[f[N].coord],O=N;if(f[N].ringAndEdge1Walkable)var R=f[N].ringAndEdge1,A=f[N].nxtIsectAlongRingAndEdge1;else R=f[N].ringAndEdge2,A=f[N].nxtIsectAlongRingAndEdge2;for(;!Rl(f[N].coord,f[A].coord);){T.push(f[A].coord);var D=void 0;for(r=0;r1)for(e=0;e=0==e}function Ol(t){for(var e=0,n=0;n0)){if(o/=f,f<0){if(o0){if(o>c)return;o>h&&(h=o)}if(o=r-u,f||!(o<0)){if(o/=f,f<0){if(o>c)return;o>h&&(h=o)}else if(f>0){if(o0)){if(o/=g,g<0){if(o0){if(o>c)return;o>h&&(h=o)}if(o=i-l,g||!(o<0)){if(o/=g,g<0){if(o>c)return;o>h&&(h=o)}else if(g>0){if(o0||c<1)||(h>0&&(t[0]=[u+h*f,l+h*g]),c<1&&(t[1]=[u+c*f,l+c*g]),!0)}}}}}function Hl(t,e,n,r,i){var o=t[1];if(o)return!0;var s,a,u=t[0],l=t.left,h=t.right,c=l[0],f=l[1],g=h[0],p=h[1],v=(c+g)/2,d=(f+p)/2;if(p===f){if(v=r)return;if(c>g){if(u){if(u[1]>=i)return}else u=[v,n];o=[v,i]}else{if(u){if(u[1]1)if(c>g){if(u){if(u[1]>=i)return}else u=[(n-a)/s,n];o=[(i-a)/s,i]}else{if(u){if(u[1]=r)return}else u=[e,s*e+a];o=[r,s*r+a]}else{if(u){if(u[0]=-dh)){var g=u*u+l*l,p=h*h+c*c,v=(c*g-l*p)/f,d=(u*p-h*g)/f,y=$l.pop()||new th;y.arc=t,y.site=i,y.x=v+s,y.y=(y.cy=d+a)+Math.sqrt(v*v+d*d),t.circle=y;for(var m=null,_=gh._;_;)if(y.y<_.y||y.y===_.y&&y.x<=_.x){if(!_.L){m=_.P;break}_=_.L}else{if(!_.R){m=_;break}_=_.R}gh.insert(m,y),m||(Ql=y)}}}}function nh(t){var e=t.circle;e&&(e.P||(Ql=e.N),gh.remove(e),$l.push(e),Gl(e),t.circle=null)}var rh=[];function ih(){Gl(this),this.edge=this.site=this.circle=null}function oh(t){var e=rh.pop()||new ih;return e.site=t,e}function sh(t){nh(t),ch.remove(t),rh.push(t),Gl(t)}function ah(t){var e=t.circle,n=e.x,r=e.cy,i=[n,r],o=t.P,s=t.N,a=[t];sh(t);for(var u=o;u.circle&&Math.abs(n-u.circle.x)vh)a=a.L;else{if(!((i=o-hh(a,s))>vh)){r>-vh?(e=a.P,n=a):i>-vh?(e=a,n=a.N):e=n=a;break}if(!a.R){e=a;break}a=a.R}!function(t){fh[t.index]={site:t,halfedges:[]}}(t);var u=oh(t);if(ch.insert(e,u),e||n){if(e===n)return nh(e),n=oh(e.site),ch.insert(u,n),u.edge=n.edge=jl(e.site,u.site),eh(e),void eh(n);if(n){nh(e),nh(n);var l=e.site,h=l[0],c=l[1],f=t[0]-h,g=t[1]-c,p=n.site,v=p[0]-h,d=p[1]-c,y=2*(f*d-g*v),m=f*f+g*g,_=v*v+d*d,x=[(d*m-g*_)/y+h,(f*_-v*m)/y+c];Ul(n.edge,l,p,x),u.edge=jl(l,t,null,x),n.edge=jl(t,p,null,x),eh(e),eh(n)}else u.edge=jl(e.site,u.site)}}function lh(t,e){var n=t.site,r=n[0],i=n[1],o=i-e;if(!o)return r;var s=t.P;if(!s)return-1/0;var a=(n=s.site)[0],u=n[1],l=u-e;if(!l)return a;var h=a-r,c=1/o-1/l,f=h/l;return c?(-f+Math.sqrt(f*f-2*c*(h*h/(-2*l)-u+l/2+i-o/2)))/c+r:(r+a)/2}function hh(t,e){var n=t.N;if(n)return lh(n,e);var r=t.site;return r[1]===e?r[0]:1/0}var ch,fh,gh,ph,vh=1e-6,dh=1e-12;function yh(t,e){return e[1]-t[1]||e[0]-t[0]}function mh(t,e){var n,r,i,o=t.sort(yh).pop();for(ph=[],fh=new Array(t.length),ch=new Vl,gh=new Vl;;)if(i=Ql,o&&(!i||o[1]vh||Math.abs(i[0][1]-i[1][1])>vh)||delete ph[o]}(s,a,u,l),function(t,e,n,r){var i,o,s,a,u,l,h,c,f,g,p,v,d=fh.length,y=!0;for(i=0;ivh||Math.abs(v-f)>vh)&&(u.splice(a,0,ph.push(Xl(s,g,Math.abs(p-t)vh?[t,Math.abs(c-t)vh?[Math.abs(f-r)vh?[n,Math.abs(c-n)vh?[Math.abs(f-e)=a)return null;var u=t-i.site[0],l=e-i.site[1],h=u*u+l*l;do{i=o.cells[r=s],s=null,i.halfedges.forEach((function(n){var r=o.edges[n],a=r.left;if(a!==i.site&&a||(a=r.right)){var u=t-a[0],l=e-a[1],c=u*u+l*l;c2&&void 0!==arguments[2]?arguments[2]:{},r=rt(t).coordinates,i=0,o=0;o=i&&o===r.length-1);o++){if(i>=e){var s=e-i;if(s){var a=st(r[o],r[o-1])-180;return at(r[o],s,a,n)}return I(r[o])}i+=ut(r[o],r[o+1],n)}return I(r[r.length-1])},t.angle=function(t,e,n){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};if(!Z(r))throw new Error("options is invalid");if(!t)throw new Error("startPoint is required");if(!e)throw new Error("midPoint is required");if(!n)throw new Error("endPoint is required");var i=t,o=e,s=n,a=G(!0!==r.mercator?st(o,i):lt(o,i)),u=G(!0!==r.mercator?st(o,s):lt(o,s));u1&&void 0!==arguments[1]?arguments[1]:{},n=e.resolution||1e4,r=e.sharpness||.85,i=[],o=rt(t).coordinates.map((function(t){return{x:t[0],y:t[1]}})),s=new Gt({duration:n,points:o,sharpness:r}),a=function(t){var e=s.pos(t);Math.floor(t/100)%2==0&&i.push([e.x,e.y])},u=0;u0;else if(n!==u>0)return!0}return!1},t.booleanContains=function(t,e){var n=rt(t),r=rt(e),i=n.type,o=r.type,s=n.coordinates,u=r.coordinates;switch(i){case"Point":if("Point"===o)return Ht(s,u);throw new Error("feature2 "+o+" geometry not supported");case"MultiPoint":switch(o){case"Point":return function(t,e){var n,r=!1;for(n=0;n2&&void 0!==arguments[2]?arguments[2]:{}).precision;if("number"!=typeof(n=null==n||isNaN(n)?6:n)||!(n>=0))throw new Error("precision must be a positive number");return rt(t).type===rt(e).type&&Ne(Le(t),Le(e),{precision:n})},t.booleanIntersects=Oe,t.booleanOverlap=function(t,e){var n=rt(t),r=rt(e),i=n.type,o=r.type;if("MultiPoint"===i&&"MultiPoint"!==o||("LineString"===i||"MultiLineString"===i)&&"LineString"!==o&&"MultiLineString"!==o||("Polygon"===i||"MultiPolygon"===i)&&"Polygon"!==o&&"MultiPolygon"!==o)throw new Error("features must be of the same type");if("Point"===i)throw new Error("Point geometry not supported");if(Ne(t,e,{precision:6}))return!1;var s=0;switch(i){case"MultiPoint":for(var a=0;a0},t.booleanParallel=function(t,e){if(!t)throw new Error("line1 is required");if(!e)throw new Error("line2 is required");if("LineString"!==In(t,"line1"))throw new Error("line1 must be a LineString");if("LineString"!==In(e,"line2"))throw new Error("line2 must be a LineString");for(var n=$e(Le(t)).features,r=$e(Le(e)).features,i=0;i1;case"MultiPoint":for(var i=0;i0&&ue(S([r[0]]),S([r[i]])).features.length>1)return!1}return!0;case"MultiPolygon":for(i=0;i0&&ue(S([o[0]]),S([o[s]])).features.length>1)return!1}return!0;default:return!1}},t.booleanWithin=Cn,t.buffer=function(t,e,n){var r=(n=n||{}).units||"kilometers",i=n.steps||8;if(!t)throw new Error("geojson is required");if("object"!==m(n))throw new Error("options must be an object");if("number"!=typeof i)throw new Error("steps must be an number");if(void 0===e)throw new Error("radius is required");if(i<=0)throw new Error("steps must be greater than 0");var o=[];switch(t.type){case"GeometryCollection":return mt(t,(function(t){var n=ui(t,e,r,i);n&&o.push(n)})),C(o);case"FeatureCollection":return vt(t,(function(t){var n=ui(t,e,r,i);n&&vt(n,(function(t){t&&o.push(t)}))})),C(o)}return ui(t,e,r,i)},t.center=An,t.centerMean=fi,t.centerMedian=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!Z(e=e||{}))throw new Error("options is invalid");var n=e.counter||10;if(!U(n))throw new Error("counter must be a number");var r=e.weight,i=fi(t,{weight:e.weight}),o=C([]);vt(t,(function(t){var e;o.features.push(gi(t,{properties:{weight:null==(e=t.properties)?void 0:e[r]}}))}));var s={tolerance:e.tolerance,medianCandidates:[]};return pi(i.geometry.coordinates,[0,0],o,s,n)},t.centerOfMass=function t(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};switch(it(e)){case"Point":return I(K(e),n.properties);case"Polygon":var r=[];ct(e,(function(t){r.push(t)}));var i,o,s,a,u,l,h,c,f=gi(e,{properties:n.properties}),g=f.geometry.coordinates,p=0,v=0,d=0,y=r.map((function(t){return[t[0]-g[0],t[1]-g[1]]}));for(i=0;i2&&void 0!==arguments[2]?arguments[2]:{};!0!==n.mutate&&(t=Ai(t));var r=n.minPoints||3,i=V(e,n.units),o=new to(t.features.length),s=t.features.map((function(t){return!1})),a=t.features.map((function(t){return!1})),u=t.features.map((function(t){return!1})),l=t.features.map((function(t){return-1}));o.load(t.features.map((function(t,e){var n=v(t.geometry.coordinates,2),r=n[0],i=n[1];return{minX:r,minY:i,maxX:r,maxY:i,index:e}})));var h=function(n){var r=t.features[n],s=v(r.geometry.coordinates,2),a=s[0],u=s[1],l=Math.max(u-i,-90),h=Math.min(u+i,90),c=l<0&&h>0?i:Math.abs(l)=r){var i=c;c++,s[e]=!0,function(t,e){for(var n=0;n=r&&e.push.apply(e,d(o))}a[i]||(a[i]=!0,l[i]=t)}}(i,n)}else u[e]=!0}})),t.features.forEach((function(e,n){var r=t.features[n];r.properties||(r.properties={}),l[n]>=0?(r.properties.dbscan=u[n]?"edge":"core",r.properties.cluster=l[n]):r.properties.dbscan="noise"})),t},t.clustersKmeans=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=t.features.length;e.numberOfClusters=e.numberOfClusters||Math.round(Math.sqrt(n/2)),e.numberOfClusters>n&&(e.numberOfClusters=n),!0!==e.mutate&&(t=Ai(t));var r=yt(t),i=r.slice(0,e.numberOfClusters),o=ro(r,e.numberOfClusters,i),s={};return o.centroids.forEach((function(t,e){s[e]=t})),vt(t,(function(t,e){var n=o.idxs[e];t.properties.cluster=n,t.properties.centroid=s[n]})),t},t.collect=function(t,e,n,r){var i=new io(6),o=e.features.map((function(t){var e;return{minX:t.geometry.coordinates[0],minY:t.geometry.coordinates[1],maxX:t.geometry.coordinates[0],maxY:t.geometry.coordinates[1],property:null==(e=t.properties)?void 0:e[n]}}));return i.load(o),t.features.forEach((function(t){t.properties||(t.properties={});var e=Rt(t),n=i.search({minX:e[0],minY:e[1],maxX:e[2],maxY:e[3]}),o=[];n.forEach((function(e){zt([e.minX,e.minY],t)&&o.push(e.property)})),t.properties[r]=o})),t},t.collectionOf=nt,t.combine=function(t){var e={MultiPoint:{coordinates:[],properties:[]},MultiLineString:{coordinates:[],properties:[]},MultiPolygon:{coordinates:[],properties:[]}};return vt(t,(function(t){var n,r,i,o;switch(null==(o=t.geometry)?void 0:o.type){case"Point":e.MultiPoint.coordinates.push(t.geometry.coordinates),e.MultiPoint.properties.push(t.properties);break;case"MultiPoint":(n=e.MultiPoint.coordinates).push.apply(n,d(t.geometry.coordinates)),e.MultiPoint.properties.push(t.properties);break;case"LineString":e.MultiLineString.coordinates.push(t.geometry.coordinates),e.MultiLineString.properties.push(t.properties);break;case"MultiLineString":(r=e.MultiLineString.coordinates).push.apply(r,d(t.geometry.coordinates)),e.MultiLineString.properties.push(t.properties);break;case"Polygon":e.MultiPolygon.coordinates.push(t.geometry.coordinates),e.MultiPolygon.properties.push(t.properties);break;case"MultiPolygon":(i=e.MultiPolygon.coordinates).push.apply(i,d(t.geometry.coordinates)),e.MultiPolygon.properties.push(t.properties)}})),C(Object.keys(e).filter((function(t){return e[t].coordinates.length})).sort().map((function(t){return b({type:t,coordinates:e[t].coordinates},{collectedProperties:e[t].properties})})))},t.concave=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=e.maxEdge||1/0,r=function(t){var e=[],n={};return vt(t,(function(t){if(t.geometry){var r=t.geometry.coordinates.join("-");Object.prototype.hasOwnProperty.call(n,r)||(e.push(t),n[r]=!0)}})),C(e)}(t),i=oo(r);if(i.features=i.features.filter((function(t){var r=t.geometry.coordinates[0][0],i=t.geometry.coordinates[0][1],o=t.geometry.coordinates[0][2],s=ut(r,i,e),a=ut(i,o,e),u=ut(r,o,e);return s<=n&&a<=n&&u<=n})),i.features.length<1)return null;var o=Ro(i);return 1===o.coordinates.length&&(o.coordinates=o.coordinates[0],o.type="Polygon"),b(o)},t.containsNumber=$,t.convertArea=X,t.convertLength=j,t.convex=Oi,t.coordAll=yt,t.coordEach=ct,t.coordReduce=ft,t.createBins=zi,t.degreesToRadians=z,t.destination=at,t.difference=function(t){var e=[];if(mt(t,(function(t){e.push(t.coordinates)})),e.length<2)throw new Error("Must have at least two features");var n=t.features[0].properties||{},r=As.apply(Fs,[e[0]].concat(d(e.slice(1))));return 0===r.length?null:1===r.length?S(r[0],n):R(r,n)},t.dissolve=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!Z(e=e||{}))throw new Error("options is invalid");var n=e.propertyName;nt(t,"Polygon","dissolve");var r=[];if(!n)return qs(R(Os.apply(null,t.features.map((function(t){return t.geometry.coordinates})))));var i={};vt(t,(function(t){t.properties&&(Object.prototype.hasOwnProperty.call(i,t.properties[n])||(i[t.properties[n]]=[]),i[t.properties[n]].push(t))}));for(var o=Object.keys(i),s=0;s1&&void 0!==arguments[1]?arguments[1]:{},o=i.properties,s=null==(e=i.autoComplete)||e,a=null==(n=i.orderCoords)||n;if(null!=(r=i.mutate)&&r||(t=Ai(t)),"FeatureCollection"===t.type){var u=[];return t.features.forEach((function(t){u.push(Q(ru(t,{},s,a)))})),R(u,o)}return ru(t,o,s,a)},t.mask=function(t,e,n){var r,i=null!=(r=null==n?void 0:n.mutate)&&r,o=e;e&&!1===i&&(o=Ai(e));var s,a=su(o);return("FeatureCollection"===t.type?ou(2===(s=t).features.length?Os(s.features[0].geometry.coordinates,s.features[1].geometry.coordinates):Os.apply(Fs,s.features.map((function(t){return t.geometry.coordinates})))):"Feature"===t.type?ou(Os(t.geometry.coordinates)):ou(Os(t.coordinates))).geometry.coordinates.forEach((function(t){a.geometry.coordinates.push(t[0])})),a},t.meta=Mt,t.midpoint=function(t,e){return at(t,ut(t,e)/2,st(t,e))},t.moranIndex=function(t,e){var n,r,i=e.inputField,o=e.threshold||1e5,s=e.p||2,u=null!=(n=e.binary)&&n,l=Gs(t,{alpha:e.alpha||-1,binary:u,p:s,standardization:null==(r=e.standardization)||r,threshold:o}),h=[];vt(t,(function(t){var e=t.properties||{};h.push(e[i])}));for(var c=au(h),f=function(t){var e,n=au(t),r=0,i=a(t);try{for(i.s();!(e=i.n()).done;){var o=e.value;r+=Math.pow(o-n,2)}}catch(t){i.e(t)}finally{i.f()}return r/t.length}(h),g=0,p=0,v=0,d=0,y=l.length,m=0;m2&&void 0!==arguments[2]?arguments[2]:{},r=n.units,i=n.properties||{},o=function(t){var e=[];switch(t.geometry?t.geometry.type:t.type){case"GeometryCollection":return mt(t,(function(t){"Point"===t.type&&e.push({type:"Feature",properties:{},geometry:t})})),{type:"FeatureCollection",features:e};case"FeatureCollection":return t.features=t.features.filter((function(t){return"Point"===t.geometry.type})),t;default:throw new Error("points must be a Point Collection")}}(t);if(!o.features.length)throw new Error("points must contain features");if(!e)throw new Error("line is required");if("LineString"!==it(e))throw new Error("line must be a LineString");var s=1/0,a=null;return vt(o,(function(t){var n=mu(t,e,{units:r});n2&&void 0!==arguments[2]?arguments[2]:{},a=null!=(i=s.method)?i:"geodesic",u=null!=(o=s.units)?o:"kilometers";if(!e)throw new Error("point is required");if(!r)throw new Error("polygon or multi-polygon is required");var l,h=rt(r);if("MultiPolygon"===h.type){var c=h.coordinates.map((function(n){return t(e,S(n),{method:a,units:u})}));return Math.min.apply(Math,d(c.map(Math.abs)))*(zt(e,r)?-1:1)}if(h.coordinates.length>1){var p=h.coordinates.map((function(n){return t(e,S([n]),{method:a,units:u})})),v=n(l=p)||f(l)||_(l)||g(),y=v[0],m=v.slice(1);if(y>=0)return y;var x=Math.min.apply(Math,d(m));return x<0?Math.abs(x):Math.min(x,Math.abs(y))}var E=le(h),k=1/0;return xt(E,(function(t){k=Math.min(k,mu(e,t,{method:a,units:u}))})),zt(e,h)?-k:k},t.points=N,t.pointsWithinPolygon=Su,t.polygon=S,t.polygonSmooth=function(t,e){(e=e||{}).iterations=e.iterations||1;var n=e.iterations,r=[];if(!t)throw new Error("inputPolys is required");return mt(t,(function(t,e,i){if("Polygon"===t.type){for(var o=[[]],s=0;s0&&(u=S(o).geometry),Ru(u,a),o=a.slice(0)}r.push(S(o,i))}else{if("MultiPolygon"!==t.type)throw new Error("geometry is invalid, must be Polygon or MultiPolygon");for(var l=[[[]]],h=0;h0&&(f=R(l).geometry),Au(f,c),l=c.slice(0)}r.push(R(l,i))}})),C(r)},t.polygonTangents=function(t,e){var n,r=Q(t),i=Q(e),o=[],s=[],a=Rt(e),u=0,l=null;switch(r[0]>a[0]&&r[0]a[1]&&r[1]_&&(_=k)}for(var b=[],w=Object.keys(l).length,I=f/w,N=0,S=0;S<_+1;S++)N+=Math.exp(-I)*Math.pow(I,S)/Zu(S),b.push(N);for(var M=[],L=0,P=0;P<_+1;P++){for(var C=0,T=Object.keys(l);CR&&(R=D)}var F=Xu[r]/Math.sqrt(w),q={criticalValue:F,isRandom:!0,maxAbsoluteDifference:R,observedDistribution:M};return R>F&&(q.isRandom=!1),q},t.radiansToDegrees=Y,t.radiansToLength=F,t.random=nl,t.randomLineString=$u,t.randomPoint=Ku,t.randomPolygon=Qu,t.randomPosition=Hu,t.rectangleGrid=oa,t.rewind=function(t){var e,n,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!Z(r=r||{}))throw new Error("options is invalid");var i=null!=(e=r.mutate)&&e,o=null!=(n=r.reverse)&&n;if(!t)throw new Error(" is required");if("boolean"!=typeof o)throw new Error(" must be a boolean");if("boolean"!=typeof i)throw new Error(" must be a boolean");i||"Point"===t.type||"MultiPoint"===t.type||(t=Ai(t));var s=[];switch(t.type){case"GeometryCollection":return mt(t,(function(t){rl(t,o)})),t;case"FeatureCollection":return vt(t,(function(t){vt(rl(t,o),(function(t){s.push(t)}))})),C(s)}return rl(t,o)},t.rhumbBearing=lt,t.rhumbDestination=Bs,t.rhumbDistance=Ys,t.round=D,t.sample=function(t,e){if(!t)throw new Error("fc is required");if(null==e)throw new Error("num is required");if("number"!=typeof e)throw new Error("num must be a number");var n=C(function(t,e){var n,r,i=t.slice(0),o=t.length,s=o-e;for(;o-- >s;)n=i[r=Math.floor((o+1)*Math.random())],i[r]=i[o],i[o]=n;return i.slice(s)}(t.features,e));return n},t.sector=function(t,e,n,r){var i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{};if(!Z(i=i||{}))throw new Error("options is invalid");var o=i.properties;if(!t)throw new Error("center is required");if(null==n)throw new Error("bearing1 is required");if(null==r)throw new Error("bearing2 is required");if(!e)throw new Error("radius is required");if("object"!==m(i))throw new Error("options must be an object");if(sl(n)===sl(r))return Ri(t,e,i);var s=Q(t),a=ja(t,e,n,r,i),u=[[s]];return ct(a,(function(t){u[0].push(t)})),u[0].push(s),S(u,o)},t.segmentEach=kt,t.segmentReduce=bt,t.shortestPath=function(t,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(!Z(n=n||{}))throw new Error("options is invalid");var r=n.obstacles||C([]),i=n.resolution||100;if(!t)throw new Error("start is required");if(!e)throw new Error("end is required");if(i&&(!U(i)||i<=0))throw new Error("options.resolution must be a number, greater than 0");var o=K(t),s=K(e);if(t=I(o),e=I(s),"FeatureCollection"===r.type){if(0===r.features.length)return L([o,s])}else{if("Polygon"!==r.type)throw new Error("invalid obstacles");r=C([b(rt(r))])}var a=r;a.features.push(t),a.features.push(e);var u=v(Rt(al(Vt(Rt(a)),1.15)),4),l=u[0],h=u[1],c=u[2],f=u[3],g=ut([l,h],[c,h],n)/i;a.features.pop(),a.features.pop();for(var p,d,y=g/ut([l,h],[c,h],n)*(c-l),m=g/ut([l,h],[l,f],n)*(f-h),_=c-l,x=f-h,E=Math.floor(_/y),k=Math.floor(x/m),w=(_-E*y)/2,N=[],S=[],M=1/0,P=1/0,T=f-(x-k*m)/2,O=0;T>=h;){for(var R=[],A=[],D=l+w,F=0;D<=c;){var q=I([D,T]),V=pl(q,r);R.push(V?0:1),A.push(D+"|"+T);var G=ut(q,t);!V&&G1&&void 0!==arguments[1]?arguments[1]:{};if(!Z(i=null!=i?i:{}))throw new Error("options is invalid");var o=null!=(e=i.tolerance)?e:1,s=null!=(n=i.highQuality)&&n,a=null!=(r=i.mutate)&&r;if(!t)throw new Error("geojson is required");if(o&&o<0)throw new Error("invalid tolerance");return!0!==a&&(t=Ai(t)),mt(t,(function(t){!function(t,e,n){var r=t.type;if("Point"===r||"MultiPoint"===r)return t;if(Le(t,{mutate:!0}),"GeometryCollection"!==r)switch(r){case"LineString":t.coordinates=ml(t.coordinates,e,n);break;case"MultiLineString":t.coordinates=t.coordinates.map((function(t){return ml(t,e,n)}));break;case"Polygon":t.coordinates=_l(t.coordinates,e,n);break;case"MultiPolygon":t.coordinates=t.coordinates.map((function(t){return _l(t,e,n)}))}}(t,o,s)})),t},t.square=Ka,t.squareGrid=sa,t.standardDeviationalEllipse=function(t,e){var n;if(!Z(e=e||{}))throw new Error("options is invalid");var r=e.steps||64,i=e.weight,o=e.properties||{};if(!U(r))throw new Error("steps must be a number");if(!Z(o))throw new Error("properties must be a number");var s=yt(t).length,a=fi(t,{weight:i}),u=0,l=0,h=0;vt(t,(function(t){var e,n=i&&(null==(e=t.properties)?void 0:e[i])||1,r=El(Q(t),Q(a));u+=Math.pow(r.x,2)*n,l+=Math.pow(r.y,2)*n,h+=r.x*r.y*n}));var c=u-l,f=Math.sqrt(Math.pow(c,2)+4*Math.pow(h,2)),g=2*h,p=Math.atan((c+f)/g),v=180*p/Math.PI,d=0,y=0,m=0;vt(t,(function(t){var e,n=i&&(null==(e=t.properties)?void 0:e[i])||1,r=El(Q(t),Q(a));d+=Math.pow(r.x*Math.cos(p)-r.y*Math.sin(p),2)*n,y+=Math.pow(r.x*Math.sin(p)+r.y*Math.cos(p),2)*n,m+=n}));var _=Math.sqrt(2*d/m),x=Math.sqrt(2*y/m),E=js(a,_,x,{units:"degrees",angle:v,steps:r,properties:o}),k=Su(t,C([E])),b={meanCenterCoordinates:Q(a),semiMajorAxis:_,semiMinorAxis:x,numberOfFeatures:s,angle:v,percentageWithinEllipse:100*yt(k).length/s};return E.properties=null!=(n=E.properties)?n:{},E.properties.standardDeviationalEllipse=b,E},t.tag=function(t,e,n,r){return t=Ai(t),e=Ai(e),vt(t,(function(t){t.properties||(t.properties={}),vt(e,(function(e){t.properties&&e.properties&&void 0===t.properties[r]&&zt(t,e)&&(t.properties[r]=e.properties[n])}))})),t},t.tesselate=function(t){if(!t.geometry||"Polygon"!==t.geometry.type&&"MultiPolygon"!==t.geometry.type)throw new Error("input must be a Polygon or MultiPolygon");var e={type:"FeatureCollection",features:[]};return"Polygon"===t.geometry.type?e.features=Nl(t.geometry.coordinates):t.geometry.coordinates.forEach((function(t){e.features=e.features.concat(Nl(t))})),e},t.tin=oo,t.toMercator=Vu,t.toWgs84=Gu,t.transformRotate=zs,t.transformScale=al,t.transformTranslate=function(t,e,n,r){if(!Z(r=r||{}))throw new Error("options is invalid");var i=r.units,o=r.zTranslation,s=r.mutate;if(!t)throw new Error("geojson is required");if(null==e||isNaN(e))throw new Error("distance is required");if(o&&"number"!=typeof o&&isNaN(o))throw new Error("zTranslation is not a number");if(o=void 0!==o?o:0,0===e&&0===o)return t;if(null==n||isNaN(n))throw new Error("direction is required");return e<0&&(e=-e,n+=180),!1!==s&&void 0!==s||(t=Ai(t)),ct(t,(function(t){var r=Q(Bs(t,e,n,{units:i}));t[0]=r[0],t[1]=r[1],o&&3===t.length&&(t[2]+=o)})),t},t.triangleGrid=aa,t.truncate=Qa,t.union=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=[];if(mt(t,(function(t){n.push(t.coordinates)})),n.length<2)throw new Error("Must have at least 2 geometries");var r=Os.apply(Fs,[n[0]].concat(d(n.slice(1))));return 0===r.length?null:1===r.length?S(r[0],e.properties):R(r,e.properties)},t.unkinkPolygon=function(t){var e=[];return xt(t,(function(t){"Polygon"===t.geometry.type&&vt(Ll(t),(function(n){e.push(S(n.geometry.coordinates,t.properties))}))})),C(e)},t.validateBBox=H,t.validateId=W,t.voronoi=function(t,e){if(!Z(e=e||{}))throw new Error("options is invalid");var n=e.bbox||[-180,-85,180,85];if(!t)throw new Error("points is required");if(!Array.isArray(n))throw new Error("bbox is invalid");return nt(t,"Point","points"),C(function(){var t=Fl,e=ql,n=null;function r(r){return new mh(r.map((function(n,i){var o=[Math.round(t(n,i,r)/vh)*vh,Math.round(e(n,i,r)/vh)*vh];return o.index=i,o.data=n,o})),n)}return r.polygons=function(t){return r(t).polygons()},r.links=function(t){return r(t).links()},r.triangles=function(t){return r(t).triangles()},r.x=function(e){return arguments.length?(t="function"==typeof e?e:Dl(+e),r):t},r.y=function(t){return arguments.length?(e="function"==typeof t?t:Dl(+t),r):e},r.extent=function(t){return arguments.length?(n=null==t?null:[[+t[0][0],+t[0][1]],[+t[1][0],+t[1][1]]],r):n&&[[n[0][0],n[0][1]],[n[1][0],n[1][1]]]},r.size=function(t){return arguments.length?(n=null==t?null:[[0,0],[+t[0],+t[1]]],r):n&&[n[1][0]-n[0][0],n[1][1]-n[0][1]]},r}().x((function(t){return t.geometry.coordinates[0]})).y((function(t){return t.geometry.coordinates[1]})).extent([[n[0],n[1]],[n[2],n[3]]]).polygons(t.features).map((function(e,n){return Object.assign(function(t){return(t=t.slice()).push(t[0]),S([t])}(e),{properties:Fi(t.features[n].properties)})})))}}));