@spatial/turf
Version:
a JavaScript library for performing geospatial operations with GeoJSON
1 lines • 1.68 MB
JavaScript
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t=t||self).turf={})}(this,function(t){"use strict";var e=6371008.8,n={meters:e,metres:e,millimeters:1e3*e,millimetres:1e3*e,centimeters:100*e,centimetres:100*e,kilometers:e/1e3,kilometres:e/1e3,miles:e/1609.344,nauticalmiles:e/1852,inches:39.37*e,yards:e/1.0936,feet:3.28084*e,radians:1,degrees:e/111325},i={meters:1,metres:1,millimeters:1e3,millimetres:1e3,centimeters:100,centimetres:100,kilometers:.001,kilometres:.001,miles:1/1609.344,nauticalmiles:1/1852,inches:39.37,yards:1/1.0936,feet:3.28084,radians:1/e,degrees:1/111325},r={meters:1,metres:1,millimeters:1e6,millimetres:1e6,centimeters:1e4,centimetres:1e4,kilometers:1e-6,kilometres:1e-6,acres:247105e-9,miles:3.86e-7,yards:1.195990046,feet:10.763910417,inches:1550.003100006};function o(t,e,n){if(!L(n=n||{}))throw new Error("options is invalid");const i=n.bbox,r=n.id;if(void 0===t)throw new Error("geometry is required");if(e&&e.constructor!==Object)throw new Error("properties must be an Object");i&&P(i),r&&O(r);const o={type:"Feature"};return r&&(o.id=r),i&&(o.bbox=i),o.properties=e||{},o.geometry=t,o}function s(t,e,n){if(!L(n=n||{}))throw new Error("options is invalid");const i=n.bbox;if(!t)throw new Error("type is required");if(!e)throw new Error("coordinates is required");if(!Array.isArray(e))throw new Error("coordinates must be an Array");let r;switch(i&&P(i),t){case"Point":r=a(e).geometry;break;case"LineString":r=h(e).geometry;break;case"Polygon":r=l(e).geometry;break;case"MultiPoint":r=d(e).geometry;break;case"MultiLineString":r=g(e).geometry;break;case"MultiPolygon":r=y(e).geometry;break;default:throw new Error(`${t} is invalid`)}return i&&(r.bbox=i),r}function a(t,e,n){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(!S(t[0])||!S(t[1]))throw new Error("coordinates must contain numbers");return o({type:"Point",coordinates:t},e,n)}function u(t,e,n){if(!t)throw new Error("coordinates is required");if(!Array.isArray(t))throw new Error("coordinates must be an Array");return f(t.map(t=>a(t,e)),n)}function l(t,e,n){if(!t)throw new Error("coordinates is required");for(let e=0;e<t.length;e++){const n=t[e];if(n.length<4)throw new Error("Each LinearRing of a Polygon must have 4 or more Positions.");for(let t=0;t<n[n.length-1].length;t++){if(0===e&&0===t&&!S(n[0][0])||!S(n[0][1]))throw new Error("coordinates must contain numbers");if(n[n.length-1][t]!==n[0][t])throw new Error("First and last Position are not equivalent.")}}return o({type:"Polygon",coordinates:t},e,n)}function c(t,e,n){if(!t)throw new Error("coordinates is required");if(!Array.isArray(t))throw new Error("coordinates must be an Array");return f(t.map(t=>l(t,e)),n)}function h(t,e,n){if(!t)throw new Error("coordinates is required");if(t.length<2)throw new Error("coordinates must be an array of two or more positions");if(!S(t[0][1])||!S(t[0][1]))throw new Error("coordinates must contain numbers");return o({type:"LineString",coordinates:t},e,n)}function p(t,e,n){if(!t)throw new Error("coordinates is required");if(!Array.isArray(t))throw new Error("coordinates must be an Array");return f(t.map(t=>h(t,e)),n)}function f(t,e){if(!L(e=e||{}))throw new Error("options is invalid");const n=e.bbox,i=e.id;if(!t)throw new Error("No features passed");if(!Array.isArray(t))throw new Error("features must be an Array");n&&P(n),i&&O(i);const r={type:"FeatureCollection"};return i&&(r.id=i),n&&(r.bbox=n),r.features=t,r}function g(t,e,n){if(!t)throw new Error("coordinates is required");return o({type:"MultiLineString",coordinates:t},e,n)}function d(t,e,n){if(!t)throw new Error("coordinates is required");return o({type:"MultiPoint",coordinates:t},e,n)}function y(t,e,n){if(!t)throw new Error("coordinates is required");return o({type:"MultiPolygon",coordinates:t},e,n)}function _(t,e,n){if(!t)throw new Error("geometries is required");if(!Array.isArray(t))throw new Error("geometries must be an Array");return o({type:"GeometryCollection",geometries:t},e,n)}function m(t,e){if(null==t||isNaN(t))throw new Error("num is required");if(e&&!(e>=0))throw new Error("precision must be a positive number");const n=Math.pow(10,e||0);return Math.round(t*n)/n}function v(t,e){if(null==t)throw new Error("radians is required");if(e&&"string"!=typeof e)throw new Error("units must be a string");const i=n[e||"kilometers"];if(!i)throw new Error(`${e} units is invalid`);return t*i}function x(t,e){if(null==t)throw new Error("distance is required");if(e&&"string"!=typeof e)throw new Error("units must be a string");const i=n[e||"kilometers"];if(!i)throw new Error(`${e} units is invalid`);return t/i}function E(t,e){return N(x(t,e))}function I(t){if(null==t)throw new Error("bearing is required");let e=t%360;return e<0&&(e+=360),e}function N(t){if(null==t)throw new Error("radians is required");return 180*(t%(2*Math.PI))/Math.PI}function b(t){if(null==t)throw new Error("degrees is required");return t%360*Math.PI/180}function C(t,e,n){if(null==t)throw new Error("length is required");if(!(t>=0))throw new Error("length must be a positive number");return v(x(t,e),n||"kilometers")}function w(t,e,n){if(null==t)throw new Error("area is required");if(!(t>=0))throw new Error("area must be a positive number");const i=r[e||"meters"];if(!i)throw new Error("invalid original units");const o=r[n||"kilometers"];if(!o)throw new Error("invalid final units");return t/i*o}function S(t){return!isNaN(t)&&null!==t&&!Array.isArray(t)}function L(t){return!!t&&t.constructor===Object}function P(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(t=>{if(!S(t))throw new Error("bbox must only contain numbers")})}function O(t){if(!t)throw new Error("id is required");if(-1===["string","number"].indexOf(typeof t))throw new Error("id must be a number or a string")}var M=Object.freeze({areaFactors:r,bearingToAngle:function(){throw new Error("method has been renamed to `bearingToAzimuth`")},bearingToAzimuth:I,convertArea:w,convertDistance:function(){throw new Error("method has been renamed to `convertLength`")},convertLength:C,degrees2radians:function(){throw new Error("method has been renamed to `degreesToRadians`")},degreesToRadians:b,distanceToDegrees:function(){throw new Error("method has been renamed to `lengthToDegrees`")},distanceToRadians:function(){throw new Error("method has been renamed to `lengthToRadians`")},earthRadius:e,factors:n,feature:o,featureCollection:f,geometry:s,geometryCollection:_,isNumber:S,isObject:L,lengthToDegrees:E,lengthToRadians:x,lineString:h,lineStrings:p,multiLineString:g,multiPoint:d,multiPolygon:y,point:a,points:u,polygon:l,polygons:c,radians2degrees:function(){throw new Error("method has been renamed to `radiansToDegrees`")},radiansToDegrees:N,radiansToDistance:function(){throw new Error("method has been renamed to `radiansToLength`")},radiansToLength:v,round:m,unitsFactors:i,validateBBox:P,validateId:O});function R(t,e,n){if(null===t)return;let i,r,o,s,a,u,l,c,h=0,p=0,f=t.type,g="FeatureCollection"===f,d="Feature"===f,y=g?t.features.length:1;for(let f=0;f<y;f++){a=(c=!!(l=g?t.features[f].geometry:d?t.geometry:t)&&"GeometryCollection"===l.type)?l.geometries.length:1;for(let t=0;t<a;t++){let a=0,g=0;if(null===(s=c?l.geometries[t]:l))continue;u=s.coordinates;const d=s.type;switch(h=!n||"Polygon"!==d&&"MultiPolygon"!==d?0:1,d){case null:break;case"Point":e(u,p,f,a,g),p++,a++;break;case"LineString":case"MultiPoint":for(i=0;i<u.length;i++)e(u[i],p,f,a,g),p++,"MultiPoint"===d&&a++;"LineString"===d&&a++;break;case"Polygon":case"MultiLineString":for(i=0;i<u.length;i++){for(r=0;r<u[i].length-h;r++)e(u[i][r],p,f,a,g),p++;"MultiLineString"===d&&a++,"Polygon"===d&&g++}"Polygon"===d&&a++;break;case"MultiPolygon":for(i=0;i<u.length;i++){for("MultiPolygon"===d&&(g=0),r=0;r<u[i].length;r++){for(o=0;o<u[i][r].length-h;o++)e(u[i][r][o],p,f,a,g),p++;g++}a++}break;case"GeometryCollection":for(i=0;i<s.geometries.length;i++)R(s.geometries[i],e,n);break;default:throw new Error("Unknown Geometry Type")}}}}function T(t,e,n,i){let r=n;return R(t,(t,i,o,s,a)=>{r=0===i&&void 0===n?t:e(r,t,i,o,s,a)},i),r}function D(t,e){let n;switch(t.type){case"FeatureCollection":for(n=0;n<t.features.length;n++)e(t.features[n].properties,n);break;case"Feature":e(t.properties,0)}}function A(t,e,n){let i=n;return D(t,(t,r)=>{i=0===r&&void 0===n?t:e(i,t,r)}),i}function F(t,e){if("Feature"===t.type)e(t,0);else if("FeatureCollection"===t.type)for(let n=0;n<t.features.length;n++)e(t.features[n],n)}function G(t,e,n){let i=n;return F(t,(t,r)=>{i=0===r&&void 0===n?t:e(i,t,r)}),i}function B(t){const e=[];return R(t,t=>{e.push(t)}),e}function q(t,e){let n,i,r,o,s,a,u,l,c,h,p=0,f="FeatureCollection"===t.type,g="Feature"===t.type,d=f?t.features.length:1;for(n=0;n<d;n++){for(a=f?t.features[n].geometry:g?t.geometry:t,l=f?t.features[n].properties:g?t.properties:{},c=f?t.features[n].bbox:g?t.bbox:void 0,h=f?t.features[n].id:g?t.id:void 0,s=(u=!!a&&"GeometryCollection"===a.type)?a.geometries.length:1,r=0;r<s;r++)if(null!==(o=u?a.geometries[r]:a))switch(o.type){case"Point":case"LineString":case"MultiPoint":case"Polygon":case"MultiLineString":case"MultiPolygon":e(o,p,l,c,h);break;case"GeometryCollection":for(i=0;i<o.geometries.length;i++)e(o.geometries[i],p,l,c,h);break;default:throw new Error("Unknown Geometry Type")}else e(null,p,l,c,h);p++}}function V(t,e,n){let i=n;return q(t,(t,r,o,s,a)=>{i=0===r&&void 0===n?t:e(i,t,r,o,s,a)}),i}function z(t,e){q(t,(t,n,i,r,s)=>{const a=null===t?null:t.type;switch(a){case null:case"Point":case"LineString":case"Polygon":return void e(o(t,i,{bbox:r,id:s}),n,0)}let u;switch(a){case"MultiPoint":u="Point";break;case"MultiLineString":u="LineString";break;case"MultiPolygon":u="Polygon"}t.coordinates.forEach((t,r)=>{e(o({type:u,coordinates:t},i),n,r)})})}function U(t,e,n){let i=n;return z(t,(t,r,o)=>{i=0===r&&0===o&&void 0===n?t:e(i,t,r,o)}),i}function X(t,e){z(t,(t,n,i)=>{let r=0;if(!t.geometry)return;const o=t.geometry.type;"Point"!==o&&"MultiPoint"!==o&&T(t,(o,s,a,u,l,c)=>{const p=h([o,s],t.properties);return e(p,n,i,c,r),r++,s})})}function Y(t,e,n){let i=n,r=!1;return X(t,(t,o,s,a,u)=>{i=!1===r&&void 0===n?t:e(i,t,o,s,a,u),r=!0}),i}function k(t,e){if(!t)throw new Error("geojson is required");z(t,(t,n,i)=>{if(null===t.geometry)return;const r=t.geometry.type,o=t.geometry.coordinates;switch(r){case"LineString":e(t,n,i,0,0);break;case"Polygon":for(let r=0;r<o.length;r++)e(h(o[r],t.properties),n,i,r)}})}function j(t,e,n){let i=n;return k(t,(t,r,o,s)=>{i=0===r&&void 0===n?t:e(i,t,r,o,s)}),i}var H=Object.freeze({coordAll:B,coordEach:R,coordReduce:T,featureEach:F,featureReduce:G,flattenEach:z,flattenReduce:U,geomEach:q,geomReduce:V,lineEach:k,lineReduce:j,propEach:D,propReduce:A,segmentEach:X,segmentReduce:Y});function W(t){const e=[1/0,1/0,-1/0,-1/0];return R(t,t=>{e[0]>t[0]&&(e[0]=t[0]),e[1]>t[1]&&(e[1]=t[1]),e[2]<t[0]&&(e[2]=t[0]),e[3]<t[1]&&(e[3]=t[1])}),e}function J(t){if(!t)throw new Error("obj is required");const e=K(t);if(e.length>1&&S(e[0])&&S(e[1]))return e;throw new Error("Coordinate is not a valid Point")}function K(t){if(!t)throw new Error("obj is required");let e;if(t.length?e=t:t.coordinates?e=t.coordinates:t.geometry&&t.geometry.coordinates&&(e=t.geometry.coordinates),e)return Q(e),e;throw new Error("No valid coordinates")}function Q(t){if(t.length>1&&S(t[0])&&S(t[1]))return!0;if(Array.isArray(t[0])&&t[0].length)return Q(t[0]);throw new Error("coordinates must only contain numbers")}function Z(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 $(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 tt(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`);for(let i=0;i<t.features.length;i++){const r=t.features[i];if(!r||"Feature"!==r.type||!r.geometry)throw new Error(`Invalid input to ${n}, Feature with geometry required`);if(!r.geometry||r.geometry.type!==e)throw new Error(`Invalid input to ${n}: must be a ${e}, given ${r.geometry.type}`)}}function et(t){if(!t)throw new Error("geojson is required");if(void 0!==t.geometry)return t.geometry;if(t.coordinates||t.geometries)return t;throw new Error("geojson must be a valid Feature or Geometry Object")}function nt(){throw new Error("invariant.getGeomType has been deprecated in v5.0 in favor of invariant.getType")}function it(t,e){if(!t)throw new Error(`${e||"geojson"} is required`);if(t.geometry&&t.geometry.type)return t.geometry.type;if(t.type)return t.type;throw new Error(`${e||"geojson"} is invalid`)}var rt=Object.freeze({collectionOf:tt,containsNumber:Q,featureOf:$,geojsonType:Z,getCoord:J,getCoords:K,getGeom:et,getGeomType:nt,getType:it}),ot={successCallback:null,verbose:!1},st={};function at(t,e,n){n=n||{};for(var i=Object.keys(ot),r=0;r<i.length;r++){var o=i[r],s=n[o];s=null!=s?s:ot[o],st[o]=s}st.verbose&&console.log("MarchingSquaresJS-isoContours: computing isocontour for "+e);var a=function(t){var e=[],n=0;t.rows,t.cols;return t.cells.forEach(function(i,r){i.forEach(function(i,o){if(void 0!==i&&5!==(p=i).cval&&10!==p.cval&&!lt(i)){var s=function(t,e,n){var i,r,o,s=t.length,a=[],u=[0,0,1,1,0,0,0,0,-1,0,1,1,-1,0,-1,0],l=[0,-1,0,0,1,1,1,1,0,-1,0,0,0,-1,0,0],c=["none","bottom","right","right","top","top","top","top","left","bottom","right","right","left","bottom","left","none"],h=(t[e][n],t[e][n]),p=h.cval,f=ht(h,o=["none","left","bottom","left","right","none","bottom","left","top","top","none","top","right","right","bottom","none"][p]);a.push([n+f[0],e+f[1]]),f=ht(h,o=c[p]),a.push([n+f[0],e+f[1]]),ct(h);for(var g=n+u[p],d=e+l[p],y=p;g>=0&&d>=0&&d<s&&(g!=n||d!=e)&&void 0!==(h=t[d][g]);){if(0===(p=h.cval)||15===p)return{path:a,info:"mergeable"};o=c[p],i=u[p],r=l[p],5!==p&&10!==p||(5===p?h.flipped?-1===l[y]?(o="left",i=-1,r=0):(o="right",i=1,r=0):-1===u[y]&&(o="bottom",i=0,r=-1):10===p&&(h.flipped?-1===u[y]?(o="top",i=0,r=1):(o="bottom",i=0,r=-1):1===l[y]&&(o="left",i=-1,r=0))),f=ht(h,o),a.push([g+f[0],d+f[1]]),ct(h),g+=i,d+=r,y=p}return{path:a,info:"closed"}}(t.cells,r,o),a=!1;if("mergeable"===s.info)for(var u=s.path[s.path.length-1][0],l=s.path[s.path.length-1][1],c=n-1;c>=0;c--)if(Math.abs(e[c][0][0]-u)<=1e-7&&Math.abs(e[c][0][1]-l)<=1e-7){for(var h=s.path.length-2;h>=0;--h)e[c].unshift(s.path[h]);a=!0;break}a||(e[n++]=s.path)}var p})}),e}(function(t,e){for(var n=t.length-1,i=t[0].length-1,r={rows:n,cols:i,cells:[]},o=0;o<n;++o){r.cells[o]=[];for(var s=0;s<i;++s){var a=0,u=t[o+1][s],l=t[o+1][s+1],c=t[o][s+1],h=t[o][s];if(!(isNaN(u)||isNaN(l)||isNaN(c)||isNaN(h))){a|=u>=e?8:0,a|=l>=e?4:0,a|=c>=e?2:0;var p,f,g,d,y=!1;if(5===(a|=h>=e?1:0)||10===a){var _=(u+l+c+h)/4;5===a&&_<e?(a=10,y=!0):10===a&&_<e&&(a=5,y=!0)}if(0!==a&&15!==a)p=f=g=d=.5,1===a?(g=1-ut(e,u,h),f=1-ut(e,c,h)):2===a?(f=ut(e,h,c),d=1-ut(e,l,c)):3===a?(g=1-ut(e,u,h),d=1-ut(e,l,c)):4===a?(p=ut(e,u,l),d=ut(e,c,l)):5===a?(p=ut(e,u,l),d=ut(e,c,l),f=1-ut(e,c,h),g=1-ut(e,u,h)):6===a?(f=ut(e,h,c),p=ut(e,u,l)):7===a?(g=1-ut(e,u,h),p=ut(e,u,l)):8===a?(g=ut(e,h,u),p=1-ut(e,l,u)):9===a?(f=1-ut(e,c,h),p=1-ut(e,l,u)):10===a?(p=1-ut(e,l,u),d=1-ut(e,l,c),f=ut(e,h,c),g=ut(e,h,u)):11===a?(p=1-ut(e,l,u),d=1-ut(e,l,c)):12===a?(g=ut(e,h,u),d=ut(e,c,l)):13===a?(f=1-ut(e,c,h),d=ut(e,c,l)):14===a?(g=ut(e,h,u),f=ut(e,h,c)):console.log("MarchingSquaresJS-isoContours: Illegal cval detected: "+a),r.cells[o][s]={cval:a,flipped:y,top:p,right:d,bottom:f,left:g}}}}return r}(t,e));return"function"==typeof st.successCallback&&st.successCallback(a),a}function ut(t,e,n){return(t-e)/(n-e)}function lt(t){return 0===t.cval||15===t.cval}function ct(t){lt(t)||5===t.cval||10===t.cval||(t.cval=15)}function ht(t,e){return"top"===e?[t.top,1]:"bottom"===e?[t.bottom,0]:"right"===e?[1,t.right]:"left"===e?[0,t.left]:void 0}function pt(t,e){if(!L(e=e||{}))throw new Error("options is invalid");var n=e.zProperty||"elevation",i=e.flip,r=e.flags;tt(t,"Point","input must contain Points");for(var o=function(t,e){var n={};return F(t,function(t){var e=K(t)[1];n[e]||(n[e]=[]),n[e].push(t)}),Object.keys(n).map(function(t){return n[t].sort(function(t,e){return K(t)[0]-K(e)[0]})}).sort(function(t,n){return e?K(t[0])[1]-K(n[0])[1]:K(n[0])[1]-K(t[0])[1]})}(t,i),s=[],a=0;a<o.length;a++){for(var u=o[a],l=[],c=0;c<u.length;c++){var h=u[c];h.properties[n]?l.push(h.properties[n]):l.push(0),!0===r&&(h.properties.matrixPosition=[a,c])}s.push(l)}return s}"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self&&self;function ft(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function gt(t,e){return t(e={exports:{}},e.exports),e.exports}var dt=gt(function(t,e){t.exports=function(){function t(t,e,n){var i=t[e];t[e]=t[n],t[n]=i}function e(t,e){return t<e?-1:t>e?1:0}return function(n,i,r,o,s){!function e(n,i,r,o,s){for(;o>r;){if(o-r>600){var a=o-r+1,u=i-r+1,l=Math.log(a),c=.5*Math.exp(2*l/3),h=.5*Math.sqrt(l*c*(a-c)/a)*(u-a/2<0?-1:1),p=Math.max(r,Math.floor(i-u*c/a+h)),f=Math.min(o,Math.floor(i+(a-u)*c/a+h));e(n,i,p,f,s)}var g=n[i],d=r,y=o;for(t(n,r,i),s(n[o],g)>0&&t(n,r,o);d<y;){for(t(n,d,y),d++,y--;s(n[d],g)<0;)d++;for(;s(n[y],g)>0;)y--}0===s(n[r],g)?t(n,r,y):t(n,++y,o),y<=i&&(r=y+1),i<=y&&(o=y-1)}}(n,i,r||0,o||n.length-1,s||e)}}()}),yt=mt,_t=mt;function mt(t,e){if(!(this instanceof mt))return new mt(t,e);this._maxEntries=Math.max(4,t||9),this._minEntries=Math.max(2,Math.ceil(.4*this._maxEntries)),e&&this._initFormat(e),this.clear()}function vt(t,e,n){if(!n)return e.indexOf(t);for(var i=0;i<e.length;i++)if(n(t,e[i]))return i;return-1}function xt(t,e){Et(t,0,t.children.length,e,t)}function Et(t,e,n,i,r){r||(r=Pt(null)),r.minX=1/0,r.minY=1/0,r.maxX=-1/0,r.maxY=-1/0;for(var o,s=e;s<n;s++)o=t.children[s],It(r,t.leaf?i(o):o);return r}function It(t,e){return t.minX=Math.min(t.minX,e.minX),t.minY=Math.min(t.minY,e.minY),t.maxX=Math.max(t.maxX,e.maxX),t.maxY=Math.max(t.maxY,e.maxY),t}function Nt(t,e){return t.minX-e.minX}function bt(t,e){return t.minY-e.minY}function Ct(t){return(t.maxX-t.minX)*(t.maxY-t.minY)}function wt(t){return t.maxX-t.minX+(t.maxY-t.minY)}function St(t,e){return t.minX<=e.minX&&t.minY<=e.minY&&e.maxX<=t.maxX&&e.maxY<=t.maxY}function Lt(t,e){return e.minX<=t.maxX&&e.minY<=t.maxY&&e.maxX>=t.minX&&e.maxY>=t.minY}function Pt(t){return{children:t,height:1,leaf:!0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}}function Ot(t,e,n,i,r){for(var o,s=[e,n];s.length;)(n=s.pop())-(e=s.pop())<=i||(o=e+Math.ceil((n-e)/i/2)*i,dt(t,o,e,n,r),s.push(e,o,o,n))}mt.prototype={all:function(){return this._all(this.data,[])},search:function(t){var e=this.data,n=[],i=this.toBBox;if(!Lt(t,e))return n;for(var r,o,s,a,u=[];e;){for(r=0,o=e.children.length;r<o;r++)s=e.children[r],Lt(t,a=e.leaf?i(s):s)&&(e.leaf?n.push(s):St(t,a)?this._all(s,n):u.push(s));e=u.pop()}return n},collides:function(t){var e=this.data,n=this.toBBox;if(!Lt(t,e))return!1;for(var i,r,o,s,a=[];e;){for(i=0,r=e.children.length;i<r;i++)if(o=e.children[i],Lt(t,s=e.leaf?n(o):o)){if(e.leaf||St(t,s))return!0;a.push(o)}e=a.pop()}return!1},load:function(t){if(!t||!t.length)return this;if(t.length<this._minEntries){for(var e=0,n=t.length;e<n;e++)this.insert(t[e]);return this}var i=this._build(t.slice(),0,t.length-1,0);if(this.data.children.length)if(this.data.height===i.height)this._splitRoot(this.data,i);else{if(this.data.height<i.height){var r=this.data;this.data=i,i=r}this._insert(i,this.data.height-i.height-1,!0)}else this.data=i;return this},insert:function(t){return t&&this._insert(t,this.data.height-1),this},clear:function(){return this.data=Pt([]),this},remove:function(t,e){if(!t)return this;for(var n,i,r,o,s=this.data,a=this.toBBox(t),u=[],l=[];s||u.length;){if(s||(s=u.pop(),i=u[u.length-1],n=l.pop(),o=!0),s.leaf&&-1!==(r=vt(t,s.children,e)))return s.children.splice(r,1),u.push(s),this._condense(u),this;o||s.leaf||!St(s,a)?i?(n++,s=i.children[n],o=!1):s=null:(u.push(s),l.push(n),n=0,i=s,s=s.children[0])}return this},toBBox:function(t){return t},compareMinX:Nt,compareMinY:bt,toJSON:function(){return this.data},fromJSON:function(t){return this.data=t,this},_all:function(t,e){for(var n=[];t;)t.leaf?e.push.apply(e,t.children):n.push.apply(n,t.children),t=n.pop();return e},_build:function(t,e,n,i){var r,o=n-e+1,s=this._maxEntries;if(o<=s)return xt(r=Pt(t.slice(e,n+1)),this.toBBox),r;i||(i=Math.ceil(Math.log(o)/Math.log(s)),s=Math.ceil(o/Math.pow(s,i-1))),(r=Pt([])).leaf=!1,r.height=i;var a,u,l,c,h=Math.ceil(o/s),p=h*Math.ceil(Math.sqrt(s));for(Ot(t,e,n,p,this.compareMinX),a=e;a<=n;a+=p)for(Ot(t,a,l=Math.min(a+p-1,n),h,this.compareMinY),u=a;u<=l;u+=h)c=Math.min(u+h-1,l),r.children.push(this._build(t,u,c,i-1));return xt(r,this.toBBox),r},_chooseSubtree:function(t,e,n,i){for(var r,o,s,a,u,l,c,h,p,f;i.push(e),!e.leaf&&i.length-1!==n;){for(c=h=1/0,r=0,o=e.children.length;r<o;r++)u=Ct(s=e.children[r]),p=t,f=s,(l=(Math.max(f.maxX,p.maxX)-Math.min(f.minX,p.minX))*(Math.max(f.maxY,p.maxY)-Math.min(f.minY,p.minY))-u)<h?(h=l,c=u<c?u:c,a=s):l===h&&u<c&&(c=u,a=s);e=a||e.children[0]}return e},_insert:function(t,e,n){var i=this.toBBox,r=n?t:i(t),o=[],s=this._chooseSubtree(r,this.data,e,o);for(s.children.push(t),It(s,r);e>=0&&o[e].children.length>this._maxEntries;)this._split(o,e),e--;this._adjustParentBBoxes(r,o,e)},_split:function(t,e){var n=t[e],i=n.children.length,r=this._minEntries;this._chooseSplitAxis(n,r,i);var o=this._chooseSplitIndex(n,r,i),s=Pt(n.children.splice(o,n.children.length-o));s.height=n.height,s.leaf=n.leaf,xt(n,this.toBBox),xt(s,this.toBBox),e?t[e-1].children.push(s):this._splitRoot(n,s)},_splitRoot:function(t,e){this.data=Pt([t,e]),this.data.height=t.height+1,this.data.leaf=!1,xt(this.data,this.toBBox)},_chooseSplitIndex:function(t,e,n){var i,r,o,s,a,u,l,c,h,p,f,g,d,y;for(u=l=1/0,i=e;i<=n-e;i++)r=Et(t,0,i,this.toBBox),o=Et(t,i,n,this.toBBox),h=r,p=o,f=void 0,g=void 0,d=void 0,y=void 0,f=Math.max(h.minX,p.minX),g=Math.max(h.minY,p.minY),d=Math.min(h.maxX,p.maxX),y=Math.min(h.maxY,p.maxY),s=Math.max(0,d-f)*Math.max(0,y-g),a=Ct(r)+Ct(o),s<u?(u=s,c=i,l=a<l?a:l):s===u&&a<l&&(l=a,c=i);return c},_chooseSplitAxis:function(t,e,n){var i=t.leaf?this.compareMinX:Nt,r=t.leaf?this.compareMinY:bt;this._allDistMargin(t,e,n,i)<this._allDistMargin(t,e,n,r)&&t.children.sort(i)},_allDistMargin:function(t,e,n,i){t.children.sort(i);var r,o,s=this.toBBox,a=Et(t,0,e,s),u=Et(t,n-e,n,s),l=wt(a)+wt(u);for(r=e;r<n-e;r++)o=t.children[r],It(a,t.leaf?s(o):o),l+=wt(a);for(r=n-e-1;r>=e;r--)o=t.children[r],It(u,t.leaf?s(o):o),l+=wt(u);return l},_adjustParentBBoxes:function(t,e,n){for(var i=n;i>=0;i--)It(e[i],t)},_condense: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():xt(t[n],this.toBBox)},_initFormat:function(t){var e=["return a"," - b",";"];this.compareMinX=new Function("a","b",e.join(t[0])),this.compareMinY=new Function("a","b",e.join(t[1])),this.toBBox=new Function("a","return {minX: a"+t[0]+", minY: a"+t[1]+", maxX: a"+t[2]+", maxY: a"+t[3]+"};")}},yt.default=_t;var Mt=function(t,e,n){var i=t*e,r=Rt*t,o=r-(r-t),s=t-o,a=Rt*e,u=a-(a-e),l=e-u,c=s*l-(i-o*u-s*u-o*l);if(n)return n[0]=c,n[1]=i,n;return[c,i]},Rt=+(Math.pow(2,27)+1);var Tt=function(t,e){var n=0|t.length,i=0|e.length;if(1===n&&1===i)return function(t,e){var n=t+e,i=n-t,r=t-(n-i)+(e-i);if(r)return[r,n];return[n]}(t[0],e[0]);var r,o,s=new Array(n+i),a=0,u=0,l=0,c=Math.abs,h=t[u],p=c(h),f=e[l],g=c(f);p<g?(o=h,(u+=1)<n&&(h=t[u],p=c(h))):(o=f,(l+=1)<i&&(f=e[l],g=c(f)));u<n&&p<g||l>=i?(r=h,(u+=1)<n&&(h=t[u],p=c(h))):(r=f,(l+=1)<i&&(f=e[l],g=c(f)));var d,y,_=r+o,m=_-r,v=o-m,x=v,E=_;for(;u<n&&l<i;)p<g?(r=h,(u+=1)<n&&(h=t[u],p=c(h))):(r=f,(l+=1)<i&&(f=e[l],g=c(f))),(v=(o=x)-(m=(_=r+o)-r))&&(s[a++]=v),x=E-((d=E+_)-(y=d-E))+(_-y),E=d;for(;u<n;)(v=(o=x)-(m=(_=(r=h)+o)-r))&&(s[a++]=v),x=E-((d=E+_)-(y=d-E))+(_-y),E=d,(u+=1)<n&&(h=t[u]);for(;l<i;)(v=(o=x)-(m=(_=(r=f)+o)-r))&&(s[a++]=v),x=E-((d=E+_)-(y=d-E))+(_-y),E=d,(l+=1)<i&&(f=e[l]);x&&(s[a++]=x);E&&(s[a++]=E);a||(s[a++]=0);return s.length=a,s};var Dt=function(t,e,n){var i=t+e,r=i-t,o=e-r,s=t-(i-r);if(n)return n[0]=s+o,n[1]=i,n;return[s+o,i]};var At=function(t,e){var n=t.length;if(1===n){var i=Mt(t[0],e);return i[0]?i:[i[1]]}var r=new Array(2*n),o=[.1,.1],s=[.1,.1],a=0;Mt(t[0],e,o),o[0]&&(r[a++]=o[0]);for(var u=1;u<n;++u){Mt(t[u],e,s);var l=o[1];Dt(l,s[0],o),o[0]&&(r[a++]=o[0]);var c=s[1],h=o[1],p=c+h,f=p-c,g=h-f;o[1]=p,g&&(r[a++]=g)}o[1]&&(r[a++]=o[1]);0===a&&(r[a++]=0);return r.length=a,r};var Ft=function(t,e){var n=0|t.length,i=0|e.length;if(1===n&&1===i)return function(t,e){var n=t+e,i=n-t,r=t-(n-i)+(e-i);if(r)return[r,n];return[n]}(t[0],-e[0]);var r,o,s=new Array(n+i),a=0,u=0,l=0,c=Math.abs,h=t[u],p=c(h),f=-e[l],g=c(f);p<g?(o=h,(u+=1)<n&&(h=t[u],p=c(h))):(o=f,(l+=1)<i&&(f=-e[l],g=c(f)));u<n&&p<g||l>=i?(r=h,(u+=1)<n&&(h=t[u],p=c(h))):(r=f,(l+=1)<i&&(f=-e[l],g=c(f)));var d,y,_=r+o,m=_-r,v=o-m,x=v,E=_;for(;u<n&&l<i;)p<g?(r=h,(u+=1)<n&&(h=t[u],p=c(h))):(r=f,(l+=1)<i&&(f=-e[l],g=c(f))),(v=(o=x)-(m=(_=r+o)-r))&&(s[a++]=v),x=E-((d=E+_)-(y=d-E))+(_-y),E=d;for(;u<n;)(v=(o=x)-(m=(_=(r=h)+o)-r))&&(s[a++]=v),x=E-((d=E+_)-(y=d-E))+(_-y),E=d,(u+=1)<n&&(h=t[u]);for(;l<i;)(v=(o=x)-(m=(_=(r=f)+o)-r))&&(s[a++]=v),x=E-((d=E+_)-(y=d-E))+(_-y),E=d,(l+=1)<i&&(f=-e[l]);x&&(s[a++]=x);E&&(s[a++]=E);a||(s[a++]=0);return s.length=a,s};var Gt=gt(function(t){var e=5;function n(t,e){for(var n=new Array(t.length-1),i=1;i<t.length;++i)for(var r=n[i-1]=new Array(t.length-1),o=0,s=0;o<t.length;++o)o!==e&&(r[s++]=t[i][o]);return n}function i(t){if(1===t.length)return t[0];if(2===t.length)return["sum(",t[0],",",t[1],")"].join("");var e=t.length>>1;return["sum(",i(t.slice(0,e)),",",i(t.slice(e)),")"].join("")}function r(t){if(2===t.length)return[["sum(prod(",t[0][0],",",t[1][1],"),prod(-",t[0][1],",",t[1][0],"))"].join("")];for(var e=[],o=0;o<t.length;++o)e.push(["scale(",i(r(n(t,o))),",",(s=o,1&s?"-":""),t[0][o],")"].join(""));return e;var s}function o(t){for(var e=[],o=[],s=function(t){for(var e=new Array(t),n=0;n<t;++n){e[n]=new Array(t);for(var i=0;i<t;++i)e[n][i]=["m",i,"[",t-n-1,"]"].join("")}return e}(t),a=[],u=0;u<t;++u)0==(1&u)?e.push.apply(e,r(n(s,u))):o.push.apply(o,r(n(s,u))),a.push("m"+u);var l=i(e),c=i(o),h="orientation"+t+"Exact",p=["function ",h,"(",a.join(),"){var p=",l,",n=",c,",d=sub(p,n);return d[d.length-1];};return ",h].join("");return new Function("sum","prod","scale","sub",p)(Tt,Mt,At,Ft)}var s=o(3),a=o(4),u=[function(){return 0},function(){return 0},function(t,e){return e[0]-t[0]},function(t,e,n){var i,r=(t[1]-n[1])*(e[0]-n[0]),o=(t[0]-n[0])*(e[1]-n[1]),a=r-o;if(r>0){if(o<=0)return a;i=r+o}else{if(!(r<0))return a;if(o>=0)return a;i=-(r+o)}var u=3.3306690738754716e-16*i;return a>=u||a<=-u?a:s(t,e,n)},function(t,e,n,i){var r=t[0]-i[0],o=e[0]-i[0],s=n[0]-i[0],u=t[1]-i[1],l=e[1]-i[1],c=n[1]-i[1],h=t[2]-i[2],p=e[2]-i[2],f=n[2]-i[2],g=o*c,d=s*l,y=s*u,_=r*c,m=r*l,v=o*u,x=h*(g-d)+p*(y-_)+f*(m-v),E=7.771561172376103e-16*((Math.abs(g)+Math.abs(d))*Math.abs(h)+(Math.abs(y)+Math.abs(_))*Math.abs(p)+(Math.abs(m)+Math.abs(v))*Math.abs(f));return x>E||-x>E?x:a(t,e,n,i)}];function l(t){var e=u[t.length];return e||(e=u[t.length]=o(t.length)),e.apply(void 0,t)}!function(){for(;u.length<=e;)u.push(o(u.length));for(var n=[],i=["slow"],r=0;r<=e;++r)n.push("a"+r),i.push("o"+r);var s=["function getOrientation(",n.join(),"){switch(arguments.length){case 0:case 1:return 0;"];for(r=2;r<=e;++r)s.push("case ",r,":return o",r,"(",n.slice(0,r).join(),");");s.push("}var s=new Array(arguments.length);for(var i=0;i<arguments.length;++i){s[i]=arguments[i]};return slow(s);}return getOrientation"),i.push(s.join(""));var a=Function.apply(void 0,i);for(t.exports=a.apply(void 0,[l].concat(u)),r=0;r<=e;++r)t.exports[r]=u[r]}()}),Bt=function(t){var e=t.length;if(e<3){for(var n=new Array(e),i=0;i<e;++i)n[i]=i;return 2===e&&t[0][0]===t[1][0]&&t[0][1]===t[1][1]?[0]:n}for(var r=new Array(e),i=0;i<e;++i)r[i]=i;r.sort(function(e,n){var i=t[e][0]-t[n][0];return i||t[e][1]-t[n][1]});for(var o=[r[0],r[1]],s=[r[0],r[1]],i=2;i<e;++i){for(var a=r[i],u=t[a],l=o.length;l>1&&qt(t[o[l-2]],t[o[l-1]],u)<=0;)l-=1,o.pop();for(o.push(a),l=s.length;l>1&&qt(t[s[l-2]],t[s[l-1]],u)>=0;)l-=1,s.pop();s.push(a)}for(var n=new Array(s.length+o.length-2),c=0,i=0,h=o.length;i<h;++i)n[c++]=o[i];for(var p=s.length-2;p>0;--p)n[c++]=s[p];return n},qt=Gt[3];var Vt=Ut,zt=Ut;function Ut(t,e){if(!(this instanceof Ut))return new Ut(t,e);if(this.data=t||[],this.length=this.data.length,this.compare=e||Xt,this.length>0)for(var n=(this.length>>1)-1;n>=0;n--)this._down(n)}function Xt(t,e){return t<e?-1:t>e?1:0}Ut.prototype={push:function(t){this.data.push(t),this.length++,this._up(this.length-1)},pop:function(){if(0!==this.length){var t=this.data[0];return this.length--,this.length>0&&(this.data[0]=this.data[this.length],this._down(0)),this.data.pop(),t}},peek:function(){return this.data[0]},_up:function(t){for(var e=this.data,n=this.compare,i=e[t];t>0;){var r=t-1>>1,o=e[r];if(n(i,o)>=0)break;e[t]=o,t=r}e[t]=i},_down:function(t){for(var e=this.data,n=this.compare,i=this.length>>1,r=e[t];t<i;){var o=1+(t<<1),s=o+1,a=e[o];if(s<this.length&&n(e[s],a)<0&&(o=s,a=e[s]),n(a,r)>=0)break;e[t]=a,t=o}e[t]=r}},Vt.default=zt;var Yt=function(t,e){for(var n=t[0],i=t[1],r=!1,o=0,s=e.length-1;o<e.length;s=o++){var a=e[o][0],u=e[o][1],l=e[s][0],c=e[s][1];u>i!=c>i&&n<(l-a)*(i-u)/(c-u)+a&&(r=!r)}return r},kt=Gt[3],jt=Wt,Ht=Wt;function Wt(t,e,n){e=Math.max(0,void 0===e?2:e),n=n||0;for(var i,r=function(t){for(var e=t[0],n=t[0],i=t[0],r=t[0],o=0;o<t.length;o++){var s=t[o];s[0]<e[0]&&(e=s),s[0]>i[0]&&(i=s),s[1]<n[1]&&(n=s),s[1]>r[1]&&(r=s)}var a=[e,n,i,r],u=a.slice();for(o=0;o<t.length;o++)Yt(t[o],a)||u.push(t[o]);var l=Bt(u),c=[];for(o=0;o<l.length;o++)c.push(u[l[o]]);return c}(t),o=yt(16,["[0]","[1]","[0]","[1]"]).load(t),s=[],a=0;a<r.length;a++){var u=r[a];o.remove(u),i=ee(u,i),s.push(i)}var l=yt(16);for(a=0;a<s.length;a++)l.insert(te(s[a]));for(var c=e*e,h=n*n;s.length;){var p=s.shift(),f=p.p,g=p.next.p,d=ne(f,g);if(!(d<h)){var y=d/c;(u=Jt(o,p.prev.p,f,g,p.next.next.p,y,l))&&Math.min(ne(u,f),ne(u,g))<=y&&(s.push(p),s.push(ee(u,p)),o.remove(u),l.remove(p),l.insert(te(p)),l.insert(te(p.next)))}}p=i;var _=[];do{_.push(p.p),p=p.next}while(p!==i);return _.push(p.p),_}function Jt(t,e,n,i,r,o,s){for(var a=new Vt(null,Kt),u=t.data;u;){for(var l=0;l<u.children.length;l++){var c=u.children[l],h=u.leaf?ie(c,n,i):Qt(n,i,c);h>o||a.push({node:c,dist:h})}for(;a.length&&!a.peek().node.children;){var p=a.pop(),f=p.node,g=ie(f,e,n),d=ie(f,i,r);if(p.dist<g&&p.dist<d&&$t(n,f,s)&&$t(i,f,s))return f}(u=a.pop())&&(u=u.node)}return null}function Kt(t,e){return t.dist-e.dist}function Qt(t,e,n){if(Zt(t,n)||Zt(e,n))return 0;var i=re(t[0],t[1],e[0],e[1],n.minX,n.minY,n.maxX,n.minY);if(0===i)return 0;var r=re(t[0],t[1],e[0],e[1],n.minX,n.minY,n.minX,n.maxY);if(0===r)return 0;var o=re(t[0],t[1],e[0],e[1],n.maxX,n.minY,n.maxX,n.maxY);if(0===o)return 0;var s=re(t[0],t[1],e[0],e[1],n.minX,n.maxY,n.maxX,n.maxY);return 0===s?0:Math.min(i,r,o,s)}function Zt(t,e){return t[0]>=e.minX&&t[0]<=e.maxX&&t[1]>=e.minY&&t[1]<=e.maxY}function $t(t,e,n){for(var i,r,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]),h=n.search({minX:a,minY:u,maxX:l,maxY:c}),p=0;p<h.length;p++)if(i=h[p].p,r=h[p].next.p,o=t,i!==(s=e)&&r!==o&&kt(i,r,o)>0!=kt(i,r,s)>0&&kt(o,s,i)>0!=kt(o,s,r)>0)return!1;return!0}function te(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 ee(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 ne(t,e){var n=t[0]-e[0],i=t[1]-e[1];return n*n+i*i}function ie(t,e,n){var i=e[0],r=e[1],o=n[0]-i,s=n[1]-r;if(0!==o||0!==s){var a=((t[0]-i)*o+(t[1]-r)*s)/(o*o+s*s);a>1?(i=n[0],r=n[1]):a>0&&(i+=o*a,r+=s*a)}return(o=t[0]-i)*o+(s=t[1]-r)*s}function re(t,e,n,i,r,o,s,a){var u,l,c,h,p=n-t,f=i-e,g=s-r,d=a-o,y=t-r,_=e-o,m=p*p+f*f,v=p*g+f*d,x=g*g+d*d,E=p*y+f*_,I=g*y+d*_,N=m*x-v*v,b=N,C=N;0===N?(l=0,b=1,h=I,C=x):(h=m*I-v*E,(l=v*I-x*E)<0?(l=0,h=I,C=x):l>b&&(l=b,h=I+v,C=x)),h<0?(h=0,-E<0?l=0:-E>m?l=b:(l=-E,b=m)):h>C&&(h=C,-E+v<0?l=0:-E+v>m?l=b:(l=-E+v,b=m));var w=(1-(c=0===h?0:h/C))*r+c*s-((1-(u=0===l?0:l/b))*t+u*n),S=(1-c)*o+c*a-((1-u)*e+u*i);return w*w+S*S}function oe(t,e){if(!L(e=e||{}))throw new Error("options is invalid");const n=e.concavity||1/0,i=[];if(R(t,t=>{i.push([t[0],t[1]])}),!i.length)return null;const r=jt(i,n);return r.length>3?l([r]):null}function se(t,e,n){if("object"!=typeof(n=n||{}))throw new Error("options is invalid");const i=n.ignoreBoundary;if(!t)throw new Error("point is required");if(!e)throw new Error("polygon is required");const r=J(t);let o=K(e);const s=e.geometry?e.geometry.type:e.type,a=e.bbox;if(a&&!1===function(t,e){return e[0]<=t[0]&&e[1]<=t[1]&&e[2]>=t[0]&&e[3]>=t[1]}(r,a))return!1;"Polygon"===s&&(o=[o]);for(var u=0,l=!1;u<o.length&&!l;u++)if(ae(r,o[u][0],i)){let t=!1,e=1;for(;e<o[u].length&&!t;)ae(r,o[u][e],!i)&&(t=!0),e++;t||(l=!0)}return l}function ae(t,e,n){let i=!1;e[0][0]===e[e.length-1][0]&&e[0][1]===e[e.length-1][1]&&(e=e.slice(0,e.length-1));for(let r=0,o=e.length-1;r<e.length;o=r++){const s=e[r][0],a=e[r][1],u=e[o][0],l=e[o][1];if(t[1]*(s-u)+a*(u-t[0])+l*(t[0]-s)==0&&(s-t[0])*(u-t[0])<=0&&(a-t[1])*(l-t[1])<=0)return!n;a>t[1]!=l>t[1]&&t[0]<(u-s)*(t[1]-a)/(l-a)+s&&(i=!i)}return i}function ue(t,e){const n=[];return q(e,e=>{F(t,t=>{se(t,e)&&n.push(t)})}),f(n)}function le(t,e){if("FeatureCollection"!==t.type)throw new Error("points must be a FeatureCollection");let n=!1;return f(function(t){if(t.length<3)return[];t.sort(he);let e=t.length-1,n=t[e].y,i=n;const r=t[e].x,o=t[0].x;let s,a,u,l,c,h;for(;e--;)t[e].y<n&&(n=t[e].y),t[e].y>i&&(i=t[e].y);let p,f=o-r,g=i-n;const d=f>g?f:g,y=.5*(o+r),_=.5*(i+n),m=[new ce({x:y-20*d,y:_-d,__sentinel:!0},{x:y,y:_+20*d,__sentinel:!0},{x:y+20*d,y:_-d,__sentinel:!0})],v=[],x=[];e=t.length;for(;e--;){for(x.length=0,p=m.length;p--;)(f=t[e].x-m[p].x)>0&&f*f>m[p].r?(v.push(m[p]),m.splice(p,1)):(g=t[e].y-m[p].y,f*f+g*g>m[p].r||(x.push(m[p].a,m[p].b,m[p].b,m[p].c,m[p].c,m[p].a),m.splice(p,1)));for(pe(x),p=x.length;p;)a=x[--p],s=x[--p],u=t[e],l=a.x-s.x,c=a.y-s.y,h=2*(l*(u.y-a.y)-c*(u.x-a.x)),Math.abs(h)>1e-12&&m.push(new ce(s,a,u))}Array.prototype.push.apply(v,m),e=v.length;for(;e--;)(v[e].a.__sentinel||v[e].b.__sentinel||v[e].c.__sentinel)&&v.splice(e,1);return v}(t.features.map(t=>{const i={x:t.geometry.coordinates[0],y:t.geometry.coordinates[1]};return e?i.z=t.properties[e]:3===t.geometry.coordinates.length&&(n=!0,i.z=t.geometry.coordinates[2]),i})).map(t=>{const e=[t.a.x,t.a.y],i=[t.b.x,t.b.y],r=[t.c.x,t.c.y];let o={};return n?(e.push(t.a.z),i.push(t.b.z),r.push(t.c.z)):o={a:t.a.z,b:t.b.z,c:t.c.z},l([[e,i,r,e]],o)}))}function ce(t,e,n){this.a=t,this.b=e,this.c=n;const i=e.x-t.x,r=e.y-t.y,o=n.x-t.x,s=n.y-t.y,a=i*(t.x+e.x)+r*(t.y+e.y),u=o*(t.x+n.x)+s*(t.y+n.y),l=2*(i*(n.y-e.y)-r*(n.x-e.x));this.x=(s*a-r*u)/l,this.y=(i*u-o*a)/l;const c=this.x-t.x,h=this.y-t.y;this.r=c*c+h*h}function he(t,e){return e.x-t.x}function pe(t){let e,n,i,r,o,s=t.length;for(;s;)for(n=t[--s],e=t[--s],i=s;i;)if(o=t[--i],e===(r=t[--i])&&n===o||e===o&&n===r){t.splice(s,2),t.splice(i,2),s-=2;break}}function fe(t,e,n){if(!L(n=n||{}))throw new Error("options is invalid");const i=n.units,r=J(t),o=J(e),s=b(o[1]-r[1]),a=b(o[0]-r[0]),u=b(r[1]),l=b(o[1]),c=Math.pow(Math.sin(s/2),2)+Math.pow(Math.sin(a/2),2)*Math.cos(u)*Math.cos(l);return v(2*Math.atan2(Math.sqrt(c),Math.sqrt(1-c)),i)}function ge(t){if(!t)throw new Error("geojson is required");switch(t.type){case"Feature":return de(t);case"FeatureCollection":return function(t){const e={type:"FeatureCollection"};return Object.keys(t).forEach(n=>{switch(n){case"type":case"features":return;default:e[n]=t[n]}}),e.features=t.features.map(t=>de(t)),e}(t);case"Point":case"LineString":case"Polygon":case"MultiPoint":case"MultiLineString":case"MultiPolygon":case"GeometryCollection":return ye(t);default:throw new Error("unknown GeoJSON type")}}function de(t){const e={type:"Feature"};return Object.keys(t).forEach(n=>{switch(n){case"type":case"properties":case"geometry":return;default:e[n]=t[n]}}),e.properties=function t(e){const n={};if(!e)return n;Object.keys(e).forEach(i=>{const r=e[i];"object"==typeof r?null===r?n[i]=null:r.length?n[i]=r.map(t=>t):n[i]=t(r):n[i]=r});return n}(t.properties),e.geometry=ye(t.geometry),e}function ye(t){const e={type:t.type};return t.bbox&&(e.bbox=t.bbox),"GeometryCollection"===t.type?(e.geometries=t.geometries.map(t=>ye(t)),e):(e.coordinates=function t(e){if("object"!=typeof e[0])return e.slice();return e.map(e=>t(e))}(t.coordinates),e)}function _e(t){return t}function me(t,e){var n=function(t){if(null==t)return _e;var e,n,i=t.scale[0],r=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,c=new Array(l);for(c[0]=(e+=t[0])*i+o,c[1]=(n+=t[1])*r+s;u<l;)c[u]=t[u],++u;return c}}(t.transform),i=t.arcs;function r(t,e){e.length&&e.pop();for(var r=i[t<0?~t:t],o=0,s=r.length;o<s;++o)e.push(n(r[o],o));t<0&&function(t,e){for(var n,i=t.length,r=i-e;r<--i;)n=t[r],t[r++]=t[i],t[i]=n}(e,s)}function o(t){return n(t)}function s(t){for(var e=[],n=0,i=t.length;n<i;++n)r(t[n],e);return e.length<2&&e.push(e[0]),e}function a(t){for(var e=s(t);e.length<4;)e.push(e[0]);return e}function u(t){return t.map(a)}return function t(e){var n,i=e.type;switch(i){case"GeometryCollection":return{type:i,geometries:e.geometries.map(t)};case"Point":n=o(e.coordinates);break;case"MultiPoint":n=e.coordinates.map(o);break;case"LineString":n=s(e.arcs);break;case"MultiLineString":n=e.arcs.map(s);break;case"Polygon":n=u(e.arcs);break;case"MultiPolygon":n=e.arcs.map(u);break;default:return null}return{type:i,coordinates:n}}(e)}function ve(t,e){var n={},i={},r={},o=[],s=-1;function a(t,e){for(var i in t){var r=t[i];delete e[r.start],delete r.start,delete r.end,r.forEach(function(t){n[t<0?~t:t]=1}),o.push(r)}}return e.forEach(function(n,i){var r,o=t.arcs[n<0?~n:n];o.length<3&&!o[1][0]&&!o[1][1]&&(r=e[++s],e[s]=n,e[i]=r)}),e.forEach(function(e){var n,o,s=function(e){var n,i=t.arcs[e<0?~e:e],r=i[0];t.transform?(n=[0,0],i.forEach(function(t){n[0]+=t[0],n[1]+=t[1]})):n=i[i.length-1];return e<0?[n,r]:[r,n]}(e),a=s[0],u=s[1];if(n=r[a])if(delete r[n.end],n.push(e),n.end=u,o=i[u]){delete i[o.start];var l=o===n?n:n.concat(o);i[l.start=n.start]=r[l.end=o.end]=l}else i[n.start]=r[n.end]=n;else if(n=i[u])if(delete i[n.start],n.unshift(e),n.start=a,o=r[a]){delete r[o.end];var c=o===n?n:o.concat(n);i[c.start=o.start]=r[c.end=n.end]=c}else i[n.start]=r[n.end]=n;else i[(n=[e]).start=a]=r[n.end=u]=n}),a(r,i),a(i,r),e.forEach(function(t){n[t<0?~t:t]||o.push([t])}),o}function xe(t){return me(t,function(t,e){var n={},i=[],r=[];function o(t){t.forEach(function(e){e.forEach(function(e){(n[e=e<0?~e:e]||(n[e]=[])).push(t)})}),i.push(t)}function s(e){return function(t){for(var e,n=-1,i=t.length,r=t[i-1],o=0;++n<i;)e=r,r=t[n],o+=e[0]*r[1]-e[1]*r[0];return Math.abs(o)}(me(t,{type:"Polygon",arcs:[e]}).coordinates[0])}return e.forEach(function t(e){switch(e.type){case"GeometryCollection":e.geometries.forEach(t);break;case"Polygon":o(e.arcs);break;case"MultiPolygon":e.arcs.forEach(o)}}),i.forEach(function(t){if(!t._){var e=[],i=[t];for(t._=1,r.push(e);t=i.pop();)e.push(t),t.forEach(function(t){t.forEach(function(t){n[t<0?~t:t].forEach(function(t){t._||(t._=1,i.push(t))})})})}}),i.forEach(function(t){delete t._}),{type:"MultiPolygon",arcs:r.map(function(e){var i,r=[];if(e.forEach(function(t){t.forEach(function(t){t.forEach(function(t){n[t<0?~t:t].length<2&&r.push(t)})})}),(i=(r=ve(t,r)).length)>1)for(var o,a,u=1,l=s(r[0]);u<i;++u)(o=s(r[u]))>l&&(a=r[0],r[0]=r[u],r[u]=a,l=o);return r})}}.apply(this,arguments))}function Ee(t,e,n,i,r,o){3===arguments.length&&(i=o=Array,r=null);for(var s=new i(t=1<<Math.max(4,Math.ceil(Math.log(t)/Math.LN2))),a=new o(t),u=t-1,l=0;l<t;++l)s[l]=r;return{set:function(i,o){for(var l=e(i)&u,c=s[l],h=0;c!=r;){if(n(c,i))return a[l]=o;if(++h>=t)throw new Error("full hashmap");c=s[l=l+1&u]}return s[l]=i,a[l]=o,o},maybeSet:function(i,o){for(var l=e(i)&u,c=s[l],h=0;c!=r;){if(n(c,i))return a[l];if(++h>=t)throw new Error("full hashmap");c=s[l=l+1&u]}return s[l]=i,a[l]=o,o},get:function(i,o){for(var l=e(i)&u,c=s[l],h=0;c!=r;){if(n(c,i))return a[l];if(++h>=t)break;c=s[l=l+1&u]}return o},keys:function(){for(var t=[],e=0,n=s.length;e<n;++e){var i=s[e];i!=r&&t.push(i)}return t}}}function Ie(t,e){return t[0]===e[0]&&t[1]===e[1]}jt.default=Ht;var Ne=new ArrayBuffer(16),be=new Float64Array(Ne),Ce=new Uint32Array(Ne);function we(t){be[0]=t[0],be[1]=t[1];var e=Ce[0]^Ce[1];return 2147483647&(e=e<<5^e>>7^Ce[2]^Ce[3])}function Se(t){var e,n,i,r,o=t.coordinates,s=t.lines,a=t.rings,u=function(){for(var t=Ee(1.4*o.length,E,I,Int32Array,-1,Int32Array),e=new Int32Array(o.length),n=0,i=o.length;n<i;++n)e[n]=t.maybeSet(n,n);return e}(),l=new Int32Array(o.length),c=new Int32Array(o.length),h=new Int32Array(o.length),p=new Int8Array(o.length),f=0;for(e=0,n=o.length;e<n;++e)l[e]=c[e]=h[e]=-1;for(e=0,n=s.length;e<n;++e){var g=s[e],d=g[0],y=g[1];for(i=u[d],r=u[++d],++f,p[i]=1;++d<=y;)x(e,i,i=r,r=u[d]);++f,p[r]=1}for(e=0,n=o.length;e<n;++e)l[e]=-1;for(e=0,n=a.length;e<n;++e){var _=a[e],m=_[0]+1,v=_[1];for(x(e,u[v-1],i=u[m-1],r=u[m]);++m<=v;)x(e,i,i=r,r=u[m])}function x(t,e,n,i){if(l[n]!==t){l[n]=t;var r=c[n];if(r>=0){var o=h[n];r===e&&o===i||r===i&&o===e||(++f,p[n]=1)}else c[n]=e,h[n]=i}}function E(t){return we(o[t])}function I(t,e){return Ie(o[t],o[e])}l=c=h=null;var N,b=function(t,e,n,i,r){3===arguments.length&&(i=Array,r=null);for(var o=new i(t=1<<Math.max(4,Math.ceil(Math.log(t)/Math.LN2))),s=t-1,a=0;a<t;++a)o[a]=r;return{add:function(i){for(var a=e(i)&s,u=o[a],l=0;u!=r;){if(n(u,i))return!0;if(++l>=t)throw new Error("full hashset");u=o[a=a+1&s]}return o[a]=i,!0},has:function(i){for(var a=e(i)&s,u=o[a],l=0;u!=r;){if(n(u,i))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<n;++e){var i=o[e];i!=r&&t.push(i)}return t}}}(1.4*f,we,Ie);for(e=0,n=o.length;e<n;++e)p[N=u[e]]&&b.add(o[N]);return b}function Le(t,e,n){for(var i,r=e+(n---e>>1);e<r;++e,--n)i=t[e],t[e]=t[n],t[n]=i}function Pe(t){var e,n=Oe(t.geometry);for(e in null!=t.id&&(n.id=t.id),null!=t.bbox&&(n.bbox=t.bbox),t.properties){n.properties=t.properties;break}return n}function Oe(t){if(null==t)return{type:null};var e="GeometryCollection"===t.type?{type:"GeometryCollection",geometries:t.geometries.map(Oe)}:"Point"===t.type||"MultiPoint"===t.type?{type:t.type,coordinates:t.coordinates}:{type:t.type,arcs:t.coordinates};return null!=t.bbox&&(e.bbox=t.bbox),e}function Me(t,e){var n=function(t){var e=1/0,n=1/0,i=-1/0,r=-1/0;function o(t){null!=t&&s.hasOwnProperty(t.type)&&s[t.type](t)}var s={GeometryCollection:function(t){t.geometries.forEach(o)},Point:function(t){a(t.coordinates)},MultiPoint:function(t){t.coordinates.forEach(a)},LineString:function(t){u(t.arcs)},MultiLineString:function(t){t.arcs.forEach(u)},Polygon:function(t){t.arcs.forEach(u)},MultiPolygon:function(t){t.arcs.forEach(l)}};function a(t){var o=t[0],s=t[1];o<e&&(e=o),o>i&&(i=o),s<n&&(n=s),s>r&&(r=s)}function u(t){t.forEach(a)}function l(t){t.forEach(u)}for(var c in t)o(t[c]);return i>=e&&r>=n?[e,n,i,r]:void 0}(t=function(t){var e,n,i={};for(e in t)i[e]=null==(n=t[e])?{type:null}:("FeatureCollection"===n.type?function(t){var e={type:"GeometryCollection",geometries:t.features.map(Pe)};return null!=t.bbox&&(e.bbox=t.bbox),e}:"Feature"===n.type?Pe:Oe)(n);return i}(t)),i=e>0&&n&&function(t,e,n){var i=e[0],r=e[1],o=e[2],s=e[3],a=o-i?(n-1)/(o-i):1,u=s-r?(n-1)/(s-r):1;function l(t){return[Math.round((t[0]-i)*a),Math.round((t[1]-r)*u)]}function c(t,e){for(var n,o,s,l,c,h=-1,p=0,f=t.length,g=new Array(f);++h<f;)n=t[h],l=Math.round((n[0]-i)*a),c=Math.round((n[1]-r)*u),l===o&&c===s||(g[p++]=[o=l,s=c]);for(g.length=p;p<e;)p=g.push([g[0][0],g[0][1]]);return g}function h(t){return c(t,2)}function p(t){return c(t,4)}function f(t){return t.map(p)}function g(t){null!=t&&d.hasOwnProperty(t.type)&&d[t.type](t)}var d={GeometryCollection:function(t){t.geometries.forEach(g)},Point:function(t){t.coordinates=l(t.coordinates)},MultiPoint:function(t){t.coordinates=t.coordinates.map(l)},LineString:function(t){t.arcs=h(t.arcs)},MultiLineString:function(t){t.arcs=t.arcs.map(h)},Polygon:function(t){t.arcs=f(t.arcs)},MultiPolygon:function(t){t.arcs=t.arcs.map(f)}};for(var y in t)g(t[y]);return{scale:[1/a,1/u],translate:[i,r]}}(t,n,e),r=function(t){var e,n,i,r,o=t.coordinates,s=t.lines,a=t.rings,u=s.length+a.length;for(delete t.lines,delete t.rings,i=0,r=s.length;i<r;++i)for(e=s[i];e=e.next;)++u;for(i=0,r=a.length;i<r;++i)for(n=a[i];n=n.next;)++u;var l=Ee(2*u*1.4,we,Ie),c=t.arcs=[];for(i=0,r=s.length;i<r;++i){e=s[i];do{h(e)}while(e=e.next)}for(i=0,r=a.length;i<r;++i)if((n=a[i]).next)do{h(n)}while(n=n.next);else p(n);function h(t){var e,n,i,r,s,a,u,h;if(i=l.get(e=o[t[0]]))for(u=0,h=i.length;u<h;++u)if(f(r=i[u],t))return t[0]=r[0],void(t[1]=r[1]);if(s=l.get(n=o[t[1]]))for(u=0,h=s.length;u<h;++u)if(g(a=s[u],t))return t[1]=a[0],void(t[0]=a[1]);i?i.push(t):l.set(e,[t]),s?s.push(t):l.set(n,[t]),c.push(t)}function p(t){var e,n,i,r,s;if(n=l.get(o[t[0]]))for(r=0,s=n.length;r<s;++r){if(d(i=n[r],t))return t[0]=i[0],void(t[1]=i[1]);if(y(i,t))return t[0]=i[1],void(t[1]=i[0])}if(n=l.get(e=o[t[0]+_(t)]))for(r=0,s=n.length;r<s;++r){if(d(i=n[r],t))return t[0]=i[0],void(t[1]=i[1]);if(y(i,t))return t[0]=i[1],void(t[1]=i[0])}n?n.push(t):l.set(e,[t]),c.push(t)}function f(t,e){var n=t[0],i=e[0],r=t[1];if(n-r!=i-e[1])return!1;for(;n<=r;++n,++i)if(!Ie(o[n],o[i]))return!1;return!0}function g(t,e){var n=t[0],i=e[0],r=t[1],s=e[1];if(n-r!=i-s)return!1;for(;n<=r;++n,--s)if(!Ie(o[n],o[s]))return!1;return!0}function d(t,e){var n=t[0],i=e[0],r=t[1]-n;if(r!==e[1]-i)return!1;for(var s=_(t),a=_(e),u=0;u<r;++u)if(!Ie(o[n+(u+s)%r],o[i+(u+a)%r]))return!1;return!0}function y(t,e){var n=t[0],i=e[0],r=t[1],s=e[1],a=r-n;if(a!==s-i)return!1;for(var u=_(t),l=a-_(e),c=0;c<a;++c)if(!Ie(o[n+(c+u)%a],o[s-(c+l)%a]))return!1;return!0}function _(t){for(var e=t[0],n=t[1],i=e,r=i,s=o[i];++i<n;){var a=o[i];(a[0]<s[0]||a[0]===s[0]&&a[1]<s[1])&&(r=i,s=a)}return r-e}return t}(function(t){var e,n,i,r=Se(t),o=t.coordinates,s=t.lines,a=t.rings;for(n=0,i=s.length;n<i;++n)for(var u=s[n],l=u[0],c=u[1];++l<c;)r.has(o[l])&&(e={0:l,1:u[1]},u[1]=l,u=u.next=e);for(n=0,i=a.length;n<i;++n)for(var h=a[n],p=h[0],f=p,g=h[1],d=r.has(o[p]);++f<g;)r.has(o[f])&&(d?(e={0:f,1:h[1]},h[1]=f,h=h.next=e):(y=o,_=p,m=g,v=g-f,Le(y,_,m),Le(y,_,_+v),Le(y,_+v,m),o[g]=o[p],d=!0,f=p));var y,_,m,v;return t}(function(t){var e=-1,n=[],i=[],r=[];function o(t){t&&s.hasOwnProperty(t.type)&&s[t.type](t)}var s={GeometryCollection:function(t){t.geometries.forEach(o)},LineString:function(t){t.arcs=a(t.arcs)},MultiLineString:function(t){t.arcs=t.arcs.map(a)},Polygon:function(t){t.arcs=t.arcs.map(u)},MultiPolygon:function(t){t.arcs=t.arcs.map(l)}};function a(t){for(var i=0,o=t.length;i<o;++i)r[++e]=t[i];var s={0:e-o+1,1:e};return n.push(s),s}function u(t){for(var n=0,o=t.length;n<o;++n)r[++e]=t[n];var s={0:e-o+1,1:e};return i.push(s),s}function l(t){return t.map(u)}for(var c in t)o(t[c]);return{type:"Topology",coordinates:r,lines:n,rings:i,objects:t}}(t))),o=r.coordinates,s=Ee(1.4*r.arcs.length,Re,Te);function a(t){t&&u.hasOwnProperty(t.type)&&u[t.type](t)}t=r.objects,r.bbox=n,r.arcs=r.arcs.map(function(t,e){return s.set(t,e),o.slice(t[0],t[1]+1)}),delete r.coordinates,o=null;var u={GeometryCollection:function(t){t.geometries.forEach(a)},LineString:function(t){t.arcs=l(t.arcs)},MultiLineString:function(t){t.arcs=t.arcs.map(l)},Polygon:function(t){t.arcs=t.arcs.map(l)},MultiPolygon:function(t){t.arcs=t.arcs.map(c)}};function l(t){var e=[];do{var n=s.get(t);e.push(t[0]<t[1]?n:~n)}while(t=t.next);return e}function c(t){return t.map(l)}for(var h in t)a(t[h]);return i&&(r.transform=i,r.arcs=function(t){for(var e=-1,n=t.length;++e<n;){for(var i,r,o=t[e],s=0,a=1,u=o.length,l=o[0],c=l[0],h=l[1];++s<u;)i=(l=o[s])[0],r=l[1],i===c&&r===h||(o[a++]=[i-c,r-h],c=i,h=r);1===a&&(o[a++]=[0,0]),o.length=a}return t}(r.arcs)),r}function Re(t){var e,n=t[0],i=t[1];return i<n&&(e=n,n=i,i=e),n+31*i}function Te(t,e){var n,i=t[0],r=t[1],o=e[0],s=e[1];return r<i&&(n=i,i=r,r=n),s<o&&(n=o,o=s,s=n),i===o&&r===s}function De(t,e){if(!L(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=ge(t));var i=[],r=j(t,function(t,e){var n=function(t,e){var n,i=t.geometry.coordinates,r=e.geometry.coordinates,o=Ae(i[0]),s=Ae(i[i.length-1]),a=Ae(r[0]),u=Ae(r[r.length-1]);if(o===u)n=r.concat(i.slice(1));else if(a===s)n=i.concat(r.slice(1));else if(o===a)n=i.slice(1).reverse().concat(r);else{if(s!==u)return null;n=i.concat(r.reverse().slice(1))}return h(n)}(t,e);return n||(i.push(t),e)});return r&&i.push(r),i.length?1===i.length?i[0]:g(i.map(function(t){return t.coordinates})):null}function Ae(t){return t[0].toString()+","+t[1].toString()}function Fe(t,e){if(!L(e=e||{}))throw ne