@maplat/tin 1.0.0-rc1 → 1.1.0-rc.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.ja.md +12 -5
- package/README.md +12 -5
- package/dist/index.d.ts +1 -1
- package/dist/maplat_tin.js +2263 -2317
- package/dist/maplat_tin.umd.js +3 -3
- package/dist/strict-overlap.d.ts +22 -1
- package/dist/tin.d.ts +3 -1
- package/package.json +13 -13
- package/src/edgebound/constrain.ts +1 -1
- package/src/index.ts +2 -2
- package/src/strict-overlap.ts +37 -14
- package/src/tin.ts +23 -18
- package/dist/weight-buffer.d.ts +0 -13
- package/src/weight-buffer.ts +0 -114
package/dist/maplat_tin.umd.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
(function(yt,It){typeof exports=="object"&&typeof module<"u"?It(exports):typeof define=="function"&&define.amd?define(["exports"],It):(yt=typeof globalThis<"u"?globalThis:yt||self,It(yt.tin={}))})(this,(function(yt){"use strict";function It(n,t,e={}){const i={type:"Feature"};return(e.id===0||e.id)&&(i.id=e.id),e.bbox&&(i.bbox=e.bbox),i.properties=t||{},i.geometry=n,i}function Nt(n,t,e={}){if(!n)throw new Error("coordinates is required");if(!Array.isArray(n))throw new Error("coordinates must be an Array");if(n.length<2)throw new Error("coordinates must be at least 2 numbers long");if(!Ge(n[0])||!Ge(n[1]))throw new Error("coordinates must contain numbers");return It({type:"Point",coordinates:n},t,e)}function Jt(n,t,e={}){for(const o of n){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(let r=0;r<o[o.length-1].length;r++)if(o[o.length-1][r]!==o[0][r])throw new Error("First and last Position are not equivalent.")}return It({type:"Polygon",coordinates:n},t,e)}function We(n,t,e={}){if(n.length<2)throw new Error("coordinates must be an array of two or more positions");return It({type:"LineString",coordinates:n},t,e)}function _t(n,t={}){const e={type:"FeatureCollection"};return t.id&&(e.id=t.id),t.bbox&&(e.bbox=t.bbox),e.features=n,e}function Ge(n){return!isNaN(n)&&n!==null&&!Array.isArray(n)}function zn(n){if(!n)throw new Error("coord is required");if(!Array.isArray(n)){if(n.type==="Feature"&&n.geometry!==null&&n.geometry.type==="Point")return[...n.geometry.coordinates];if(n.type==="Point")return[...n.coordinates]}if(Array.isArray(n)&&n.length>=2&&!Array.isArray(n[0])&&!Array.isArray(n[1]))return[...n];throw new Error("coord must be GeoJSON Point or an Array of numbers")}function Wn(n){return n.type==="Feature"?n.geometry:n}function _e(n,t,e){if(n!==null)for(var i,o,r,s,a,c,f,l=0,h=0,u,p=n.type,x=p==="FeatureCollection",y=p==="Feature",k=x?n.features.length:1,S=0;S<k;S++){f=x?n.features[S].geometry:y?n.geometry:n,u=f?f.type==="GeometryCollection":!1,a=u?f.geometries.length:1;for(var g=0;g<a;g++){var v=0,d=0;if(s=u?f.geometries[g]:f,s!==null){c=s.coordinates;var b=s.type;switch(l=e&&(b==="Polygon"||b==="MultiPolygon")?1:0,b){case null:break;case"Point":if(t(c,h,S,v,d)===!1)return!1;h++,v++;break;case"LineString":case"MultiPoint":for(i=0;i<c.length;i++){if(t(c[i],h,S,v,d)===!1)return!1;h++,b==="MultiPoint"&&v++}b==="LineString"&&v++;break;case"Polygon":case"MultiLineString":for(i=0;i<c.length;i++){for(o=0;o<c[i].length-l;o++){if(t(c[i][o],h,S,v,d)===!1)return!1;h++}b==="MultiLineString"&&v++,b==="Polygon"&&d++}b==="Polygon"&&v++;break;case"MultiPolygon":for(i=0;i<c.length;i++){for(d=0,o=0;o<c[i].length;o++){for(r=0;r<c[i][o].length-l;r++){if(t(c[i][o][r],h,S,v,d)===!1)return!1;h++}d++}v++}break;case"GeometryCollection":for(i=0;i<s.geometries.length;i++)if(_e(s.geometries[i],t,e)===!1)return!1;break;default:throw new Error("Unknown Geometry Type")}}}}}const ut=11102230246251565e-32,U=134217729,Je=(3+8*ut)*ut;function ht(n,t,e,i,o){let r,s,a,c,f=t[0],l=i[0],h=0,u=0;l>f==l>-f?(r=f,f=t[++h]):(r=l,l=i[++u]);let p=0;if(h<n&&u<e)for(l>f==l>-f?(s=f+r,a=r-(s-f),f=t[++h]):(s=l+r,a=r-(s-l),l=i[++u]),r=s,a!==0&&(o[p++]=a);h<n&&u<e;)l>f==l>-f?(s=r+f,c=s-r,a=r-(s-c)+(f-c),f=t[++h]):(s=r+l,c=s-r,a=r-(s-c)+(l-c),l=i[++u]),r=s,a!==0&&(o[p++]=a);for(;h<n;)s=r+f,c=s-r,a=r-(s-c)+(f-c),f=t[++h],r=s,a!==0&&(o[p++]=a);for(;u<e;)s=r+l,c=s-r,a=r-(s-c)+(l-c),l=i[++u],r=s,a!==0&&(o[p++]=a);return(r!==0||p===0)&&(o[p++]=r),p}function xt(n,t,e,i,o,r,s,a){return ht(ht(n,t,e,i,s),s,o,r,a)}function Y(n,t,e,i){let o,r,s,a,c,f,l,h,u,p,x;l=U*e,p=l-(l-e),x=e-p;let y=t[0];o=y*e,l=U*y,h=l-(l-y),u=y-h,s=u*x-(o-h*p-u*p-h*x);let k=0;s!==0&&(i[k++]=s);for(let S=1;S<n;S++)y=t[S],a=y*e,l=U*y,h=l-(l-y),u=y-h,c=u*x-(a-h*p-u*p-h*x),r=o+c,f=r-o,s=o-(r-f)+(c-f),s!==0&&(i[k++]=s),o=a+r,s=r-(o-a),s!==0&&(i[k++]=s);return(o!==0||k===0)&&(i[k++]=o),k}function Ke(n,t){let e=t[0];for(let i=1;i<n;i++)e+=t[i];return e}function tt(n){return new Float64Array(n)}const Gn=(3+16*ut)*ut,Jn=(2+12*ut)*ut,Kn=(9+64*ut)*ut*ut,Vt=tt(4),Qe=tt(8),He=tt(12),Ze=tt(16),pt=tt(4);function Qn(n,t,e,i,o,r,s){let a,c,f,l,h,u,p,x,y,k,S,g,v,d,b,m,A,B;const P=n-o,I=e-o,N=t-r,X=i-r;d=P*X,u=U*P,p=u-(u-P),x=P-p,u=U*X,y=u-(u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=U*l,y=u-(u-l),k=l-y,b=x*k-(d-p*y-x*y-p*k),m=c*f,u=U*c,p=u-(u-c),x=c-p,u=U*f,y=u-(u-f),k=f-y,A=x*k-(m-p*y-x*y-p*k),S=b-A,h=b-S,pt[0]=b-(S+h)+(h-A),g=d+S,h=g-d,v=d-(g-h)+(S-h),S=v-m,h=v-S,pt[1]=v-(S+h)+(h-m),B=g+S,h=B-g,pt[2]=g-(B-h)+(S-h),pt[3]=B;const T=ht(M,He,4,pt,Ze);return Ze[T-1]}function St(n,t,e,i,o,r){const s=(t-r)*(e-o),a=(n-o)*(i-r),c=s-a,f=Math.abs(s+a);return Math.abs(c)>=Gn*f?c:-Qn(n,t,e,i,o,r,f)}const Hn=(10+96*ut)*ut,Zn=(4+48*ut)*ut,ti=(44+576*ut)*ut*ut,Ct=tt(4),Xt=tt(4),Dt=tt(4),kt=tt(4),Et=tt(4),At=tt(4),gt=tt(4),mt=tt(4),Me=tt(8),Se=tt(8),ke=tt(8),Ee=tt(8),Ae=tt(8),Pe=tt(8),fe=tt(8),he=tt(8),le=tt(8),Lt=tt(4),jt=tt(4),$t=tt(4),z=tt(8),J=tt(16),nt=tt(16),it=tt(16),et=tt(32),Rt=tt(32),st=tt(48),vt=tt(64);let Ut=tt(1152),Ie=tt(1152);function at(n,t,e){n=ht(n,Ut,t,e,Ie);const i=Ut;return Ut=Ie,Ie=i,n}function ei(n,t,e,i,o,r,s,a,c){let f,l,h,u,p,x,y,k,S,g,v,d,b,m,A,B,P,I,N,X,F,w,E,M,T,O,D,_,C,R,L,q,j,V,$;const G=n-s,W=e-s,K=o-s,Q=t-a,Z=i-a,H=r-a;L=W*H,E=U*W,M=E-(E-W),T=W-M,E=U*H,O=E-(E-H),D=H-O,q=T*D-(L-M*O-T*O-M*D),j=K*Z,E=U*K,M=E-(E-K),T=K-M,E=U*Z,O=E-(E-Z),D=Z-O,V=T*D-(j-M*O-T*O-M*D),_=q-V,w=q-_,Ct[0]=q-(_+w)+(w-V),C=L+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,J),J,Y(ot,z,u,nt),nt,Y(rt,it,u,et),et,Rt,vt),vt),p!==0&&(f=at(f,Y(Y(4,Et,u,z),z,p,J),J)),x!==0&&(f=at(f,Y(Y(4,kt,-u,z),z,x,J),J))}if(y!==0){const rt=Y(m,fe,y,it);f=at(f,ht(Y(b,Pe,y,J),J,Y(rt,it,2*H,et),et,st),st);const ot=Y(P,Lt,y,z);f=at(f,xt(Y(ot,z,2*H,J),J,Y(ot,z,y,nt),nt,Y(rt,it,y,et),et,Rt,vt),vt)}}return Ut[f-1]}function ni(n,t,e,i,o,r,s,a){const c=n-s,f=e-s,l=o-s,h=t-a,u=i-a,p=r-a,x=f*p,y=l*u,k=c*c+h*h,S=l*h,g=c*p,v=f*f+u*u,d=c*u,b=f*h,m=l*l+p*p,A=k*(x-y)+v*(S-g)+m*(d-b),B=(Math.abs(x)+Math.abs(y))*k+(Math.abs(S)+Math.abs(g))*v+(Math.abs(d)+Math.abs(b))*m,P=Hn*B;return A>P||-A>P?A:ei(n,t,e,i,o,r,s,a,B)}function ii(n,t){var e,i,o=0,r,s,a,c,f,l,h,u=n[0],p=n[1],x=t.length;for(e=0;e<x;e++){i=0;var y=t[e],k=y.length-1;if(l=y[0],l[0]!==y[k][0]&&l[1]!==y[k][1])throw new Error("First and last coordinates in a ring must be the same");for(s=l[0]-u,a=l[1]-p,i;i<k;i++){if(h=y[i+1],c=h[0]-u,f=h[1]-p,a===0&&f===0){if(c<=0&&s>=0||s<=0&&c>=0)return 0}else if(f>=0&&a<=0||f<=0&&a>=0){if(r=St(s,c,a,f,0,0),r===0)return 0;(r>0&&f>0&&a<=0||r<0&&f<=0&&a>0)&&o++}l=h,a=f,s=c}}return o%2!==0}function Be(n,t,e={}){if(!n)throw new Error("point is required");if(!t)throw new Error("polygon is required");const i=zn(n),o=Wn(t),r=o.type,s=t.bbox;let a=o.coordinates;if(s&&ri(i,s)===!1)return!1;r==="Polygon"&&(a=[a]);let c=!1;for(var f=0;f<a.length;++f){const l=ii(i,a[f]);if(l===0)return!e.ignoreBoundary;l&&(c=!0)}return c}function ri(n,t){return t[0]<=n[0]&&t[1]<=n[1]&&t[2]>=n[0]&&t[3]>=n[1]}let tn=class{constructor(t=[],e=oi){if(this.data=t,this.length=this.data.length,this.compare=e,this.length>0)for(let i=(this.length>>1)-1;i>=0;i--)this._down(i)}push(t){this.data.push(t),this.length++,this._up(this.length-1)}pop(){if(this.length===0)return;const t=this.data[0],e=this.data.pop();return this.length--,this.length>0&&(this.data[0]=e,this._down(0)),t}peek(){return this.data[0]}_up(t){const{data:e,compare:i}=this,o=e[t];for(;t>0;){const r=t-1>>1,s=e[r];if(i(o,s)>=0)break;e[t]=s,t=r}e[t]=o}_down(t){const{data:e,compare:i}=this,o=this.length>>1,r=e[t];for(;t<o;){let s=(t<<1)+1,a=e[s];const c=s+1;if(c<this.length&&i(e[c],a)<0&&(s=c,a=e[c]),i(a,r)>=0)break;e[t]=a,t=s}e[t]=r}};function oi(n,t){return n<t?-1:n>t?1:0}function en(n,t){return n.p.x>t.p.x?1:n.p.x<t.p.x?-1:n.p.y!==t.p.y?n.p.y>t.p.y?1:-1:1}function si(n,t){return n.rightSweepEvent.p.x>t.rightSweepEvent.p.x?1:n.rightSweepEvent.p.x<t.rightSweepEvent.p.x?-1:n.rightSweepEvent.p.y!==t.rightSweepEvent.p.y?n.rightSweepEvent.p.y<t.rightSweepEvent.p.y?1:-1:1}class nn{constructor(t,e,i,o){this.p={x:t[0],y:t[1]},this.featureId=e,this.ringId=i,this.eventId=o,this.otherEvent=null,this.isLeftEndpoint=null}isSamePoint(t){return this.p.x===t.p.x&&this.p.y===t.p.y}}function ai(n,t){if(n.type==="FeatureCollection"){const e=n.features;for(let i=0;i<e.length;i++)rn(e[i],t)}else rn(n,t)}let ue=0,de=0,pe=0;function rn(n,t){const e=n.type==="Feature"?n.geometry:n;let i=e.coordinates;(e.type==="Polygon"||e.type==="MultiLineString")&&(i=[i]),e.type==="LineString"&&(i=[[i]]);for(let o=0;o<i.length;o++)for(let r=0;r<i[o].length;r++){let s=i[o][r][0],a=null;de=de+1;for(let c=0;c<i[o][r].length-1;c++){a=i[o][r][c+1];const f=new nn(s,ue,de,pe),l=new nn(a,ue,de,pe+1);f.otherEvent=l,l.otherEvent=f,en(f,l)>0?(l.isLeftEndpoint=!0,f.isLeftEndpoint=!1):(f.isLeftEndpoint=!0,l.isLeftEndpoint=!1),t.push(f),t.push(l),s=a,pe=pe+1}}ue=ue+1}class ci{constructor(t){this.leftSweepEvent=t,this.rightSweepEvent=t.otherEvent}}function fi(n,t){if(n===null||t===null||n.leftSweepEvent.ringId===t.leftSweepEvent.ringId&&(n.rightSweepEvent.isSamePoint(t.leftSweepEvent)||n.rightSweepEvent.isSamePoint(t.leftSweepEvent)||n.rightSweepEvent.isSamePoint(t.rightSweepEvent)||n.leftSweepEvent.isSamePoint(t.leftSweepEvent)||n.leftSweepEvent.isSamePoint(t.rightSweepEvent)))return!1;const e=n.leftSweepEvent.p.x,i=n.leftSweepEvent.p.y,o=n.rightSweepEvent.p.x,r=n.rightSweepEvent.p.y,s=t.leftSweepEvent.p.x,a=t.leftSweepEvent.p.y,c=t.rightSweepEvent.p.x,f=t.rightSweepEvent.p.y,l=(f-a)*(o-e)-(c-s)*(r-i),h=(c-s)*(i-a)-(f-a)*(e-s),u=(o-e)*(i-a)-(r-i)*(e-s);if(l===0)return!1;const p=h/l,x=u/l;if(p>=0&&p<=1&&x>=0&&x<=1){const y=e+p*(o-e),k=i+p*(r-i);return[y,k]}return!1}function hi(n,t){t=t||!1;const e=[],i=new tn([],si);for(;n.length;){const o=n.pop();if(o.isLeftEndpoint){const r=new ci(o);for(let s=0;s<i.data.length;s++){const a=i.data[s];if(t&&a.leftSweepEvent.featureId===o.featureId)continue;const c=fi(r,a);c!==!1&&e.push(c)}i.push(r)}else o.isLeftEndpoint===!1&&i.pop()}return e}function li(n,t){const e=new tn([],en);return ai(n,e),hi(e,t)}var ui=li;function di(n,t,e={}){const{removeDuplicates:i=!0,ignoreSelfIntersections:o=!0}=e;let r=[];n.type==="FeatureCollection"?r=r.concat(n.features):n.type==="Feature"?r.push(n):(n.type==="LineString"||n.type==="Polygon"||n.type==="MultiLineString"||n.type==="MultiPolygon")&&r.push(It(n)),t.type==="FeatureCollection"?r=r.concat(t.features):t.type==="Feature"?r.push(t):(t.type==="LineString"||t.type==="Polygon"||t.type==="MultiLineString"||t.type==="MultiPolygon")&&r.push(It(t));const s=ui(_t(r),o);let a=[];if(i){const c={};s.forEach(f=>{const l=f.join(",");c[l]||(c[l]=!0,a.push(f))})}else a=s;return _t(a.map(c=>Nt(c)))}function pi(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}function gi(n){if(Object.prototype.hasOwnProperty.call(n,"__esModule"))return n;var t=n.default;if(typeof t=="function"){var e=function i(){var o=!1;try{o=this instanceof i}catch{}return o?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};e.prototype=t.prototype}else e={};return Object.defineProperty(e,"__esModule",{value:!0}),Object.keys(n).forEach(function(i){var o=Object.getOwnPropertyDescriptor(n,i);Object.defineProperty(e,i,o.get?o:{enumerable:!0,get:function(){return n[i]}})}),e}function mi(n,t={}){let e=0,i=0,o=0;return _e(n,function(r){e+=r[0],i+=r[1],o++},!0),Nt([e/o,i/o],t.properties)}var ge={exports:{}},me={exports:{}},wi=me.exports,on;function yi(){return on||(on=1,(function(n,t){(function(e,i){n.exports=i()})(wi,function(){function e(g,v,d,b,m){(function A(B,P,I,N,X){for(;N>I;){if(N-I>600){var F=N-I+1,w=P-I+1,E=Math.log(F),M=.5*Math.exp(2*E/3),T=.5*Math.sqrt(E*M*(F-M)/F)*(w-F/2<0?-1:1),O=Math.max(I,Math.floor(P-w*M/F+T)),D=Math.min(N,Math.floor(P+(F-w)*M/F+T));A(B,P,O,D,X)}var _=B[P],C=I,R=N;for(i(B,I,P),X(B[N],_)>0&&i(B,I,N);C<R;){for(i(B,C,R),C++,R--;X(B[C],_)<0;)C++;for(;X(B[R],_)>0;)R--}X(B[I],_)===0?i(B,I,R):i(B,++R,N),R<=P&&(I=R+1),P<=R&&(N=R-1)}})(g,v,d||0,b||g.length-1,m||o)}function i(g,v,d){var b=g[v];g[v]=g[d],g[d]=b}function o(g,v){return g<v?-1:g>v?1:0}var r=function(g){g===void 0&&(g=9),this._maxEntries=Math.max(4,g),this._minEntries=Math.max(2,Math.ceil(.4*this._maxEntries)),this.clear()};function s(g,v,d){if(!d)return v.indexOf(g);for(var b=0;b<v.length;b++)if(d(g,v[b]))return b;return-1}function a(g,v){c(g,0,g.children.length,v,g)}function c(g,v,d,b,m){m||(m=k(null)),m.minX=1/0,m.minY=1/0,m.maxX=-1/0,m.maxY=-1/0;for(var A=v;A<d;A++){var B=g.children[A];f(m,g.leaf?b(B):B)}return m}function f(g,v){return g.minX=Math.min(g.minX,v.minX),g.minY=Math.min(g.minY,v.minY),g.maxX=Math.max(g.maxX,v.maxX),g.maxY=Math.max(g.maxY,v.maxY),g}function l(g,v){return g.minX-v.minX}function h(g,v){return g.minY-v.minY}function u(g){return(g.maxX-g.minX)*(g.maxY-g.minY)}function p(g){return g.maxX-g.minX+(g.maxY-g.minY)}function x(g,v){return g.minX<=v.minX&&g.minY<=v.minY&&v.maxX<=g.maxX&&v.maxY<=g.maxY}function y(g,v){return v.minX<=g.maxX&&v.minY<=g.maxY&&v.maxX>=g.minX&&v.maxY>=g.minY}function k(g){return{children:g,height:1,leaf:!0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}}function S(g,v,d,b,m){for(var A=[v,d];A.length;)if(!((d=A.pop())-(v=A.pop())<=b)){var B=v+Math.ceil((d-v)/b/2)*b;e(g,B,v,d,m),A.push(v,B,B,d)}}return r.prototype.all=function(){return this._all(this.data,[])},r.prototype.search=function(g){var v=this.data,d=[];if(!y(g,v))return d;for(var b=this.toBBox,m=[];v;){for(var A=0;A<v.children.length;A++){var B=v.children[A],P=v.leaf?b(B):B;y(g,P)&&(v.leaf?d.push(B):x(g,P)?this._all(B,d):m.push(B))}v=m.pop()}return d},r.prototype.collides=function(g){var v=this.data;if(!y(g,v))return!1;for(var d=[];v;){for(var b=0;b<v.children.length;b++){var m=v.children[b],A=v.leaf?this.toBBox(m):m;if(y(g,A)){if(v.leaf||x(g,A))return!0;d.push(m)}}v=d.pop()}return!1},r.prototype.load=function(g){if(!g||!g.length)return this;if(g.length<this._minEntries){for(var v=0;v<g.length;v++)this.insert(g[v]);return this}var d=this._build(g.slice(),0,g.length-1,0);if(this.data.children.length)if(this.data.height===d.height)this._splitRoot(this.data,d);else{if(this.data.height<d.height){var b=this.data;this.data=d,d=b}this._insert(d,this.data.height-d.height-1,!0)}else this.data=d;return this},r.prototype.insert=function(g){return g&&this._insert(g,this.data.height-1),this},r.prototype.clear=function(){return this.data=k([]),this},r.prototype.remove=function(g,v){if(!g)return this;for(var d,b,m,A=this.data,B=this.toBBox(g),P=[],I=[];A||P.length;){if(A||(A=P.pop(),b=P[P.length-1],d=I.pop(),m=!0),A.leaf){var N=s(g,A.children,v);if(N!==-1)return A.children.splice(N,1),P.push(A),this._condense(P),this}m||A.leaf||!x(A,B)?b?(d++,A=b.children[d],m=!1):A=null:(P.push(A),I.push(d),d=0,b=A,A=A.children[0])}return this},r.prototype.toBBox=function(g){return g},r.prototype.compareMinX=function(g,v){return g.minX-v.minX},r.prototype.compareMinY=function(g,v){return g.minY-v.minY},r.prototype.toJSON=function(){return this.data},r.prototype.fromJSON=function(g){return this.data=g,this},r.prototype._all=function(g,v){for(var d=[];g;)g.leaf?v.push.apply(v,g.children):d.push.apply(d,g.children),g=d.pop();return v},r.prototype._build=function(g,v,d,b){var m,A=d-v+1,B=this._maxEntries;if(A<=B)return a(m=k(g.slice(v,d+1)),this.toBBox),m;b||(b=Math.ceil(Math.log(A)/Math.log(B)),B=Math.ceil(A/Math.pow(B,b-1))),(m=k([])).leaf=!1,m.height=b;var P=Math.ceil(A/B),I=P*Math.ceil(Math.sqrt(B));S(g,v,d,I,this.compareMinX);for(var N=v;N<=d;N+=I){var X=Math.min(N+I-1,d);S(g,N,X,P,this.compareMinY);for(var F=N;F<=X;F+=P){var w=Math.min(F+P-1,X);m.children.push(this._build(g,F,w,b-1))}}return a(m,this.toBBox),m},r.prototype._chooseSubtree=function(g,v,d,b){for(;b.push(v),!v.leaf&&b.length-1!==d;){for(var m=1/0,A=1/0,B=void 0,P=0;P<v.children.length;P++){var I=v.children[P],N=u(I),X=(F=g,w=I,(Math.max(w.maxX,F.maxX)-Math.min(w.minX,F.minX))*(Math.max(w.maxY,F.maxY)-Math.min(w.minY,F.minY))-N);X<A?(A=X,m=N<m?N:m,B=I):X===A&&N<m&&(m=N,B=I)}v=B||v.children[0]}var F,w;return v},r.prototype._insert=function(g,v,d){var b=d?g:this.toBBox(g),m=[],A=this._chooseSubtree(b,this.data,v,m);for(A.children.push(g),f(A,b);v>=0&&m[v].children.length>this._maxEntries;)this._split(m,v),v--;this._adjustParentBBoxes(b,m,v)},r.prototype._split=function(g,v){var d=g[v],b=d.children.length,m=this._minEntries;this._chooseSplitAxis(d,m,b);var A=this._chooseSplitIndex(d,m,b),B=k(d.children.splice(A,d.children.length-A));B.height=d.height,B.leaf=d.leaf,a(d,this.toBBox),a(B,this.toBBox),v?g[v-1].children.push(B):this._splitRoot(d,B)},r.prototype._splitRoot=function(g,v){this.data=k([g,v]),this.data.height=g.height+1,this.data.leaf=!1,a(this.data,this.toBBox)},r.prototype._chooseSplitIndex=function(g,v,d){for(var b,m,A,B,P,I,N,X=1/0,F=1/0,w=v;w<=d-v;w++){var E=c(g,0,w,this.toBBox),M=c(g,w,d,this.toBBox),T=(m=E,A=M,B=void 0,P=void 0,I=void 0,N=void 0,B=Math.max(m.minX,A.minX),P=Math.max(m.minY,A.minY),I=Math.min(m.maxX,A.maxX),N=Math.min(m.maxY,A.maxY),Math.max(0,I-B)*Math.max(0,N-P)),O=u(E)+u(M);T<X?(X=T,b=w,F=O<F?O:F):T===X&&O<F&&(F=O,b=w)}return b||d-v},r.prototype._chooseSplitAxis=function(g,v,d){var b=g.leaf?this.compareMinX:l,m=g.leaf?this.compareMinY:h;this._allDistMargin(g,v,d,b)<this._allDistMargin(g,v,d,m)&&g.children.sort(b)},r.prototype._allDistMargin=function(g,v,d,b){g.children.sort(b);for(var m=this.toBBox,A=c(g,0,v,m),B=c(g,d-v,d,m),P=p(A)+p(B),I=v;I<d-v;I++){var N=g.children[I];f(A,g.leaf?m(N):N),P+=p(A)}for(var X=d-v-1;X>=v;X--){var F=g.children[X];f(B,g.leaf?m(F):F),P+=p(B)}return P},r.prototype._adjustParentBBoxes=function(g,v,d){for(var b=d;b>=0;b--)f(v[b],g)},r.prototype._condense=function(g){for(var v=g.length-1,d=void 0;v>=0;v--)g[v].children.length===0?v>0?(d=g[v-1].children).splice(d.indexOf(g[v]),1):this.clear():a(g[v],this.toBBox)},r})})(me)),me.exports}class vi{constructor(t=[],e=bi){if(this.data=t,this.length=this.data.length,this.compare=e,this.length>0)for(let i=(this.length>>1)-1;i>=0;i--)this._down(i)}push(t){this.data.push(t),this.length++,this._up(this.length-1)}pop(){if(this.length===0)return;const t=this.data[0],e=this.data.pop();return this.length--,this.length>0&&(this.data[0]=e,this._down(0)),t}peek(){return this.data[0]}_up(t){const{data:e,compare:i}=this,o=e[t];for(;t>0;){const r=t-1>>1,s=e[r];if(i(o,s)>=0)break;e[t]=s,t=r}e[t]=o}_down(t){const{data:e,compare:i}=this,o=this.length>>1,r=e[t];for(;t<o;){let s=(t<<1)+1,a=e[s];const c=s+1;if(c<this.length&&i(e[c],a)<0&&(s=c,a=e[c]),i(a,r)>=0)break;e[t]=a,t=s}e[t]=r}}function bi(n,t){return n<t?-1:n>t?1:0}const xi=gi(Object.freeze(Object.defineProperty({__proto__:null,default:vi},Symbol.toStringTag,{value:"Module"})));var Kt={exports:{}},Oe,sn;function _i(){return sn||(sn=1,Oe=function(t,e,i,o){var r=t[0],s=t[1],a=!1;i===void 0&&(i=0),o===void 0&&(o=e.length);for(var c=(o-i)/2,f=0,l=c-1;f<c;l=f++){var h=e[i+f*2+0],u=e[i+f*2+1],p=e[i+l*2+0],x=e[i+l*2+1],y=u>s!=x>s&&r<(p-h)*(s-u)/(x-u)+h;y&&(a=!a)}return a}),Oe}var Te,an;function Mi(){return an||(an=1,Te=function(t,e,i,o){var r=t[0],s=t[1],a=!1;i===void 0&&(i=0),o===void 0&&(o=e.length);for(var c=o-i,f=0,l=c-1;f<c;l=f++){var h=e[f+i][0],u=e[f+i][1],p=e[l+i][0],x=e[l+i][1],y=u>s!=x>s&&r<(p-h)*(s-u)/(x-u)+h;y&&(a=!a)}return a}),Te}var cn;function Si(){if(cn)return Kt.exports;cn=1;var n=_i(),t=Mi();return Kt.exports=function(i,o,r,s){return o.length>0&&Array.isArray(o[0])?t(i,o,r,s):n(i,o,r,s)},Kt.exports.nested=t,Kt.exports.flat=n,Kt.exports}var Qt={exports:{}},ki=Qt.exports,fn;function Ei(){return fn||(fn=1,(function(n,t){(function(e,i){i(t)})(ki,function(e){const o=33306690738754706e-32;function r(y,k,S,g,v){let d,b,m,A,B=k[0],P=g[0],I=0,N=0;P>B==P>-B?(d=B,B=k[++I]):(d=P,P=g[++N]);let X=0;if(I<y&&N<S)for(P>B==P>-B?(m=d-((b=B+d)-B),B=k[++I]):(m=d-((b=P+d)-P),P=g[++N]),d=b,m!==0&&(v[X++]=m);I<y&&N<S;)P>B==P>-B?(m=d-((b=d+B)-(A=b-d))+(B-A),B=k[++I]):(m=d-((b=d+P)-(A=b-d))+(P-A),P=g[++N]),d=b,m!==0&&(v[X++]=m);for(;I<y;)m=d-((b=d+B)-(A=b-d))+(B-A),B=k[++I],d=b,m!==0&&(v[X++]=m);for(;N<S;)m=d-((b=d+P)-(A=b-d))+(P-A),P=g[++N],d=b,m!==0&&(v[X++]=m);return d===0&&X!==0||(v[X++]=d),X}function s(y){return new Float64Array(y)}const a=33306690738754716e-32,c=22204460492503146e-32,f=11093356479670487e-47,l=s(4),h=s(8),u=s(12),p=s(16),x=s(4);e.orient2d=function(y,k,S,g,v,d){const b=(k-d)*(S-v),m=(y-v)*(g-d),A=b-m;if(b===0||m===0||b>0!=m>0)return A;const B=Math.abs(b+m);return Math.abs(A)>=a*B?A:-(function(P,I,N,X,F,w,E){let M,T,O,D,_,C,R,L,q,j,V,$,G,W,K,Q,Z,H;const ft=P-F,lt=N-F,rt=I-w,ot=X-w;_=(K=(L=ft-(R=(C=134217729*ft)-(C-ft)))*(j=ot-(q=(C=134217729*ot)-(C-ot)))-((W=ft*ot)-R*q-L*q-R*j))-(V=K-(Z=(L=rt-(R=(C=134217729*rt)-(C-rt)))*(j=lt-(q=(C=134217729*lt)-(C-lt)))-((Q=rt*lt)-R*q-L*q-R*j))),l[0]=K-(V+_)+(_-Z),_=(G=W-(($=W+V)-(_=$-W))+(V-_))-(V=G-Q),l[1]=G-(V+_)+(_-Q),_=(H=$+V)-$,l[2]=$-(H-_)+(V-_),l[3]=H;let Ft=(function(Hr,Vn){let Un=Vn[0];for(let ze=1;ze<Hr;ze++)Un+=Vn[ze];return Un})(4,l),ce=c*E;if(Ft>=ce||-Ft>=ce||(M=P-(ft+(_=P-ft))+(_-F),O=N-(lt+(_=N-lt))+(_-F),T=I-(rt+(_=I-rt))+(_-w),D=X-(ot+(_=X-ot))+(_-w),M===0&&T===0&&O===0&&D===0)||(ce=f*E+o*Math.abs(Ft),(Ft+=ft*D+ot*M-(rt*O+lt*T))>=ce||-Ft>=ce))return Ft;_=(K=(L=M-(R=(C=134217729*M)-(C-M)))*(j=ot-(q=(C=134217729*ot)-(C-ot)))-((W=M*ot)-R*q-L*q-R*j))-(V=K-(Z=(L=T-(R=(C=134217729*T)-(C-T)))*(j=lt-(q=(C=134217729*lt)-(C-lt)))-((Q=T*lt)-R*q-L*q-R*j))),x[0]=K-(V+_)+(_-Z),_=(G=W-(($=W+V)-(_=$-W))+(V-_))-(V=G-Q),x[1]=G-(V+_)+(_-Q),_=(H=$+V)-$,x[2]=$-(H-_)+(V-_),x[3]=H;const Jr=r(4,l,4,x,h);_=(K=(L=ft-(R=(C=134217729*ft)-(C-ft)))*(j=D-(q=(C=134217729*D)-(C-D)))-((W=ft*D)-R*q-L*q-R*j))-(V=K-(Z=(L=rt-(R=(C=134217729*rt)-(C-rt)))*(j=O-(q=(C=134217729*O)-(C-O)))-((Q=rt*O)-R*q-L*q-R*j))),x[0]=K-(V+_)+(_-Z),_=(G=W-(($=W+V)-(_=$-W))+(V-_))-(V=G-Q),x[1]=G-(V+_)+(_-Q),_=(H=$+V)-$,x[2]=$-(H-_)+(V-_),x[3]=H;const Kr=r(Jr,h,4,x,u);_=(K=(L=M-(R=(C=134217729*M)-(C-M)))*(j=D-(q=(C=134217729*D)-(C-D)))-((W=M*D)-R*q-L*q-R*j))-(V=K-(Z=(L=T-(R=(C=134217729*T)-(C-T)))*(j=O-(q=(C=134217729*O)-(C-O)))-((Q=T*O)-R*q-L*q-R*j))),x[0]=K-(V+_)+(_-Z),_=(G=W-(($=W+V)-(_=$-W))+(V-_))-(V=G-Q),x[1]=G-(V+_)+(_-Q),_=(H=$+V)-$,x[2]=$-(H-_)+(V-_),x[3]=H;const Qr=r(Kr,u,4,x,p);return p[Qr-1]})(y,k,S,g,v,d,B)},e.orient2dfast=function(y,k,S,g,v,d){return(k-d)*(S-v)-(y-v)*(g-d)},Object.defineProperty(e,"__esModule",{value:!0})})})(Qt,Qt.exports)),Qt.exports}var hn;function Ai(){if(hn)return ge.exports;hn=1;var n=yi(),t=xi,e=Si(),i=Ei().orient2d;t.default&&(t=t.default),ge.exports=o,ge.exports.default=o;function o(d,b,m){b=Math.max(0,b===void 0?2:b),m=m||0;var A=p(d),B=new n(16);B.toBBox=function(R){return{minX:R[0],minY:R[1],maxX:R[0],maxY:R[1]}},B.compareMinX=function(R,L){return R[0]-L[0]},B.compareMinY=function(R,L){return R[1]-L[1]},B.load(d);for(var P=[],I=0,N;I<A.length;I++){var X=A[I];B.remove(X),N=x(X,N),P.push(N)}var F=new n(16);for(I=0;I<P.length;I++)F.insert(u(P[I]));for(var w=b*b,E=m*m;P.length;){var M=P.shift(),T=M.p,O=M.next.p,D=y(T,O);if(!(D<E)){var _=D/w;X=r(B,M.prev.p,T,O,M.next.next.p,_,F),X&&Math.min(y(X,T),y(X,O))<=_&&(P.push(M),P.push(x(X,M)),B.remove(X),F.remove(M),F.insert(u(M)),F.insert(u(M.next)))}}M=N;var C=[];do C.push(M.p),M=M.next;while(M!==N);return C.push(M.p),C}function r(d,b,m,A,B,P,I){for(var N=new t([],s),X=d.data;X;){for(var F=0;F<X.children.length;F++){var w=X.children[F],E=X.leaf?k(w,m,A):a(m,A,w);E>P||N.push({node:w,dist:E})}for(;N.length&&!N.peek().node.children;){var M=N.pop(),T=M.node,O=k(T,b,m),D=k(T,A,B);if(M.dist<O&&M.dist<D&&f(m,T,I)&&f(A,T,I))return T}X=N.pop(),X&&(X=X.node)}return null}function s(d,b){return d.dist-b.dist}function a(d,b,m){if(c(d,m)||c(b,m))return 0;var A=S(d[0],d[1],b[0],b[1],m.minX,m.minY,m.maxX,m.minY);if(A===0)return 0;var B=S(d[0],d[1],b[0],b[1],m.minX,m.minY,m.minX,m.maxY);if(B===0)return 0;var P=S(d[0],d[1],b[0],b[1],m.maxX,m.minY,m.maxX,m.maxY);if(P===0)return 0;var I=S(d[0],d[1],b[0],b[1],m.minX,m.maxY,m.maxX,m.maxY);return I===0?0:Math.min(A,B,P,I)}function c(d,b){return d[0]>=b.minX&&d[0]<=b.maxX&&d[1]>=b.minY&&d[1]<=b.maxY}function f(d,b,m){for(var A=Math.min(d[0],b[0]),B=Math.min(d[1],b[1]),P=Math.max(d[0],b[0]),I=Math.max(d[1],b[1]),N=m.search({minX:A,minY:B,maxX:P,maxY:I}),X=0;X<N.length;X++)if(h(N[X].p,N[X].next.p,d,b))return!1;return!0}function l(d,b,m){return i(d[0],d[1],b[0],b[1],m[0],m[1])}function h(d,b,m,A){return d!==A&&b!==m&&l(d,b,m)>0!=l(d,b,A)>0&&l(m,A,d)>0!=l(m,A,b)>0}function u(d){var b=d.p,m=d.next.p;return d.minX=Math.min(b[0],m[0]),d.minY=Math.min(b[1],m[1]),d.maxX=Math.max(b[0],m[0]),d.maxY=Math.max(b[1],m[1]),d}function p(d){for(var b=d[0],m=d[0],A=d[0],B=d[0],P=0;P<d.length;P++){var I=d[P];I[0]<b[0]&&(b=I),I[0]>A[0]&&(A=I),I[1]<m[1]&&(m=I),I[1]>B[1]&&(B=I)}var N=[b,m,A,B],X=N.slice();for(P=0;P<d.length;P++)e(d[P],N)||X.push(d[P]);return v(X)}function x(d,b){var m={p:d,prev:null,next:null,minX:0,minY:0,maxX:0,maxY:0};return b?(m.next=b.next,m.prev=b,b.next.prev=m,b.next=m):(m.prev=m,m.next=m),m}function y(d,b){var m=d[0]-b[0],A=d[1]-b[1];return m*m+A*A}function k(d,b,m){var A=b[0],B=b[1],P=m[0]-A,I=m[1]-B;if(P!==0||I!==0){var N=((d[0]-A)*P+(d[1]-B)*I)/(P*P+I*I);N>1?(A=m[0],B=m[1]):N>0&&(A+=P*N,B+=I*N)}return P=d[0]-A,I=d[1]-B,P*P+I*I}function S(d,b,m,A,B,P,I,N){var X=m-d,F=A-b,w=I-B,E=N-P,M=d-B,T=b-P,O=X*X+F*F,D=X*w+F*E,_=w*w+E*E,C=X*M+F*T,R=w*M+E*T,L=O*_-D*D,q,j,V,$,G=L,W=L;L===0?(j=0,G=1,$=R,W=_):(j=D*R-_*C,$=O*R-D*C,j<0?(j=0,$=R,W=_):j>G&&(j=G,$=R+D,W=_)),$<0?($=0,-C<0?j=0:-C>O?j=G:(j=-C,G=O)):$>W&&($=W,-C+D<0?j=0:-C+D>O?j=G:(j=-C+D,G=O)),q=j===0?0:j/G,V=$===0?0:$/W;var K=(1-q)*d+q*m,Q=(1-q)*b+q*A,Z=(1-V)*B+V*I,H=(1-V)*P+V*N,ft=Z-K,lt=H-Q;return ft*ft+lt*lt}function g(d,b){return d[0]===b[0]?d[1]-b[1]:d[0]-b[0]}function v(d){d.sort(g);for(var b=[],m=0;m<d.length;m++){for(;b.length>=2&&l(b[b.length-2],b[b.length-1],d[m])<=0;)b.pop();b.push(d[m])}for(var A=[],B=d.length-1;B>=0;B--){for(;A.length>=2&&l(A[A.length-2],A[A.length-1],d[B])<=0;)A.pop();A.push(d[B])}return A.pop(),b.pop(),b.concat(A)}return ge.exports}var Pi=Ai();const Ii=pi(Pi);function ln(n,t={}){t.concavity=t.concavity||1/0;const e=[];if(_e(n,o=>{e.push([o[0],o[1]])}),!e.length)return null;const i=Ii(e,t.concavity);return i.length>3?Jt([i]):null}function un(n,t,e={}){const i={type:"Feature"};return(e.id===0||e.id)&&(i.id=e.id),e.bbox&&(i.bbox=e.bbox),i.properties=t||{},i.geometry=n,i}function Ht(n,t,e={}){if(!n)throw new Error("coordinates is required");if(!Array.isArray(n))throw new Error("coordinates must be an Array");if(n.length<2)throw new Error("coordinates must be at least 2 numbers long");if(!pn(n[0])||!pn(n[1]))throw new Error("coordinates must contain numbers");return un({type:"Point",coordinates:n},t,e)}function dn(n,t,e={}){for(const i of n){if(i.length<4)throw new Error("Each LinearRing of a Polygon must have 4 or more Positions.");if(i[i.length-1].length!==i[0].length)throw new Error("First and last Position are not equivalent.");for(let o=0;o<i[i.length-1].length;o++)if(i[i.length-1][o]!==i[0][o])throw new Error("First and last Position are not equivalent.")}return un({type:"Polygon",coordinates:n},t,e)}function zt(n,t={}){const e={type:"FeatureCollection"};return t.id&&(e.id=t.id),t.bbox&&(e.bbox=t.bbox),e.features=n,e}function pn(n){return!isNaN(n)&&n!==null&&!Array.isArray(n)}function Bi(n){if(!n)throw new Error("coord is required");if(!Array.isArray(n)){if(n.type==="Feature"&&n.geometry!==null&&n.geometry.type==="Point")return[...n.geometry.coordinates];if(n.type==="Point")return[...n.coordinates]}if(Array.isArray(n)&&n.length>=2&&!Array.isArray(n[0])&&!Array.isArray(n[1]))return[...n];throw new Error("coord must be GeoJSON Point or an Array of numbers")}function gn(n){if(Array.isArray(n))return n;if(n.type==="Feature"){if(n.geometry!==null)return n.geometry.coordinates}else if(n.coordinates)return n.coordinates;throw new Error("coords must be GeoJSON Feature, Geometry Object or an Array")}function Oi(n){return n.type==="Feature"?n.geometry:n}const Bt=11102230246251565e-32,dt=134217729,Ti=(3+8*Bt)*Bt;function Ne(n,t,e,i,o){let r,s,a,c,f=t[0],l=i[0],h=0,u=0;l>f==l>-f?(r=f,f=t[++h]):(r=l,l=i[++u]);let p=0;if(h<n&&u<e)for(l>f==l>-f?(s=f+r,a=r-(s-f),f=t[++h]):(s=l+r,a=r-(s-l),l=i[++u]),r=s,a!==0&&(o[p++]=a);h<n&&u<e;)l>f==l>-f?(s=r+f,c=s-r,a=r-(s-c)+(f-c),f=t[++h]):(s=r+l,c=s-r,a=r-(s-c)+(l-c),l=i[++u]),r=s,a!==0&&(o[p++]=a);for(;h<n;)s=r+f,c=s-r,a=r-(s-c)+(f-c),f=t[++h],r=s,a!==0&&(o[p++]=a);for(;u<e;)s=r+l,c=s-r,a=r-(s-c)+(l-c),l=i[++u],r=s,a!==0&&(o[p++]=a);return(r!==0||p===0)&&(o[p++]=r),p}function Ni(n,t){let e=t[0];for(let i=1;i<n;i++)e+=t[i];return e}function Zt(n){return new Float64Array(n)}const Ci=(3+16*Bt)*Bt,Xi=(2+12*Bt)*Bt,Di=(9+64*Bt)*Bt*Bt,Wt=Zt(4),mn=Zt(8),wn=Zt(12),yn=Zt(16),wt=Zt(4);function Ri(n,t,e,i,o,r,s){let a,c,f,l,h,u,p,x,y,k,S,g,v,d,b,m,A,B;const P=n-o,I=e-o,N=t-r,X=i-r;d=P*X,u=dt*P,p=u-(u-P),x=P-p,u=dt*X,y=u-(u-X),k=X-y,b=x*k-(d-p*y-x*y-p*k),m=N*I,u=dt*N,p=u-(u-N),x=N-p,u=dt*I,y=u-(u-I),k=I-y,A=x*k-(m-p*y-x*y-p*k),S=b-A,h=b-S,Wt[0]=b-(S+h)+(h-A),g=d+S,h=g-d,v=d-(g-h)+(S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=d+S,h=g-d,v=d-(g-h)+(S-h),S=v-m,h=v-S,wt[1]=v-(S+h)+(h-m),B=g+S,h=B-g,wt[2]=g-(B-h)+(S-h),wt[3]=B;const T=Ne(M,wn,4,wt,yn);return yn[T-1]}function Yi(n,t,e,i,o,r){const s=(t-r)*(e-o),a=(n-o)*(i-r),c=s-a,f=Math.abs(s+a);return Math.abs(c)>=Ci*f?c:-Ri(n,t,e,i,o,r,f)}function Fi(n,t){var e,i,o=0,r,s,a,c,f,l,h,u=n[0],p=n[1],x=t.length;for(e=0;e<x;e++){i=0;var y=t[e],k=y.length-1;if(l=y[0],l[0]!==y[k][0]&&l[1]!==y[k][1])throw new Error("First and last coordinates in a ring must be the same");for(s=l[0]-u,a=l[1]-p,i;i<k;i++){if(h=y[i+1],c=h[0]-u,f=h[1]-p,a===0&&f===0){if(c<=0&&s>=0||s<=0&&c>=0)return 0}else if(f>=0&&a<=0||f<=0&&a>=0){if(r=Yi(s,c,a,f,0,0),r===0)return 0;(r>0&&f>0&&a<=0||r<0&&f<=0&&a>0)&&o++}l=h,a=f,s=c}}return o%2!==0}function Ce(n,t,e={}){if(!n)throw new Error("point is required");if(!t)throw new Error("polygon is required");const i=Bi(n),o=Oi(t),r=o.type,s=t.bbox;let a=o.coordinates;if(s&&Li(i,s)===!1)return!1;r==="Polygon"&&(a=[a]);let c=!1;for(var f=0;f<a.length;++f){const l=Fi(i,a[f]);if(l===0)return!e.ignoreBoundary;l&&(c=!0)}return c}function Li(n,t){return t[0]<=n[0]&&t[1]<=n[1]&&t[2]>=n[0]&&t[3]>=n[1]}function Xe(n,t){for(let e=0;e<t.features.length;e++)if(Ce(n,t.features[e]))return t.features[e]}function vn(n,t,e){const i=t.geometry.coordinates[0][0],o=t.geometry.coordinates[0][1],r=t.geometry.coordinates[0][2],s=n.geometry.coordinates,a=t.properties.a.geom,c=t.properties.b.geom,f=t.properties.c.geom,l=[o[0]-i[0],o[1]-i[1]],h=[r[0]-i[0],r[1]-i[1]],u=[s[0]-i[0],s[1]-i[1]],p=[c[0]-a[0],c[1]-a[1]],x=[f[0]-a[0],f[1]-a[1]];let y=(h[1]*u[0]-h[0]*u[1])/(l[0]*h[1]-l[1]*h[0]),k=(l[0]*u[1]-l[1]*u[0])/(l[0]*h[1]-l[1]*h[0]);if(e){const S=e[t.properties.a.index],g=e[t.properties.b.index],v=e[t.properties.c.index];let d;if(y<0||k<0||1-y-k<0){const b=y/(y+k),m=k/(y+k);d=y/g/(b/g+m/v),k=k/v/(b/g+m/v)}else d=y/g/(y/g+k/v+(1-y-k)/S),k=k/v/(y/g+k/v+(1-y-k)/S);y=d}return[y*p[0]+k*x[0]+a[0],y*p[1]+k*x[1]+a[1]]}function ji(n,t,e,i){const o=n.geometry.coordinates,r=e.geometry.coordinates,s=Math.atan2(o[0]-r[0],o[1]-r[1]),a=$i(s,t[0]);if(a===void 0)throw new Error("Unable to determine vertex index");const c=t[1][a];return vn(n,c.features[0],i)}function te(n,t,e,i,o,r,s,a){let c;if(s&&(c=Xe(n,zt([s]))),!c)if(e){const f=n.geometry.coordinates,l=e.gridNum,h=e.xOrigin,u=e.yOrigin,p=e.xUnit,x=e.yUnit,y=e.gridCache,k=Pt(f[0],h,p,l),S=Pt(f[1],u,x,l),g=y[k]?y[k][S]?y[k][S]:[]:[],v=zt(g.map(d=>t.features[d]));c=Xe(n,v)}else c=Xe(n,t);return a&&a(c),c?vn(n,c,r):ji(n,i,o,r)}function Pt(n,t,e,i){let o=Math.floor((n-t)/e);return o<0&&(o=0),o>=i&&(o=i-1),o}function $i(n,t){let e=bn(n-t[0]),i=Math.PI*2,o;for(let r=0;r<t.length;r++){const s=(r+1)%t.length,a=bn(n-t[s]),c=Math.min(Math.abs(e),Math.abs(a));e*a<=0&&c<i&&(i=c,o=r),e=a}return o}function bn(n,t=!1){const e=2*Math.PI,i=n-Math.floor(n/e)*e;return t?i:i>Math.PI?i-e:i}function xn(n){const t=n.features;for(let e=0;e<t.length;e++){const i=t[e];`${i.properties.a.index}`.substring(0,1)==="b"&&`${i.properties.b.index}`.substring(0,1)==="b"?t[e]={geometry:{type:"Polygon",coordinates:[[i.geometry.coordinates[0][2],i.geometry.coordinates[0][0],i.geometry.coordinates[0][1],i.geometry.coordinates[0][2]]]},properties:{a:{geom:i.properties.c.geom,index:i.properties.c.index},b:{geom:i.properties.a.geom,index:i.properties.a.index},c:{geom:i.properties.b.geom,index:i.properties.b.index}},type:"Feature"}:`${i.properties.c.index}`.substring(0,1)==="b"&&`${i.properties.a.index}`.substring(0,1)==="b"&&(t[e]={geometry:{type:"Polygon",coordinates:[[i.geometry.coordinates[0][1],i.geometry.coordinates[0][2],i.geometry.coordinates[0][0],i.geometry.coordinates[0][1]]]},properties:{a:{geom:i.properties.b.geom,index:i.properties.b.index},b:{geom:i.properties.c.geom,index:i.properties.c.index},c:{geom:i.properties.a.geom,index:i.properties.a.index}},type:"Feature"})}return n}function _n(n){const t=["a","b","c","a"].map(r=>n.properties[r].geom),e=n.geometry.coordinates[0],i=n.properties,o={a:{geom:e[0],index:i.a.index},b:{geom:e[1],index:i.b.index},c:{geom:e[2],index:i.c.index}};return dn([t],o)}function qi(n){const t=[0,1,2,0].map(i=>n[i][0][0]),e={a:{geom:n[0][0][1],index:n[0][1]},b:{geom:n[1][0][1],index:n[1][1]},c:{geom:n[2][0][1],index:n[2][1]}};return dn([t],e)}function De(n,t,e,i,o,r=!1,s){const a=n.map(c=>{(!s||s<2.00703)&&(c=Mn(c));const f=isFinite(c)?t[c]:c==="c"?i:(function(){const l=c.match(/^b(\d+)$/);if(l)return o[parseInt(l[1])];const h=c.match(/^e(\d+)$/);if(h)return e[parseInt(h[1])];throw new Error("Bad index value for indexesToTri")})();return r?[[f[1],f[0]],c]:[[f[0],f[1]],c]});return qi(a)}function Mn(n){return typeof n=="number"?n:n.replace(/^(c|e|b)(?:ent|dgeNode|box)(\d+)?$/,"$1$2")}function Sn(n,t){return t&&t>=2.00703||Array.isArray(n[0])?n:n.map(e=>[e.illstNodes,e.mercNodes,e.startEnd])}const Re=2.00703;function Vi(n){return!!(n.version!==void 0||!n.tins&&n.points&&n.tins_points)}function Ui(n){return{points:n.points,pointsWeightBuffer:Wi(n),strictStatus:Gi(n),verticesParams:Ji(n),centroid:Ki(n),edges:Sn(n.edges||[]),edgeNodes:n.edgeNodes||[],tins:Qi(n),kinks:Hi(n.kinks_points),yaxisMode:n.yaxisMode??"invert",strictMode:n.strictMode??"auto",vertexMode:n.vertexMode,bounds:n.bounds,boundsPolygon:n.boundsPolygon,wh:n.wh,xy:n.xy??[0,0]}}function zi(n){const t=Zi(n),e=t.tins;return{compiled:t,tins:e,points:tr(e),strictStatus:t.strict_status,pointsWeightBuffer:t.weight_buffer,verticesParams:t.vertices_params,centroid:t.centroid,kinks:t.kinks}}function Wi(n){return!n.version||n.version<Re?["forw","bakw"].reduce((t,e)=>{const i=n.weight_buffer[e];return i&&(t[e]=Object.keys(i).reduce((o,r)=>{const s=Mn(r);return o[s]=i[r],o},{})),t},{}):n.weight_buffer}function Gi(n){return n.strict_status?n.strict_status:n.kinks_points?"strict_error":n.tins_points.length===2?"loose":"strict"}function Ji(n){const t={forw:[n.vertices_params[0]],bakw:[n.vertices_params[1]]};return t.forw[1]=kn(n,!1),t.bakw[1]=kn(n,!0),t}function kn(n,t){const e=n.vertices_points.length;return Array.from({length:e},(i,o)=>{const r=(o+1)%e,s=De(["c",`b${o}`,`b${r}`],n.points,n.edgeNodes||[],n.centroid_point,n.vertices_points,t,Re);return zt([s])})}function Ki(n){return{forw:Ht(n.centroid_point[0],{target:{geom:n.centroid_point[1],index:"c"}}),bakw:Ht(n.centroid_point[1],{target:{geom:n.centroid_point[0],index:"c"}})}}function Qi(n){const t=n.tins_points.length===1?0:1;return{forw:zt(n.tins_points[0].map(e=>De(e,n.points,n.edgeNodes||[],n.centroid_point,n.vertices_points,!1,n.version))),bakw:zt(n.tins_points[t].map(e=>De(e,n.points,n.edgeNodes||[],n.centroid_point,n.vertices_points,!0,n.version)))}}function Hi(n){if(n)return{bakw:zt(n.map(t=>Ht(t)))}}function Zi(n){return JSON.parse(JSON.stringify(n).replace('"cent"','"c"').replace(/"bbox(\d+)"/g,'"b$1"'))}function tr(n){const t=[],e=n.forw.features;for(let i=0;i<e.length;i++){const o=e[i];["a","b","c"].forEach((r,s)=>{const a=o.geometry.coordinates[0][s],c=o.properties[r].geom,f=o.properties[r].index;typeof f=="number"&&(t[f]=[a,c])})}return t}const Ye=Re;class Mt{static VERTEX_PLAIN="plain";static VERTEX_BIRDEYE="birdeye";static MODE_STRICT="strict";static MODE_AUTO="auto";static MODE_LOOSE="loose";static STATUS_STRICT="strict";static STATUS_ERROR="strict_error";static STATUS_LOOSE="loose";static YAXIS_FOLLOW="follow";static YAXIS_INVERT="invert";points=[];pointsWeightBuffer;strict_status;vertices_params;centroid;edgeNodes;edges;tins;kinks;yaxisMode=Mt.YAXIS_INVERT;strictMode=Mt.MODE_AUTO;vertexMode=Mt.VERTEX_PLAIN;bounds;boundsPolygon;wh;xy;indexedTins;stateFull=!1;stateTriangle;stateBackward;priority;importance;xyBounds;mercBounds;constructor(){}setCompiled(t){if(Vi(t)){this.applyModernState(Ui(t));return}this.applyLegacyState(zi(t))}applyModernState(t){this.points=t.points,this.pointsWeightBuffer=t.pointsWeightBuffer,this.strict_status=t.strictStatus,this.vertices_params=t.verticesParams,this.centroid=t.centroid,this.edges=t.edges,this.edgeNodes=t.edgeNodes||[],this.tins=t.tins,this.addIndexedTin(),this.kinks=t.kinks,this.yaxisMode=t.yaxisMode??Mt.YAXIS_INVERT,this.vertexMode=t.vertexMode??Mt.VERTEX_PLAIN,this.strictMode=t.strictMode??Mt.MODE_AUTO,t.bounds?(this.bounds=t.bounds,this.boundsPolygon=t.boundsPolygon,this.xy=t.xy,this.wh=t.wh):(this.bounds=void 0,this.boundsPolygon=void 0,this.xy=t.xy??[0,0],t.wh&&(this.wh=t.wh))}applyLegacyState(t){this.tins=t.tins,this.addIndexedTin(),this.strict_status=t.strictStatus,this.pointsWeightBuffer=t.pointsWeightBuffer,this.vertices_params=t.verticesParams,this.centroid=t.centroid,this.kinks=t.kinks,this.points=t.points}addIndexedTin(){const t=this.tins,e=t.forw,i=t.bakw,o=Math.ceil(Math.sqrt(e.features.length));if(o<3){this.indexedTins=void 0;return}let r=[],s=[];const a=e.features.map(y=>{let k=[];return gn(y)[0].map(S=>{r.length===0?r=[Array.from(S),Array.from(S)]:(S[0]<r[0][0]&&(r[0][0]=S[0]),S[0]>r[1][0]&&(r[1][0]=S[0]),S[1]<r[0][1]&&(r[0][1]=S[1]),S[1]>r[1][1]&&(r[1][1]=S[1])),k.length===0?k=[Array.from(S),Array.from(S)]:(S[0]<k[0][0]&&(k[0][0]=S[0]),S[0]>k[1][0]&&(k[1][0]=S[0]),S[1]<k[0][1]&&(k[0][1]=S[1]),S[1]>k[1][1]&&(k[1][1]=S[1]))}),k}),c=(r[1][0]-r[0][0])/o,f=(r[1][1]-r[0][1])/o,l=a.reduce((y,k,S)=>{const g=Pt(k[0][0],r[0][0],c,o),v=Pt(k[1][0],r[0][0],c,o),d=Pt(k[0][1],r[0][1],f,o),b=Pt(k[1][1],r[0][1],f,o);for(let m=g;m<=v;m++){y[m]||(y[m]=[]);for(let A=d;A<=b;A++)y[m][A]||(y[m][A]=[]),y[m][A].push(S)}return y},[]),h=i.features.map(y=>{let k=[];return gn(y)[0].map(S=>{s.length===0?s=[Array.from(S),Array.from(S)]:(S[0]<s[0][0]&&(s[0][0]=S[0]),S[0]>s[1][0]&&(s[1][0]=S[0]),S[1]<s[0][1]&&(s[0][1]=S[1]),S[1]>s[1][1]&&(s[1][1]=S[1])),k.length===0?k=[Array.from(S),Array.from(S)]:(S[0]<k[0][0]&&(k[0][0]=S[0]),S[0]>k[1][0]&&(k[1][0]=S[0]),S[1]<k[0][1]&&(k[0][1]=S[1]),S[1]>k[1][1]&&(k[1][1]=S[1]))}),k}),u=(s[1][0]-s[0][0])/o,p=(s[1][1]-s[0][1])/o,x=h.reduce((y,k,S)=>{const g=Pt(k[0][0],s[0][0],u,o),v=Pt(k[1][0],s[0][0],u,o),d=Pt(k[0][1],s[0][1],p,o),b=Pt(k[1][1],s[0][1],p,o);for(let m=g;m<=v;m++){y[m]||(y[m]=[]);for(let A=d;A<=b;A++)y[m][A]||(y[m][A]=[]),y[m][A].push(S)}return y},[]);this.indexedTins={forw:{gridNum:o,xOrigin:r[0][0],yOrigin:r[0][1],xUnit:c,yUnit:f,gridCache:l},bakw:{gridNum:o,xOrigin:s[0][0],yOrigin:s[0][1],xUnit:u,yUnit:p,gridCache:x}}}transform(t,e,i){if(!this.tins)throw new Error("setCompiled() must be called before transform()");if(e&&this.strict_status==Mt.STATUS_ERROR)throw new Error('Backward transform is not allowed if strict_status == "strict_error"');this.yaxisMode==Mt.YAXIS_FOLLOW&&e&&(t=[t[0],-1*t[1]]);const o=Ht(t);if(this.bounds&&!e&&!i&&!Ce(o,this.boundsPolygon))return!1;const r=e?this.tins.bakw:this.tins.forw,s=e?this.indexedTins.bakw:this.indexedTins.forw,a=e?this.vertices_params.bakw:this.vertices_params.forw,c=e?this.centroid.bakw:this.centroid.forw,f=e?this.pointsWeightBuffer.bakw:this.pointsWeightBuffer.forw;let l,h;this.stateFull&&(this.stateBackward==e?l=this.stateTriangle:(this.stateBackward=e,this.stateTriangle=void 0),h=p=>{this.stateTriangle=p});let u=te(o,r,s,a,c,f,l,h);if(this.bounds&&e&&!i){const p=Ht(u);if(!Ce(p,this.boundsPolygon))return!1}else this.yaxisMode==Mt.YAXIS_FOLLOW&&!e&&(u=[u[0],-1*u[1]]);return u}}const En=Math.pow(2,-52),we=new Uint32Array(512);class Fe{static from(t,e=or,i=sr){const o=t.length,r=new Float64Array(o*2);for(let s=0;s<o;s++){const a=t[s];r[2*s]=e(a),r[2*s+1]=i(a)}return new Fe(r)}constructor(t){const e=t.length>>1;if(e>0&&typeof t[0]!="number")throw new Error("Expected coords to contain numbers.");this.coords=t;const i=Math.max(2*e-5,0);this._triangles=new Uint32Array(i*3),this._halfedges=new Int32Array(i*3),this._hashSize=Math.ceil(Math.sqrt(e)),this._hullPrev=new Uint32Array(e),this._hullNext=new Uint32Array(e),this._hullTri=new Uint32Array(e),this._hullHash=new Int32Array(this._hashSize),this._ids=new Uint32Array(e),this._dists=new Float64Array(e),this.trianglesLen=0,this._cx=0,this._cy=0,this._hullStart=0,this.hull=this._triangles,this.triangles=this._triangles,this.halfedges=this._halfedges,this.update()}update(){const{coords:t,_hullPrev:e,_hullNext:i,_hullTri:o,_hullHash:r}=this,s=t.length>>1;let a=1/0,c=1/0,f=-1/0,l=-1/0;for(let P=0;P<s;P++){const I=t[2*P],N=t[2*P+1];I<a&&(a=I),N<c&&(c=N),I>f&&(f=I),N>l&&(l=N),this._ids[P]=P}const h=(a+f)/2,u=(c+l)/2;let p=0,x=0,y=0;for(let P=0,I=1/0;P<s;P++){const N=Le(h,u,t[2*P],t[2*P+1]);N<I&&(p=P,I=N)}const k=t[2*p],S=t[2*p+1];for(let P=0,I=1/0;P<s;P++){if(P===p)continue;const N=Le(k,S,t[2*P],t[2*P+1]);N<I&&N>0&&(x=P,I=N)}let g=t[2*x],v=t[2*x+1],d=1/0;for(let P=0;P<s;P++){if(P===p||P===x)continue;const I=ir(k,S,g,v,t[2*P],t[2*P+1]);I<d&&(y=P,d=I)}let b=t[2*y],m=t[2*y+1];if(d===1/0){for(let N=0;N<s;N++)this._dists[N]=t[2*N]-t[0]||t[2*N+1]-t[1];Gt(this._ids,this._dists,0,s-1);const P=new Uint32Array(s);let I=0;for(let N=0,X=-1/0;N<s;N++){const F=this._ids[N],w=this._dists[F];w>X&&(P[I++]=F,X=w)}this.hull=P.subarray(0,I),this.triangles=new Uint32Array(0),this.halfedges=new Int32Array(0);return}if(St(k,S,g,v,b,m)<0){const P=x,I=g,N=v;x=y,g=b,v=m,y=P,b=I,m=N}const A=rr(k,S,g,v,b,m);this._cx=A.x,this._cy=A.y;for(let P=0;P<s;P++)this._dists[P]=Le(t[2*P],t[2*P+1],A.x,A.y);Gt(this._ids,this._dists,0,s-1),this._hullStart=p;let B=3;i[p]=e[y]=x,i[x]=e[p]=y,i[y]=e[x]=p,o[p]=0,o[x]=1,o[y]=2,r.fill(-1),r[this._hashKey(k,S)]=p,r[this._hashKey(g,v)]=x,r[this._hashKey(b,m)]=y,this.trianglesLen=0,this._addTriangle(p,x,y,-1,-1,-1);for(let P=0,I=0,N=0;P<this._ids.length;P++){const X=this._ids[P],F=t[2*X],w=t[2*X+1];if(P>0&&Math.abs(F-I)<=En&&Math.abs(w-N)<=En||(I=F,N=w,X===p||X===x||X===y))continue;let E=0;for(let _=0,C=this._hashKey(F,w);_<this._hashSize&&(E=r[(C+_)%this._hashSize],!(E!==-1&&E!==i[E]));_++);E=e[E];let M=E,T;for(;T=i[M],St(F,w,t[2*M],t[2*M+1],t[2*T],t[2*T+1])>=0;)if(M=T,M===E){M=-1;break}if(M===-1)continue;let O=this._addTriangle(M,X,i[M],-1,-1,o[M]);o[X]=this._legalize(O+2),o[M]=O,B++;let D=i[M];for(;T=i[D],St(F,w,t[2*D],t[2*D+1],t[2*T],t[2*T+1])<0;)O=this._addTriangle(D,X,T,o[X],-1,o[D]),o[X]=this._legalize(O+2),i[D]=D,B--,D=T;if(M===E)for(;T=e[M],St(F,w,t[2*T],t[2*T+1],t[2*M],t[2*M+1])<0;)O=this._addTriangle(T,X,M,-1,o[M],o[T]),this._legalize(O+2),o[T]=O,i[M]=M,B--,M=T;this._hullStart=e[X]=M,i[M]=e[D]=X,i[X]=D,r[this._hashKey(F,w)]=X,r[this._hashKey(t[2*M],t[2*M+1])]=M}this.hull=new Uint32Array(B);for(let P=0,I=this._hullStart;P<B;P++)this.hull[P]=I,I=i[I];this.triangles=this._triangles.subarray(0,this.trianglesLen),this.halfedges=this._halfedges.subarray(0,this.trianglesLen)}_hashKey(t,e){return Math.floor(er(t-this._cx,e-this._cy)*this._hashSize)%this._hashSize}_legalize(t){const{_triangles:e,_halfedges:i,coords:o}=this;let r=0,s=0;for(;;){const a=i[t],c=t-t%3;if(s=c+(t+2)%3,a===-1){if(r===0)break;t=we[--r];continue}const f=a-a%3,l=c+(t+1)%3,h=f+(a+2)%3,u=e[s],p=e[t],x=e[l],y=e[h];if(nr(o[2*u],o[2*u+1],o[2*p],o[2*p+1],o[2*x],o[2*x+1],o[2*y],o[2*y+1])){e[t]=y,e[a]=u;const S=i[h];if(S===-1){let v=this._hullStart;do{if(this._hullTri[v]===h){this._hullTri[v]=t;break}v=this._hullPrev[v]}while(v!==this._hullStart)}this._link(t,S),this._link(a,i[s]),this._link(s,h);const g=f+(a+1)%3;r<we.length&&(we[r++]=g)}else{if(r===0)break;t=we[--r]}}return s}_link(t,e){this._halfedges[t]=e,e!==-1&&(this._halfedges[e]=t)}_addTriangle(t,e,i,o,r,s){const a=this.trianglesLen;return this._triangles[a]=t,this._triangles[a+1]=e,this._triangles[a+2]=i,this._link(a,o),this._link(a+1,r),this._link(a+2,s),this.trianglesLen+=3,a}}function er(n,t){const e=n/(Math.abs(n)+Math.abs(t));return(t>0?3-e:1+e)/4}function Le(n,t,e,i){const o=n-e,r=t-i;return o*o+r*r}function nr(n,t,e,i,o,r,s,a){const c=n-s,f=t-a,l=e-s,h=i-a,u=o-s,p=r-a,x=c*c+f*f,y=l*l+h*h,k=u*u+p*p;return c*(h*k-y*p)-f*(l*k-y*u)+x*(l*p-h*u)<0}function ir(n,t,e,i,o,r){const s=e-n,a=i-t,c=o-n,f=r-t,l=s*s+a*a,h=c*c+f*f,u=.5/(s*f-a*c),p=(f*l-a*h)*u,x=(s*h-c*l)*u;return p*p+x*x}function rr(n,t,e,i,o,r){const s=e-n,a=i-t,c=o-n,f=r-t,l=s*s+a*a,h=c*c+f*f,u=.5/(s*f-a*c),p=n+(f*l-a*h)*u,x=t+(s*h-c*l)*u;return{x:p,y:x}}function Gt(n,t,e,i){if(i-e<=20)for(let o=e+1;o<=i;o++){const r=n[o],s=t[r];let a=o-1;for(;a>=e&&t[n[a]]>s;)n[a+1]=n[a--];n[a+1]=r}else{const o=e+i>>1;let r=e+1,s=i;ee(n,o,r),t[n[e]]>t[n[i]]&&ee(n,e,i),t[n[r]]>t[n[i]]&&ee(n,r,i),t[n[e]]>t[n[r]]&&ee(n,e,r);const a=n[r],c=t[a];for(;;){do r++;while(t[n[r]]<c);do s--;while(t[n[s]]>c);if(s<r)break;ee(n,r,s)}n[e+1]=n[s],n[s]=a,i-r+1>=s-e?(Gt(n,t,r,i),Gt(n,t,e,s-1)):(Gt(n,t,e,s-1),Gt(n,t,r,i))}}function ee(n,t,e){const i=n[t];n[t]=n[e],n[e]=i}function or(n){return n[0]}function sr(n){return n[1]}class ar{bs;width;constructor(t,e){this.width=t,this.bs=e}add(t){const e=Math.floor(t/this.width),i=t%this.width;return this.bs[e]|=1<<i,this}delete(t){const e=Math.floor(t/this.width),i=t%this.width;return this.bs[e]&=~(1<<i),this}set(t,e){const i=Math.floor(t/this.width),r=1<<t%this.width;return this.bs[i]^=(-Number(e)^this.bs[i])&r,e}has(t){const e=Math.floor(t/this.width),i=t%this.width;return(this.bs[e]&1<<i)!==0}forEach(t){const e=this.bs.length;for(let i=0;i<e;i++){let o=0;for(;this.bs[i]&&o<this.width;)this.bs[i]&1<<o&&t(i*this.width+o),o++}return this}}class An extends ar{constructor(t){super(8,new Uint8Array(Math.ceil(t/8)).fill(0))}}function qt(n){return n%3===2?n-2:n+1}function Ot(n){return n%3===0?n+2:n-1}function Pn(n,t,e,i,o,r,s,a){const c=St(n,t,o,r,s,a),f=St(e,i,o,r,s,a);if(c>0&&f>0||c<0&&f<0)return!1;const l=St(o,r,n,t,e,i),h=St(s,a,n,t,e,i);return l>0&&h>0||l<0&&h<0?!1:c===0&&f===0&&l===0&&h===0?!(Math.max(o,s)<Math.min(n,e)||Math.max(n,e)<Math.min(o,s)||Math.max(r,a)<Math.min(t,i)||Math.max(t,i)<Math.min(r,a)):!0}class cr{del;constructor(t){this.del=t}}class fr extends cr{vertMap;flips;consd;constructor(t,e){if(!t||typeof t!="object"||!t.triangles||!t.halfedges||!t.coords)throw new Error("Expected an object with Delaunator output");if(t.triangles.length%3||t.halfedges.length!==t.triangles.length||t.coords.length%2)throw new Error("Delaunator output appears inconsistent");if(t.triangles.length<3)throw new Error("No edges in triangulation");super(t);const i=2**32-1,o=t.coords.length>>1,r=t.triangles.length;this.vertMap=new Uint32Array(o).fill(i),this.flips=new An(r),this.consd=new An(r);for(let s=0;s<r;s++){const a=t.triangles[s];this.vertMap[a]===i&&this.updateVert(s)}e&&this.constrainAll(e)}constrainOne(t,e){const{triangles:i,halfedges:o}=this.del,r=this.vertMap[t];let s=r;do{const f=i[s],l=qt(s);if(f===e)return this.protect(s);const h=Ot(s),u=i[h];if(u===e)return this.protect(l),l;if(this.intersectSegments(t,e,u,f)){s=h;break}s=o[l]}while(s!==-1&&s!==r);let a=s,c=-1;for(;s!==-1;){const f=o[s],l=Ot(s),h=Ot(f),u=qt(f);if(f===-1)throw new Error("Constraining edge exited the hull");if(this.consd.has(s))throw new Error("Edge intersects already constrained edge");if(this.isCollinear(t,e,i[s])||this.isCollinear(t,e,i[f]))throw new Error("Constraining edge intersects point");if(!this.intersectSegments(i[s],i[f],i[l],i[h])){if(c===-1&&(c=s),i[h]===e){if(s===c)throw new Error("Infinite loop: non-convex quadrilateral");s=c,c=-1;continue}if(this.intersectSegments(t,e,i[h],i[f]))s=h;else if(this.intersectSegments(t,e,i[u],i[h]))s=u;else if(c===s)throw new Error("Infinite loop: no further intersect after non-convex");continue}if(this.flipDiagonal(s),this.intersectSegments(t,e,i[l],i[h])&&(c===-1&&(c=l),c===l))throw new Error("Infinite loop: flipped diagonal still intersects");i[h]===e?(a=h,s=c,c=-1):this.intersectSegments(t,e,i[u],i[h])&&(s=u)}return this.protect(a),this.delaunify(!0),this.findEdge(t,e)}delaunify(t=!1){const{halfedges:e}=this.del,i=this.flips,o=this.consd,r=e.length;let s;do{s=0;for(let a=0;a<r;a++){if(o.has(a))continue;i.delete(a);const c=e[a];c!==-1&&(i.delete(c),this.isDelaunay(a)||(this.flipDiagonal(a),s++))}}while(t&&s>0);return this}constrainAll(t){const e=t.length;for(let i=0;i<e;i++){const o=t[i];this.constrainOne(o[0],o[1])}return this}isConstrained(t){return this.consd.has(t)}findEdge(t,e){const i=this.vertMap[e],{triangles:o,halfedges:r}=this.del;let s=i,a=-1;do{if(o[s]===t)return s;a=qt(s),s=r[a]}while(s!==-1&&s!==i);return o[qt(a)]===t?-a:1/0}protect(t){const e=this.del.halfedges[t],i=this.flips,o=this.consd;return i.delete(t),o.add(t),e!==-1?(i.delete(e),o.add(e),e):-t}markFlip(t){const e=this.del.halfedges,i=this.flips;if(this.consd.has(t))return!1;const r=e[t];return r!==-1&&(i.add(t),i.add(r)),!0}flipDiagonal(t){const{triangles:e,halfedges:i}=this.del,o=this.flips,r=this.consd,s=i[t],a=Ot(t),c=qt(t),f=Ot(s),l=qt(s),h=i[a],u=i[f];if(r.has(t))throw new Error("Trying to flip a constrained edge");return e[t]=e[f],i[t]=u,o.set(t,o.has(f))||r.set(t,r.has(f)),u!==-1&&(i[u]=t),i[a]=f,e[s]=e[a],i[s]=h,o.set(s,o.has(a))||r.set(s,r.has(a)),h!==-1&&(i[h]=s),i[f]=a,this.markFlip(t),this.markFlip(c),this.markFlip(s),this.markFlip(l),o.add(a),r.delete(a),o.add(f),r.delete(f),this.updateVert(t),this.updateVert(c),this.updateVert(s),this.updateVert(l),a}isCollinear(t,e,i){const o=this.del.coords;return St(o[t*2],o[t*2+1],o[e*2],o[e*2+1],o[i*2],o[i*2+1])===0}inCircle(t,e,i,o){const r=this.del.coords;return ni(r[t*2],r[t*2+1],r[e*2],r[e*2+1],r[i*2],r[i*2+1],r[o*2],r[o*2+1])<0}isDelaunay(t){const{triangles:e,halfedges:i}=this.del,o=i[t];if(o===-1)return!0;const r=e[Ot(t)],s=e[t],a=e[qt(t)],c=e[Ot(o)];return!this.inCircle(r,s,a,c)}updateVert(t){const{triangles:e,halfedges:i}=this.del,o=this.vertMap,r=e[t];let s=Ot(t),a=i[s];for(;a!==-1&&a!==t;)s=Ot(a),a=i[s];return o[r]=s,s}intersectSegments(t,e,i,o){const r=this.del.coords;return t===i||t===o||e===i||e===o?!1:Pn(r[t*2],r[t*2+1],r[e*2],r[e*2+1],r[i*2],r[i*2+1],r[o*2],r[o*2+1])}static intersectSegments=Pn}function ne(n,t,e){if(t||(t=[]),typeof n!="object"||n.type!=="FeatureCollection")throw"Argument points must be FeatureCollection";if(!Array.isArray(t))throw"Argument points must be Array of Array";const i=n.features.map(c=>c.geometry.coordinates),o=Fe.from(i);let r;const s=[];o.triangles.length!==0&&t.length!==0&&(r=new fr(o),r.constrainAll(t));for(let c=0;c<o.triangles.length;c+=3)s.push([o.triangles[c],o.triangles[c+1],o.triangles[c+2]]);const a=["a","b","c"];return _t(s.map(c=>{const f={},l=c.map((h,u)=>{const p=n.features[h],x=p.geometry.coordinates,y=[x[0],x[1]];return x.length===3?y[2]=x[2]:f[a[u]]=p.properties[e],y});return l[3]=l[0],Jt([l],f)}))}function hr(n,t){const e=[[],[],[],[]],i=[];return Object.keys(n).forEach(o=>{const r=n[o],s=r.forw,a=r.bakw,c=[s[0]-t.forw[0],s[1]-t.forw[1]],f=[a[0]-t.bakw[0],t.bakw[1]-a[1]],l={forw:c,bakw:f};if(i.push(l),c[0]===0||c[1]===0)return;let h=0;c[0]>0&&(h+=1),c[1]>0&&(h+=2),e[h].push(l)}),{perQuad:e,aggregate:i}}function lr(n){let t=1/0,e=0,i=0;return n.forEach(o=>{const{forw:r,bakw:s}=o,a=Math.hypot(r[0],r[1]),c=Math.hypot(s[0],s[1]);if(c===0)return;const f=a/c,l=Math.atan2(r[0],r[1])-Math.atan2(s[0],s[1]);t=Math.min(t,f),e+=Math.cos(l),i+=Math.sin(l)}),isFinite(t)?[t,Math.atan2(i,e)]:[1,0]}function ur(n,t,e){const{perQuad:i,aggregate:o}=hr(n,t),r=i.every(c=>c.length>0),a=(e==="birdeye"?r?i:[o]:[o]).map(c=>lr(c));return a.length===1?[a[0],a[0],a[0],a[0]]:a}function dr(n,t){let e=0;return n[0]>t[0]&&(e+=1),n[1]>t[1]&&(e+=2),e}function pr(n,t,e){const i=[n[0]-t.forw[0],n[1]-t.forw[1]],r=Math.sqrt(i[0]**2+i[1]**2)/e[0],s=Math.atan2(i[0],i[1])-e[1];return[t.bakw[0]+r*Math.sin(s),t.bakw[1]-r*Math.cos(s)]}function gr(n,t,e,i){const o=t[0]-n[0],r=t[1]-n[1];if(Math.abs(o)<1e-12&&Math.abs(r)<1e-12)return null;const s=i[0]-e[0],a=i[1]-e[1],c=e[0]-n[0],f=e[1]-n[1],l=o*a-r*s;if(Math.abs(l)<1e-12)return null;const h=(c*a-f*s)/l,u=(c*r-f*o)/l;return h<=1e-10||u<-1e-10||u>1+1e-10?null:{t:h,point:[n[0]+h*o,n[1]+h*r]}}function mr(n,t,e){const i=e.length;let o=-1/0,r=null;for(let s=0;s<i;s++){const a=(s+1)%i,c=gr(n,t,e[s].bakw,e[a].bakw);c&&c.t>o&&(o=c.t,r=c.point)}return r}function In(n,t){const i=Math.atan2(n[0]-t[0],n[1]-t[1])*(180/Math.PI);return i<0?i+360:i}function Bn(n,t,e,i,o,r){const s=t[0]-n[0],a=t[1]-n[1];if(s===0&&a===0)return null;const c=[];if(s!==0)for(const l of[e,i]){const h=(l-n[0])/s;if(h>0){const u=n[1]+h*a;u>=o&&u<=r&&c.push({t:h,x:l,y:u})}}if(a!==0)for(const l of[o,r]){const h=(l-n[1])/a;if(h>0){const u=n[0]+h*s;u>=e&&u<=i&&c.push({t:h,x:u,y:l})}}if(c.length===0)return null;c.sort((l,h)=>l.t-h.t);const f=c[0];return[f.x,f.y]}function On(n,t,e){const i=n.length,o=new Array(i).fill(1);for(const r of t)for(let s=0;s<i;s++){const a=(s+1)%i,c=We([n[s].bakw,n[a].bakw]),f=We([e.bakw,r.bakw]),l=di(c,f);if(l.features.length>0&&l.features[0].geometry){const h=l.features[0],u=Math.sqrt(Math.pow(r.bakw[0]-e.bakw[0],2)+Math.pow(r.bakw[1]-e.bakw[1],2)),p=Math.sqrt(Math.pow(h.geometry.coordinates[0]-e.bakw[0],2)+Math.pow(h.geometry.coordinates[1]-e.bakw[1],2)),x=u/p;x>o[s]&&(o[s]=x),x>o[a]&&(o[a]=x)}}n.forEach((r,s)=>{const a=o[s];r.bakw=[(r.bakw[0]-e.bakw[0])*a+e.bakw[0],(r.bakw[1]-e.bakw[1])*a+e.bakw[1]]})}function Tn(n,t,e){const{convexBuf:i,centroid:o,allGcps:r,minx:s,maxx:a,miny:c,maxy:f}=n,l=ur(i,o,t),u=[[s,c],[a,c],[a,f],[s,f]].map(m=>({forw:m,bakw:pr(m,o,l[dr(m,o.forw)])}));if(u.sort((m,A)=>Math.atan2(m.forw[0]-o.forw[0],m.forw[1]-o.forw[1])-Math.atan2(A.forw[0]-o.forw[0],A.forw[1]-o.forw[1])),On(u,r,o),!e)return u;const p=4,x=u.map(m=>Math.atan2(m.forw[0]-o.forw[0],m.forw[1]-o.forw[1])),y=u.map(m=>Math.atan2(m.bakw[0]-o.bakw[0],-(m.bakw[1]-o.bakw[1])));function k(m){for(let A=0;A<p;A++){const B=(A+1)%p,P=x[A],I=A<p-1?x[B]:x[B]+2*Math.PI;let N=m;for(;N<P;)N+=2*Math.PI;for(;N>=P+2*Math.PI;)N-=2*Math.PI;if(N>=P&&N<I)return{i:A,j:B,frac:(N-P)/(I-P)}}return{i:0,j:1,frac:0}}function S(m){const{i:A,j:B,frac:P}=k(m),I=y[A];let X=y[B]-I;for(;X>Math.PI;)X-=2*Math.PI;for(;X<-Math.PI;)X+=2*Math.PI;return I+P*X}const g=new Set(u.map(m=>Math.floor(In(m.forw,o.forw)/10)%36)),v=r.map(m=>({forw:m.forw,bakw:m.bakw,angleDeg:In(m.forw,o.forw),forwDist:Math.hypot(m.forw[0]-o.forw[0],m.forw[1]-o.forw[1])})),d=[];for(let m=0;m<36;m++){if(g.has(m))continue;const A=m*10,B=v.filter(E=>E.angleDeg>=A&&E.angleDeg<A+10);let P=null;if(B.length>0){const E=B.reduce((M,T)=>T.forwDist>M.forwDist?T:M);P=Bn(o.forw,E.forw,s,a,c,f)}if(!P){const E=(A+5)%360*(Math.PI/180),M=[o.forw[0]+Math.sin(E),o.forw[1]+Math.cos(E)];P=Bn(o.forw,M,s,a,c,f)}if(!P)continue;const I=[P[0]-o.forw[0],P[1]-o.forw[1]],N=Math.atan2(I[0],I[1]),X=S(N),F=[o.bakw[0]+Math.sin(X),o.bakw[1]-Math.cos(X)],w=mr(o.bakw,F,u);w&&d.push({forw:P,bakw:w})}const b=[...u,...d];return b.sort((m,A)=>Math.atan2(m.forw[0]-o.forw[0],m.forw[1]-o.forw[1])-Math.atan2(A.forw[0]-o.forw[0],A.forw[1]-o.forw[1])),On(b,r,o),b}function wr(n,t=!1){return Tn(n,"plain",t)}function yr(n,t=!1){return Tn(n,"birdeye",t)}function Nn(n){const e=new vr(n).findSegmentIntersections(),i=Fn(e),o=new Map;return i.forEach(r=>{o.set(`${r.x}:${r.y}`,r)}),Array.from(o.values()).map(r=>Nt([r.x,r.y]))}class vr{_xx;_yy;_ii;_nn;_zz=null;_zlimit=0;_bb=null;_allBounds=null;_arcIter=null;_filteredArcIter=null;buf;constructor(t){this.initArcs(t)}initArcs(t){const e=[],i=[],o=t.map(r=>{const s=r?r.length:0;for(let a=0;a<s;a++)e.push(r[a][0]),i.push(r[a][1]);return s});this.initXYData(o,e,i)}initXYData(t,e,i){const o=t.length;this._xx=new Float64Array(e),this._yy=new Float64Array(i),this._nn=new Uint32Array(t),this._zz=null,this._zlimit=0,this._filteredArcIter=null,this._ii=new Uint32Array(o);let r=0;for(let s=0;s<o;s++)this._ii[s]=r,r+=t[s];(r!=this._xx.length||this._xx.length!=this._yy.length)&&je("ArcCollection#initXYData() Counting error"),this.initBounds(),this._arcIter=new Fr(this._xx,this._yy)}initBounds(){const t=this.calcArcBounds_(this._xx,this._yy,this._nn);this._bb=t.bb,this._allBounds=t.bounds}calcArcBounds_(t,e,i){const o=i.length,r=new Float64Array(o*4),s=new re;let a=0,c,f,l;for(let h=0;h<o;h++)c=i[h],c>0&&(f=h*4,l=Lr(t,e,a,c),r[f++]=l[0],r[f++]=l[1],r[f++]=l[2],r[f]=l[3],a+=c,s.mergeBounds(l));return{bb:r,bounds:s}}getBounds(){return this._allBounds?this._allBounds.clone():new re}forEachSegment(t){let e=0;for(let i=0,o=this.size();i<o;i++)e+=this.forEachArcSegment(i,t);return e}size(){return this._ii&&this._ii.length||0}forEachArcSegment(t,e){const i=t>=0,o=i?t:~t,r=this.getRetainedInterval(),s=this._nn[o],a=i?1:-1;let c=i?this._ii[o]:this._ii[o]+s-1,f=c,l=0;for(let h=1;h<s;h++)f+=a,(r===0||this._zz[f]>=r)&&(e(c,f,this._xx,this._yy),c=f,l++);return l}getRetainedInterval(){return this._zlimit}getVertexData(){return{xx:this._xx,yy:this._yy,zz:this._zz,bb:this._bb,nn:this._nn,ii:this._ii}}getUint32Array(t){const e=t*4;return(!this.buf||this.buf.byteLength<e)&&(this.buf=new ArrayBuffer(e)),new Uint32Array(this.buf,0,t)}getAvgSegment2(){let t=0,e=0;const i=this.forEachSegment((o,r,s,a)=>{t+=Math.abs(s[o]-s[r]),e+=Math.abs(a[o]-a[r])});return[t/i||0,e/i||0]}calcSegmentIntersectionStripeCount(){const t=this.getBounds().height(),e=this.getAvgSegment2()[1];let i=1;return e>0&&t>0&&(i=Math.ceil(t/e/20)),i||1}findSegmentIntersections(){const t=this.getBounds(),e=t.ymin||0,i=(t.ymax||0)-e,o=this.calcSegmentIntersectionStripeCount(),r=new Uint32Array(o),s=o>1?y=>Math.floor((o-1)*(y-e)/i):()=>0;let a,c;this.forEachSegment((y,k,S,g)=>{let v=s(g[y]);const d=s(g[k]);for(;r[v]=r[v]+2,v!=d;)v+=d>v?1:-1});const f=this.getUint32Array(_r(r));let l=0;const h=[];Mr(r,y=>{const k=l;l+=y,h.push(f.subarray(k,l))}),Sr(r,0),this.forEachSegment((y,k,S,g)=>{let v=s(g[y]);const d=s(g[k]);let b,m;for(;b=r[v],r[v]=b+2,m=h[v],m[b]=y,m[b+1]=k,v!=d;)v+=d>v?1:-1});const u=this.getVertexData(),p=[];let x;for(a=0;a<o;a++)if(u.xx&&u.yy)for(x=kr(h[a],u.xx,u.yy),c=0;c<x.length;c++)p.push(x[c]);return Fn(p)}}function je(...n){const t=n.join(" ");throw new Error(t)}function $e(n){return n?xr(n)?!0:br(n)?!1:n.length===0?!0:n.length>0:!1}function br(n){return n!=null&&n.toString===String.prototype.toString}function xr(n){return Array.isArray(n)}function _r(n,t){$e(n)||je("utils.sum() expects an array, received:",n);let e=0,i;for(let o=0,r=n.length;o<r;o++)i=n[o],i&&(e+=i);return e}function Mr(n,t,e){if(!$e(n))throw new Error(`#forEach() takes an array-like argument. ${n}`);for(let i=0,o=n.length;i<o;i++)t.call(e,n[i],i)}function Sr(n,t){for(let e=0,i=n.length;e<i;e++)n[e]=t;return n}function kr(n,t,e){const i=n.length-2,o=[];let r,s,a,c,f,l,h,u,p,x,y,k,S,g,v,d,b;for(Xr(t,n),d=0;d<i;){for(r=n[d],s=n[d+1],f=t[r],l=t[s],p=e[r],x=e[s],b=d;b<i&&(b+=2,a=n[b],h=t[a],!(l<h));){if(y=e[a],c=n[b+1],u=t[c],k=e[c],p>=y){if(p>k&&x>y&&x>k)continue}else if(p<k&&x<y&&x<k)continue;r==a||r==c||s==a||s==c||(S=Er(f,p,l,x,h,y,u,k),S&&(g=[r,s],v=[a,c],o.push(Rn(S,g,v,t,e)),S.length==4&&o.push(Rn(S.slice(2),g,v,t,e))))}d+=2}return o}function Er(n,t,e,i,o,r,s,a){const c=Ar(n,t,e,i,o,r,s,a);let f=null;return c&&(f=Pr(n,t,e,i,o,r,s,a),f?Cr(n,t,e,i,o,r,s,a)&&(f=null):f=Nr(n,t,e,i,o,r,s,a)),f}function Ar(n,t,e,i,o,r,s,a){return ie(n,t,e,i,o,r)*ie(n,t,e,i,s,a)<=0&&ie(o,r,s,a,n,t)*ie(o,r,s,a,e,i)<=0}function ie(n,t,e,i,o,r){return Cn(n-o,t-r,e-o,i-r)}function Cn(n,t,e,i){return n*i-t*e}function Pr(n,t,e,i,o,r,s,a){let c=ye(n,t,e,i,o,r,s,a),f;return c&&(f=Br(c[0],c[1],n,t,e,i,o,r,s,a),f==1?c=ye(e,i,n,t,o,r,s,a):f==2?c=ye(o,r,s,a,n,t,e,i):f==3&&(c=ye(s,a,o,r,n,t,e,i))),c&&Tr(c,n,t,e,i,o,r,s,a),c}function ye(n,t,e,i,o,r,s,a){const c=Cn(e-n,i-t,s-o,a-r),f=1e-18;let l;if(c===0)return null;const h=ie(o,r,s,a,n,t)/c;return c<=f&&c>=-f?l=Ir(n,t,e,i,o,r,s,a):l=[n+h*(e-n),t+h*(i-t)],l}function Ir(n,t,e,i,o,r,s,a){let c=null;return!Tt(n,o,s)&&!Tt(t,r,a)?c=[n,t]:!Tt(e,o,s)&&!Tt(i,r,a)?c=[e,i]:!Tt(o,n,e)&&!Tt(r,t,i)?c=[o,r]:!Tt(s,n,e)&&!Tt(a,t,i)&&(c=[s,a]),c}function Tt(n,t,e){let i;return t<e?i=n<t||n>e:t>e?i=n>t||n<e:i=n!=t,i}function Br(n,t,...e){let i=-1,o=1/0,r;for(let s=0,a=0,c=e.length;a<c;s++,a+=2)r=Or(n,t,e[a],e[a+1]),r<o&&(o=r,i=s);return i}function Or(n,t,e,i){const o=n-e,r=t-i;return o*o+r*r}function Tr(n,t,e,i,o,r,s,a,c){let f=n[0],l=n[1];f=ve(f,t,i),f=ve(f,r,a),l=ve(l,e,o),l=ve(l,s,c),n[0]=f,n[1]=l}function ve(n,t,e){let i;return Tt(n,t,e)&&(i=Math.abs(n-t)<Math.abs(n-e)?t:e,n=i),n}function Nr(n,t,e,i,o,r,s,a){const c=Math.min(n,e,o,s),f=Math.max(n,e,o,s),l=Math.min(t,i,r,a),h=Math.max(t,i,r,a),u=h-l>f-c;let p=[];return(u?Yt(t,l,h):Yt(n,c,f))&&p.push(n,t),(u?Yt(i,l,h):Yt(e,c,f))&&p.push(e,i),(u?Yt(r,l,h):Yt(o,c,f))&&p.push(o,r),(u?Yt(a,l,h):Yt(s,c,f))&&p.push(s,a),(p.length!=2&&p.length!=4||p.length==4&&p[0]==p[2]&&p[1]==p[3])&&(p=null),p}function Cr(n,t,e,i,o,r,s,a){return n==o&&t==r||n==s&&t==a||e==o&&i==r||e==s&&i==a}function Yt(n,t,e){return n>t&&n<e}function Xr(n,t){Dr(n,t),Xn(n,t,0,t.length-2)}function Dr(n,t){for(let e=0,i=t.length;e<i;e+=2)n[t[e]]>n[t[e+1]]&&Rr(t,e,e+1)}function Rr(n,t,e){const i=n[t];n[t]=n[e],n[e]=i}function Xn(n,t,e,i){let o=e,r=i,s,a;for(;o<i;){for(s=n[t[e+i>>2<<1]];o<=r;){for(;n[t[o]]<s;)o+=2;for(;n[t[r]]>s;)r-=2;o<=r&&(a=t[o],t[o]=t[r],t[r]=a,a=t[o+1],t[o+1]=t[r+1],t[r+1]=a,o+=2,r-=2)}if(r-e<40?Dn(n,t,e,r):Xn(n,t,e,r),i-o<40){Dn(n,t,o,i);return}e=o,r=i}}function Dn(n,t,e,i){let o,r;for(let s=e+2;s<=i;s+=2){o=t[s],r=t[s+1];let a;for(a=s-2;a>=e&&n[o]<n[t[a]];a-=2)t[a+2]=t[a],t[a+3]=t[a+1];t[a+2]=o,t[a+3]=r}}function Rn(n,t,e,i,o){const r=n[0],s=n[1];t=Yn(r,s,t[0],t[1],i,o),e=Yn(r,s,e[0],e[1],i,o);const a=t[0]<e[0]?t:e,c=a==t?e:t;return{x:r,y:s,a,b:c}}function Yn(n,t,e,i,o,r){let s=e<i?e:i,a=s===e?i:e;return o[s]==n&&r[s]==t?a=s:o[a]==n&&r[a]==t&&(s=a),[s,a]}function Fn(n){const t={};return n.filter(e=>{const i=Yr(e);return i in t?!1:(t[i]=!0,!0)})}function Yr(n){return`${n.a.join(",")};${n.b.join(",")}`}class Fr{_i=0;_n=0;_inc=1;_xx;_yy;i=0;x=0;y=0;constructor(t,e){this._xx=t,this._yy=e}}function Lr(n,t,e,i){let o=e|0;const r=isNaN(i)?n.length-o:i+o;let s,a,c,f,l,h;if(r>0)c=l=n[o],f=h=t[o];else return[void 0,void 0,void 0,void 0];for(o++;o<r;o++)s=n[o],a=t[o],s<c&&(c=s),s>l&&(l=s),a<f&&(f=a),a>h&&(h=a);return[c,f,l,h]}class re{xmin;ymin;xmax;ymax;constructor(...t){t.length>0&&this.setBounds(t)}cloneBounds(){return this.clone()}clone(){return new re(this.xmin,this.ymin,this.xmax,this.ymax)}width(){return this.xmax-this.xmin||0}height(){return this.ymax-this.ymin||0}setBounds(t,e,i,o){let r,s,a,c;if(arguments.length==1)if($e(t)){const f=t;r=f[0],s=f[1],a=f[2],c=f[3]}else{const f=t;r=f.xmin,s=f.ymin,a=f.xmax,c=f.ymax}else r=t,s=e,a=i,c=o;return this.xmin=r,this.ymin=s,this.xmax=a,this.ymax=c,(r>a||s>c)&&this.update(),this}update(){let t;this.xmin>this.xmax&&(t=this.xmin,this.xmin=this.xmax,this.xmax=t),this.ymin>this.ymax&&(t=this.ymin,this.ymin=this.ymax,this.ymax=t)}mergeBounds(t,...e){let i,o,r,s;return t instanceof re?(i=t.xmin,o=t.ymin,r=t.xmax,s=t.ymax):e.length==3?(i=t,o=e[0],r=e[1],s=e[2]):t.length==4?(i=t[0],o=t[1],r=t[2],s=t[3]):je("Bounds#mergeBounds() invalid argument:",t),this.xmin===void 0?this.setBounds(i,o,r,s):(i<this.xmin&&(this.xmin=i),o<this.ymin&&(this.ymin=o),r>this.xmax&&(this.xmax=r),s>this.ymax&&(this.ymax=s)),this}}function be(n){const t=["a","b","c"].map(e=>n.properties[e].index);return[[0,1],[0,2],[1,2],[0,1,2]].map(e=>e.map(i=>t[i]).sort().join("-")).sort()}function qe(n,t,e){const i=be(t.forw),o=be(t.bakw);if(JSON.stringify(i)!=JSON.stringify(o))throw`${JSON.stringify(t,null,2)}
|
|
1
|
+
(function(bt,Bt){typeof exports=="object"&&typeof module<"u"?Bt(exports):typeof define=="function"&&define.amd?define(["exports"],Bt):(bt=typeof globalThis<"u"?globalThis:bt||self,Bt(bt.tin={}))})(this,(function(bt){"use strict";function Bt(e,t,n={}){const i={type:"Feature"};return(n.id===0||n.id)&&(i.id=n.id),n.bbox&&(i.bbox=n.bbox),i.properties=t||{},i.geometry=e,i}function Dt(e,t,n={}){if(!e)throw new Error("coordinates is required");if(!Array.isArray(e))throw new Error("coordinates must be an Array");if(e.length<2)throw new Error("coordinates must be at least 2 numbers long");if(!tn(e[0])||!tn(e[1]))throw new Error("coordinates must contain numbers");return Bt({type:"Point",coordinates:e},t,n)}function Zt(e,t,n={}){for(const o of e){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(let r=0;r<o[o.length-1].length;r++)if(o[o.length-1][r]!==o[0][r])throw new Error("First and last Position are not equivalent.")}return Bt({type:"Polygon",coordinates:e},t,n)}function Ze(e,t,n={}){if(e.length<2)throw new Error("coordinates must be an array of two or more positions");return Bt({type:"LineString",coordinates:e},t,n)}function St(e,t={}){const n={type:"FeatureCollection"};return t.id&&(n.id=t.id),t.bbox&&(n.bbox=t.bbox),n.features=e,n}function tn(e){return!isNaN(e)&&e!==null&&!Array.isArray(e)}function ti(e){if(!e)throw new Error("coord is required");if(!Array.isArray(e)){if(e.type==="Feature"&&e.geometry!==null&&e.geometry.type==="Point")return[...e.geometry.coordinates];if(e.type==="Point")return[...e.coordinates]}if(Array.isArray(e)&&e.length>=2&&!Array.isArray(e[0])&&!Array.isArray(e[1]))return[...e];throw new Error("coord must be GeoJSON Point or an Array of numbers")}function ei(e){return e.type==="Feature"?e.geometry:e}function Ae(e,t,n){if(e!==null)for(var i,o,r,s,a,h,l,u=0,c=0,f,p=e.type,_=p==="FeatureCollection",g=p==="Feature",I=_?e.features.length:1,M=0;M<I;M++){l=_?e.features[M].geometry:g?e.geometry:e,f=l?l.type==="GeometryCollection":!1,a=f?l.geometries.length:1;for(var m=0;m<a;m++){var b=0,d=0;if(s=f?l.geometries[m]:l,s!==null){h=s.coordinates;var v=s.type;switch(u=n&&(v==="Polygon"||v==="MultiPolygon")?1:0,v){case null:break;case"Point":if(t(h,c,M,b,d)===!1)return!1;c++,b++;break;case"LineString":case"MultiPoint":for(i=0;i<h.length;i++){if(t(h[i],c,M,b,d)===!1)return!1;c++,v==="MultiPoint"&&b++}v==="LineString"&&b++;break;case"Polygon":case"MultiLineString":for(i=0;i<h.length;i++){for(o=0;o<h[i].length-u;o++){if(t(h[i][o],c,M,b,d)===!1)return!1;c++}v==="MultiLineString"&&b++,v==="Polygon"&&d++}v==="Polygon"&&b++;break;case"MultiPolygon":for(i=0;i<h.length;i++){for(d=0,o=0;o<h[i].length;o++){for(r=0;r<h[i][o].length-u;r++){if(t(h[i][o][r],c,M,b,d)===!1)return!1;c++}d++}b++}break;case"GeometryCollection":for(i=0;i<s.geometries.length;i++)if(Ae(s.geometries[i],t,n)===!1)return!1;break;default:throw new Error("Unknown Geometry Type")}}}}}const ut=11102230246251565e-32,U=134217729,en=(3+8*ut)*ut;function ht(e,t,n,i,o){let r,s,a,h,l=t[0],u=i[0],c=0,f=0;u>l==u>-l?(r=l,l=t[++c]):(r=u,u=i[++f]);let p=0;if(c<e&&f<n)for(u>l==u>-l?(s=l+r,a=r-(s-l),l=t[++c]):(s=u+r,a=r-(s-u),u=i[++f]),r=s,a!==0&&(o[p++]=a);c<e&&f<n;)u>l==u>-l?(s=r+l,h=s-r,a=r-(s-h)+(l-h),l=t[++c]):(s=r+u,h=s-r,a=r-(s-h)+(u-h),u=i[++f]),r=s,a!==0&&(o[p++]=a);for(;c<e;)s=r+l,h=s-r,a=r-(s-h)+(l-h),l=t[++c],r=s,a!==0&&(o[p++]=a);for(;f<n;)s=r+u,h=s-r,a=r-(s-h)+(u-h),u=i[++f],r=s,a!==0&&(o[p++]=a);return(r!==0||p===0)&&(o[p++]=r),p}function Mt(e,t,n,i,o,r,s,a){return ht(ht(e,t,n,i,s),s,o,r,a)}function L(e,t,n,i){let o,r,s,a,h,l,u,c,f,p,_;u=U*n,p=u-(u-n),_=n-p;let g=t[0];o=g*n,u=U*g,c=u-(u-g),f=g-c,s=f*_-(o-c*p-f*p-c*_);let I=0;s!==0&&(i[I++]=s);for(let M=1;M<e;M++)g=t[M],a=g*n,u=U*g,c=u-(u-g),f=g-c,h=f*_-(a-c*p-f*p-c*_),r=o+h,l=r-o,s=o-(r-l)+(h-l),s!==0&&(i[I++]=s),o=a+r,s=r-(o-a),s!==0&&(i[I++]=s);return(o!==0||I===0)&&(i[I++]=o),I}function nn(e,t){let n=t[0];for(let i=1;i<e;i++)n+=t[i];return n}function tt(e){return new Float64Array(e)}const ni=(3+16*ut)*ut,ii=(2+12*ut)*ut,ri=(9+64*ut)*ut*ut,Gt=tt(4),rn=tt(8),on=tt(12),sn=tt(16),mt=tt(4);function oi(e,t,n,i,o,r,s){let a,h,l,u,c,f,p,_,g,I,M,m,b,d,v,w,A,S;const E=e-o,O=n-o,B=t-r,X=i-r;d=E*X,f=U*E,p=f-(f-E),_=E-p,f=U*X,g=f-(f-X),I=X-g,v=_*I-(d-p*g-_*g-p*I),w=B*O,f=U*B,p=f-(f-B),_=B-p,f=U*O,g=f-(f-O),I=O-g,A=_*I-(w-p*g-_*g-p*I),M=v-A,c=v-M,Gt[0]=v-(M+c)+(c-A),m=d+M,c=m-d,b=d-(m-c)+(M-c),M=b-w,c=b-M,Gt[1]=b-(M+c)+(c-w),S=m+M,c=S-m,Gt[2]=m-(S-c)+(M-c),Gt[3]=S;let F=nn(4,Gt),y=ii*s;if(F>=y||-F>=y||(c=e-E,a=e-(E+c)+(c-o),c=n-O,l=n-(O+c)+(c-o),c=t-B,h=t-(B+c)+(c-r),c=i-X,u=i-(X+c)+(c-r),a===0&&h===0&&l===0&&u===0)||(y=ri*s+en*Math.abs(F),F+=E*u+X*a-(B*l+O*h),F>=y||-F>=y))return F;d=a*X,f=U*a,p=f-(f-a),_=a-p,f=U*X,g=f-(f-X),I=X-g,v=_*I-(d-p*g-_*g-p*I),w=h*O,f=U*h,p=f-(f-h),_=h-p,f=U*O,g=f-(f-O),I=O-g,A=_*I-(w-p*g-_*g-p*I),M=v-A,c=v-M,mt[0]=v-(M+c)+(c-A),m=d+M,c=m-d,b=d-(m-c)+(M-c),M=b-w,c=b-M,mt[1]=b-(M+c)+(c-w),S=m+M,c=S-m,mt[2]=m-(S-c)+(M-c),mt[3]=S;const P=ht(4,Gt,4,mt,rn);d=E*u,f=U*E,p=f-(f-E),_=E-p,f=U*u,g=f-(f-u),I=u-g,v=_*I-(d-p*g-_*g-p*I),w=B*l,f=U*B,p=f-(f-B),_=B-p,f=U*l,g=f-(f-l),I=l-g,A=_*I-(w-p*g-_*g-p*I),M=v-A,c=v-M,mt[0]=v-(M+c)+(c-A),m=d+M,c=m-d,b=d-(m-c)+(M-c),M=b-w,c=b-M,mt[1]=b-(M+c)+(c-w),S=m+M,c=S-m,mt[2]=m-(S-c)+(M-c),mt[3]=S;const k=ht(P,rn,4,mt,on);d=a*u,f=U*a,p=f-(f-a),_=a-p,f=U*u,g=f-(f-u),I=u-g,v=_*I-(d-p*g-_*g-p*I),w=h*l,f=U*h,p=f-(f-h),_=h-p,f=U*l,g=f-(f-l),I=l-g,A=_*I-(w-p*g-_*g-p*I),M=v-A,c=v-M,mt[0]=v-(M+c)+(c-A),m=d+M,c=m-d,b=d-(m-c)+(M-c),M=b-w,c=b-M,mt[1]=b-(M+c)+(c-w),S=m+M,c=S-m,mt[2]=m-(S-c)+(M-c),mt[3]=S;const T=ht(k,on,4,mt,sn);return sn[T-1]}function Et(e,t,n,i,o,r){const s=(t-r)*(n-o),a=(e-o)*(i-r),h=s-a,l=Math.abs(s+a);return Math.abs(h)>=ni*l?h:-oi(e,t,n,i,o,r,l)}const si=(10+96*ut)*ut,ai=(4+48*ut)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,d=h*f,v=l*c,w=u*u+p*p,A=I*(_-g)+b*(M-m)+w*(d-v),S=(Math.abs(_)+Math.abs(g))*I+(Math.abs(M)+Math.abs(m))*b+(Math.abs(d)+Math.abs(v))*w,E=si*S;return A>E||-A>E?A:li(e,t,n,i,o,r,s,a,S)}function fi(e,t){var n,i,o=0,r,s,a,h,l,u,c,f=e[0],p=e[1],_=t.length;for(n=0;n<_;n++){i=0;var g=t[n],I=g.length-1;if(u=g[0],u[0]!==g[I][0]&&u[1]!==g[I][1])throw new Error("First and last coordinates in a ring must be the same");for(s=u[0]-f,a=u[1]-p,i;i<I;i++){if(c=g[i+1],h=c[0]-f,l=c[1]-p,a===0&&l===0){if(h<=0&&s>=0||s<=0&&h>=0)return 0}else if(l>=0&&a<=0||l<=0&&a>=0){if(r=Et(s,h,a,l,0,0),r===0)return 0;(r>0&&l>0&&a<=0||r<0&&l<=0&&a>0)&&o++}u=c,a=l,s=h}}return o%2!==0}function Ce(e,t,n={}){if(!e)throw new Error("point is required");if(!t)throw new Error("polygon is required");const i=ti(e),o=ei(t),r=o.type,s=t.bbox;let a=o.coordinates;if(s&&ui(i,s)===!1)return!1;r==="Polygon"&&(a=[a]);for(var h=0;h<a.length;++h){const l=fi(i,a[h]);if(l===0&&!n.ignoreBoundary)return!0;if(l)return!0}return!1}function ui(e,t){return t[0]<=e[0]&&t[1]<=e[1]&&t[2]>=e[0]&&t[3]>=e[1]}class De{constructor(t=[],n=di){if(this.data=t,this.length=this.data.length,this.compare=n,this.length>0)for(let i=(this.length>>1)-1;i>=0;i--)this._down(i)}push(t){this.data.push(t),this.length++,this._up(this.length-1)}pop(){if(this.length===0)return;const t=this.data[0],n=this.data.pop();return this.length--,this.length>0&&(this.data[0]=n,this._down(0)),t}peek(){return this.data[0]}_up(t){const{data:n,compare:i}=this,o=n[t];for(;t>0;){const r=t-1>>1,s=n[r];if(i(o,s)>=0)break;n[t]=s,t=r}n[t]=o}_down(t){const{data:n,compare:i}=this,o=this.length>>1,r=n[t];for(;t<o;){let s=(t<<1)+1,a=n[s];const h=s+1;if(h<this.length&&i(n[h],a)<0&&(s=h,a=n[h]),i(a,r)>=0)break;n[t]=a,t=s}n[t]=r}}function di(e,t){return e<t?-1:e>t?1:0}const pi=Object.freeze(Object.defineProperty({__proto__:null,default:De},Symbol.toStringTag,{value:"Module"})),Nt=11102230246251565e-32,dt=134217729,mi=(3+8*Nt)*Nt;function Ye(e,t,n,i,o){let r,s,a,h,l=t[0],u=i[0],c=0,f=0;u>l==u>-l?(r=l,l=t[++c]):(r=u,u=i[++f]);let p=0;if(c<e&&f<n)for(u>l==u>-l?(s=l+r,a=r-(s-l),l=t[++c]):(s=u+r,a=r-(s-u),u=i[++f]),r=s,a!==0&&(o[p++]=a);c<e&&f<n;)u>l==u>-l?(s=r+l,h=s-r,a=r-(s-h)+(l-h),l=t[++c]):(s=r+u,h=s-r,a=r-(s-h)+(u-h),u=i[++f]),r=s,a!==0&&(o[p++]=a);for(;c<e;)s=r+l,h=s-r,a=r-(s-h)+(l-h),l=t[++c],r=s,a!==0&&(o[p++]=a);for(;f<n;)s=r+u,h=s-r,a=r-(s-h)+(u-h),u=i[++f],r=s,a!==0&&(o[p++]=a);return(r!==0||p===0)&&(o[p++]=r),p}function gi(e,t){let n=t[0];for(let i=1;i<e;i++)n+=t[i];return n}function te(e){return new Float64Array(e)}const wi=(3+16*Nt)*Nt,yi=(2+12*Nt)*Nt,vi=(9+64*Nt)*Nt*Nt,Kt=te(4),an=te(8),cn=te(12),ln=te(16),yt=te(4);function bi(e,t,n,i,o,r,s){let a,h,l,u,c,f,p,_,g,I,M,m,b,d,v,w,A,S;const E=e-o,O=n-o,B=t-r,X=i-r;d=E*X,f=dt*E,p=f-(f-E),_=E-p,f=dt*X,g=f-(f-X),I=X-g,v=_*I-(d-p*g-_*g-p*I),w=B*O,f=dt*B,p=f-(f-B),_=B-p,f=dt*O,g=f-(f-O),I=O-g,A=_*I-(w-p*g-_*g-p*I),M=v-A,c=v-M,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g-p*I),M=v-A,c=v-M,yt[0]=v-(M+c)+(c-A),m=d+M,c=m-d,b=d-(m-c)+(M-c),M=b-w,c=b-M,yt[1]=b-(M+c)+(c-w),S=m+M,c=S-m,yt[2]=m-(S-c)+(M-c),yt[3]=S;const T=Ye(k,cn,4,yt,ln);return ln[T-1]}function hn(e,t,n,i,o,r){const s=(t-r)*(n-o),a=(e-o)*(i-r),h=s-a;if(s===0||a===0||s>0!=a>0)return h;const l=Math.abs(s+a);return Math.abs(h)>=wi*l?h:-bi(e,t,n,i,o,r,l)}function xi(e,t){const n=new De([],fn);return Mi(e,n),Si(n,t)}function fn(e,t){return e.p.x>t.p.x?1:e.p.x<t.p.x||e.p.x===t.p.x&&(e.featureId!==t.featureId||e.ringId!==t.ringId)&&e.isLeftEndpoint&&!t.isLeftEndpoint?-1:e.p.y!==t.p.y?e.p.y>t.p.y?1:-1:1}function _i(e,t){return e.rightSweepEvent.p.x>t.rightSweepEvent.p.x?1:e.rightSweepEvent.p.x<t.rightSweepEvent.p.x?-1:e.rightSweepEvent.p.y!==t.rightSweepEvent.p.y?e.rightSweepEvent.p.y<t.rightSweepEvent.p.y?1:-1:1}function Mi(e,t){if(e.type==="FeatureCollection"){const n=e.features;for(let i=0;i<n.length;i++)un(n[i],t)}else un(e,t)}var we=0,ye=0,ve=0;function un(e,t){const n=e.type==="Feature"?e.geometry:e;let i=n.coordinates;(n.type==="Polygon"||n.type==="MultiLineString")&&(i=[i]),n.type==="LineString"&&(i=[[i]]);for(let o=0;o<i.length;o++)for(let r=0;r<i[o].length;r++){let s=i[o][r][0],a=null;ye=ye+1;for(let h=0;h<i[o][r].length-1;h++){a=i[o][r][h+1];const l=new dn(s,we,ye,ve),u=new dn(a,we,ye,ve+1);l.otherEvent=u,u.otherEvent=l,fn(l,u)>0?(u.isLeftEndpoint=!0,l.isLeftEndpoint=!1):(l.isLeftEndpoint=!0,u.isLeftEndpoint=!1),t.push(l),t.push(u),s=a,ve=ve+1}}we=we+1}var dn=class{constructor(e,t,n,i){this.p={x:e[0],y:e[1]},this.featureId=t,this.ringId=n,this.eventId=i,this.otherEvent=null,this.isLeftEndpoint=null}isSamePoint(e){return this.p.x===e.p.x&&this.p.y===e.p.y}asNewXY(){return[this.p.x,this.p.y]}};function Si(e,t=!1){const n=[],i=new De([],_i);for(;e.length;){const o=e.pop();if(o.isLeftEndpoint){const r=new ki(o);for(let s=0;s<i.data.length;s++){const a=i.data[s];if(t&&a.leftSweepEvent.featureId===o.featureId)continue;const h=Ei(r,a);h!==!1&&n.push(h)}i.push(r)}else o.isLeftEndpoint===!1&&i.pop()}return n}var ki=class{constructor(e){this.leftSweepEvent=e,this.rightSweepEvent=e.otherEvent}};function Ei(e,t){if(e===null||t===null)return!1;const n=e.leftSweepEvent.p.x,i=e.leftSweepEvent.p.y,o=e.rightSweepEvent.p.x,r=e.rightSweepEvent.p.y,s=t.leftSweepEvent.p.x,a=t.leftSweepEvent.p.y,h=t.rightSweepEvent.p.x,l=t.rightSweepEvent.p.y,u=hn(n,i,o,r,s,a),c=hn(n,i,o,r,h,l);if(u>0&&c>0)return!1;if(u<0&&c<0)return!1;if(e.leftSweepEvent.ringId===t.leftSweepEvent.ringId){if(e.rightSweepEvent.isSamePoint(t.leftSweepEvent)||e.rightSweepEvent.isSamePoint(t.rightSweepEvent)||e.leftSweepEvent.isSamePoint(t.leftSweepEvent)||e.leftSweepEvent.isSamePoint(t.rightSweepEvent))return!1}else{if(e.rightSweepEvent.isSamePoint(t.leftSweepEvent))return t.leftSweepEvent.asNewXY();if(e.rightSweepEvent.isSamePoint(t.rightSweepEvent))return t.rightSweepEvent.asNewXY();if(e.leftSweepEvent.isSamePoint(t.leftSweepEvent))return t.leftSweepEvent.asNewXY();if(e.leftSweepEvent.isSamePoint(t.rightSweepEvent))return t.rightSweepEvent.asNewXY()}const f=(l-a)*(o-n)-(h-s)*(r-i),p=(h-s)*(i-a)-(l-a)*(n-s),_=(o-n)*(i-a)-(r-i)*(n-s);if(f===0)return!1;const g=p/f,I=_/f;if(g>=0&&g<=1&&I>=0&&I<=1){const M=n+g*(o-n),m=i+g*(r-i);return[M,m]}return!1}function Ai(e,t,n={}){const{removeDuplicates:i=!0,ignoreSelfIntersections:o=!0}=n;let r=[];e.type==="FeatureCollection"?r=r.concat(e.features):e.type==="Feature"?r.push(e):(e.type==="LineString"||e.type==="Polygon"||e.type==="MultiLineString"||e.type==="MultiPolygon")&&r.push(Bt(e)),t.type==="FeatureCollection"?r=r.concat(t.features):t.type==="Feature"?r.push(t):(t.type==="LineString"||t.type==="Polygon"||t.type==="MultiLineString"||t.type==="MultiPolygon")&&r.push(Bt(t));const s=xi(St(r),o);let a=[];if(i){const h={};s.forEach(l=>{const u=l.join(",");h[u]||(h[u]=!0,a.push(l))})}else a=s;return St(a.map(h=>Dt(h)))}function Ii(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function Pi(e){if(Object.prototype.hasOwnProperty.call(e,"__esModule"))return e;var t=e.default;if(typeof t=="function"){var n=function i(){var o=!1;try{o=this instanceof i}catch{}return o?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};n.prototype=t.prototype}else n={};return Object.defineProperty(n,"__esModule",{value:!0}),Object.keys(e).forEach(function(i){var o=Object.getOwnPropertyDescriptor(e,i);Object.defineProperty(n,i,o.get?o:{enumerable:!0,get:function(){return e[i]}})}),n}function Oi(e,t={}){let n=0,i=0,o=0;return Ae(e,function(r){n+=r[0],i+=r[1],o++},!0),Dt([n/o,i/o],t.properties)}var be={exports:{}},xe={exports:{}},Bi=xe.exports,pn;function Ni(){return pn||(pn=1,(function(e,t){(function(n,i){e.exports=i()})(Bi,function(){function n(m,b,d,v,w){(function A(S,E,O,B,X){for(;B>O;){if(B-O>600){var F=B-O+1,y=E-O+1,P=Math.log(F),k=.5*Math.exp(2*P/3),T=.5*Math.sqrt(P*k*(F-k)/F)*(y-F/2<0?-1:1),C=Math.max(O,Math.floor(E-y*k/F+T)),Y=Math.min(B,Math.floor(E+(F-y)*k/F+T));A(S,E,C,Y,X)}var x=S[E],N=O,D=B;for(i(S,O,E),X(S[B],x)>0&&i(S,O,B);N<D;){for(i(S,N,D),N++,D--;X(S[N],x)<0;)N++;for(;X(S[D],x)>0;)D--}X(S[O],x)===0?i(S,O,D):i(S,++D,B),D<=E&&(O=D+1),E<=D&&(B=D-1)}})(m,b,d||0,v||m.length-1,w||o)}function i(m,b,d){var v=m[b];m[b]=m[d],m[d]=v}function o(m,b){return m<b?-1:m>b?1:0}var r=function(m){m===void 0&&(m=9),this._maxEntries=Math.max(4,m),this._minEntries=Math.max(2,Math.ceil(.4*this._maxEntries)),this.clear()};function s(m,b,d){if(!d)return b.indexOf(m);for(var v=0;v<b.length;v++)if(d(m,b[v]))return v;return-1}function a(m,b){h(m,0,m.children.length,b,m)}function h(m,b,d,v,w){w||(w=I(null)),w.minX=1/0,w.minY=1/0,w.maxX=-1/0,w.maxY=-1/0;for(var A=b;A<d;A++){var S=m.children[A];l(w,m.leaf?v(S):S)}return w}function l(m,b){return m.minX=Math.min(m.minX,b.minX),m.minY=Math.min(m.minY,b.minY),m.maxX=Math.max(m.maxX,b.maxX),m.maxY=Math.max(m.maxY,b.maxY),m}function u(m,b){return m.minX-b.minX}function c(m,b){return m.minY-b.minY}function f(m){return(m.maxX-m.minX)*(m.maxY-m.minY)}function p(m){return m.maxX-m.minX+(m.maxY-m.minY)}function _(m,b){return m.minX<=b.minX&&m.minY<=b.minY&&b.maxX<=m.maxX&&b.maxY<=m.maxY}function g(m,b){return b.minX<=m.maxX&&b.minY<=m.maxY&&b.maxX>=m.minX&&b.maxY>=m.minY}function I(m){return{children:m,height:1,leaf:!0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}}function M(m,b,d,v,w){for(var A=[b,d];A.length;)if(!((d=A.pop())-(b=A.pop())<=v)){var S=b+Math.ceil((d-b)/v/2)*v;n(m,S,b,d,w),A.push(b,S,S,d)}}return r.prototype.all=function(){return this._all(this.data,[])},r.prototype.search=function(m){var b=this.data,d=[];if(!g(m,b))return d;for(var v=this.toBBox,w=[];b;){for(var A=0;A<b.children.length;A++){var S=b.children[A],E=b.leaf?v(S):S;g(m,E)&&(b.leaf?d.push(S):_(m,E)?this._all(S,d):w.push(S))}b=w.pop()}return d},r.prototype.collides=function(m){var b=this.data;if(!g(m,b))return!1;for(var d=[];b;){for(var v=0;v<b.children.length;v++){var w=b.children[v],A=b.leaf?this.toBBox(w):w;if(g(m,A)){if(b.leaf||_(m,A))return!0;d.push(w)}}b=d.pop()}return!1},r.prototype.load=function(m){if(!m||!m.length)return this;if(m.length<this._minEntries){for(var b=0;b<m.length;b++)this.insert(m[b]);return this}var d=this._build(m.slice(),0,m.length-1,0);if(this.data.children.length)if(this.data.height===d.height)this._splitRoot(this.data,d);else{if(this.data.height<d.height){var v=this.data;this.data=d,d=v}this._insert(d,this.data.height-d.height-1,!0)}else this.data=d;return this},r.prototype.insert=function(m){return m&&this._insert(m,this.data.height-1),this},r.prototype.clear=function(){return this.data=I([]),this},r.prototype.remove=function(m,b){if(!m)return this;for(var d,v,w,A=this.data,S=this.toBBox(m),E=[],O=[];A||E.length;){if(A||(A=E.pop(),v=E[E.length-1],d=O.pop(),w=!0),A.leaf){var B=s(m,A.children,b);if(B!==-1)return A.children.splice(B,1),E.push(A),this._condense(E),this}w||A.leaf||!_(A,S)?v?(d++,A=v.children[d],w=!1):A=null:(E.push(A),O.push(d),d=0,v=A,A=A.children[0])}return this},r.prototype.toBBox=function(m){return m},r.prototype.compareMinX=function(m,b){return m.minX-b.minX},r.prototype.compareMinY=function(m,b){return m.minY-b.minY},r.prototype.toJSON=function(){return this.data},r.prototype.fromJSON=function(m){return this.data=m,this},r.prototype._all=function(m,b){for(var d=[];m;)m.leaf?b.push.apply(b,m.children):d.push.apply(d,m.children),m=d.pop();return b},r.prototype._build=function(m,b,d,v){var w,A=d-b+1,S=this._maxEntries;if(A<=S)return a(w=I(m.slice(b,d+1)),this.toBBox),w;v||(v=Math.ceil(Math.log(A)/Math.log(S)),S=Math.ceil(A/Math.pow(S,v-1))),(w=I([])).leaf=!1,w.height=v;var E=Math.ceil(A/S),O=E*Math.ceil(Math.sqrt(S));M(m,b,d,O,this.compareMinX);for(var B=b;B<=d;B+=O){var X=Math.min(B+O-1,d);M(m,B,X,E,this.compareMinY);for(var F=B;F<=X;F+=E){var y=Math.min(F+E-1,X);w.children.push(this._build(m,F,y,v-1))}}return a(w,this.toBBox),w},r.prototype._chooseSubtree=function(m,b,d,v){for(;v.push(b),!b.leaf&&v.length-1!==d;){for(var w=1/0,A=1/0,S=void 0,E=0;E<b.children.length;E++){var O=b.children[E],B=f(O),X=(F=m,y=O,(Math.max(y.maxX,F.maxX)-Math.min(y.minX,F.minX))*(Math.max(y.maxY,F.maxY)-Math.min(y.minY,F.minY))-B);X<A?(A=X,w=B<w?B:w,S=O):X===A&&B<w&&(w=B,S=O)}b=S||b.children[0]}var F,y;return b},r.prototype._insert=function(m,b,d){var v=d?m:this.toBBox(m),w=[],A=this._chooseSubtree(v,this.data,b,w);for(A.children.push(m),l(A,v);b>=0&&w[b].children.length>this._maxEntries;)this._split(w,b),b--;this._adjustParentBBoxes(v,w,b)},r.prototype._split=function(m,b){var d=m[b],v=d.children.length,w=this._minEntries;this._chooseSplitAxis(d,w,v);var A=this._chooseSplitIndex(d,w,v),S=I(d.children.splice(A,d.children.length-A));S.height=d.height,S.leaf=d.leaf,a(d,this.toBBox),a(S,this.toBBox),b?m[b-1].children.push(S):this._splitRoot(d,S)},r.prototype._splitRoot=function(m,b){this.data=I([m,b]),this.data.height=m.height+1,this.data.leaf=!1,a(this.data,this.toBBox)},r.prototype._chooseSplitIndex=function(m,b,d){for(var v,w,A,S,E,O,B,X=1/0,F=1/0,y=b;y<=d-b;y++){var P=h(m,0,y,this.toBBox),k=h(m,y,d,this.toBBox),T=(w=P,A=k,S=void 0,E=void 0,O=void 0,B=void 0,S=Math.max(w.minX,A.minX),E=Math.max(w.minY,A.minY),O=Math.min(w.maxX,A.maxX),B=Math.min(w.maxY,A.maxY),Math.max(0,O-S)*Math.max(0,B-E)),C=f(P)+f(k);T<X?(X=T,v=y,F=C<F?C:F):T===X&&C<F&&(F=C,v=y)}return v||d-b},r.prototype._chooseSplitAxis=function(m,b,d){var v=m.leaf?this.compareMinX:u,w=m.leaf?this.compareMinY:c;this._allDistMargin(m,b,d,v)<this._allDistMargin(m,b,d,w)&&m.children.sort(v)},r.prototype._allDistMargin=function(m,b,d,v){m.children.sort(v);for(var w=this.toBBox,A=h(m,0,b,w),S=h(m,d-b,d,w),E=p(A)+p(S),O=b;O<d-b;O++){var B=m.children[O];l(A,m.leaf?w(B):B),E+=p(A)}for(var X=d-b-1;X>=b;X--){var F=m.children[X];l(S,m.leaf?w(F):F),E+=p(S)}return E},r.prototype._adjustParentBBoxes=function(m,b,d){for(var v=d;v>=0;v--)l(b[v],m)},r.prototype._condense=function(m){for(var b=m.length-1,d=void 0;b>=0;b--)m[b].children.length===0?b>0?(d=m[b-1].children).splice(d.indexOf(m[b]),1):this.clear():a(m[b],this.toBBox)},r})})(xe)),xe.exports}const Ti=Pi(pi);var ee={exports:{}},Fe,mn;function Xi(){return mn||(mn=1,Fe=function(t,n,i,o){var r=t[0],s=t[1],a=!1;i===void 0&&(i=0),o===void 0&&(o=n.length);for(var h=(o-i)/2,l=0,u=h-1;l<h;u=l++){var c=n[i+l*2+0],f=n[i+l*2+1],p=n[i+u*2+0],_=n[i+u*2+1],g=f>s!=_>s&&r<(p-c)*(s-f)/(_-f)+c;g&&(a=!a)}return a}),Fe}var Re,gn;function Ci(){return gn||(gn=1,Re=function(t,n,i,o){var r=t[0],s=t[1],a=!1;i===void 0&&(i=0),o===void 0&&(o=n.length);for(var h=o-i,l=0,u=h-1;l<h;u=l++){var c=n[l+i][0],f=n[l+i][1],p=n[u+i][0],_=n[u+i][1],g=f>s!=_>s&&r<(p-c)*(s-f)/(_-f)+c;g&&(a=!a)}return a}),Re}var wn;function Di(){if(wn)return ee.exports;wn=1;var e=Xi(),t=Ci();return ee.exports=function(i,o,r,s){return o.length>0&&Array.isArray(o[0])?t(i,o,r,s):e(i,o,r,s)},ee.exports.nested=t,ee.exports.flat=e,ee.exports}var ne={exports:{}},Yi=ne.exports,yn;function Fi(){return yn||(yn=1,(function(e,t){(function(n,i){i(t)})(Yi,function(n){const o=33306690738754706e-32;function r(g,I,M,m,b){let d,v,w,A,S=I[0],E=m[0],O=0,B=0;E>S==E>-S?(d=S,S=I[++O]):(d=E,E=m[++B]);let X=0;if(O<g&&B<M)for(E>S==E>-S?(w=d-((v=S+d)-S),S=I[++O]):(w=d-((v=E+d)-E),E=m[++B]),d=v,w!==0&&(b[X++]=w);O<g&&B<M;)E>S==E>-S?(w=d-((v=d+S)-(A=v-d))+(S-A),S=I[++O]):(w=d-((v=d+E)-(A=v-d))+(E-A),E=m[++B]),d=v,w!==0&&(b[X++]=w);for(;O<g;)w=d-((v=d+S)-(A=v-d))+(S-A),S=I[++O],d=v,w!==0&&(b[X++]=w);for(;B<M;)w=d-((v=d+E)-(A=v-d))+(E-A),E=m[++B],d=v,w!==0&&(b[X++]=w);return d===0&&X!==0||(b[X++]=d),X}function s(g){return new Float64Array(g)}const a=33306690738754716e-32,h=22204460492503146e-32,l=11093356479670487e-47,u=s(4),c=s(8),f=s(12),p=s(16),_=s(4);n.orient2d=function(g,I,M,m,b,d){const v=(I-d)*(M-b),w=(g-b)*(m-d),A=v-w;if(v===0||w===0||v>0!=w>0)return A;const S=Math.abs(v+w);return Math.abs(A)>=a*S?A:-(function(E,O,B,X,F,y,P){let k,T,C,Y,x,N,D,R,$,j,q,V,J,G,Q,H,Z,W;const ct=E-F,ft=B-F,rt=O-y,ot=X-y;x=(Q=(R=ct-(D=(N=134217729*ct)-(N-ct)))*(j=ot-($=(N=134217729*ot)-(N-ot)))-((G=ct*ot)-D*$-R*$-D*j))-(q=Q-(Z=(R=rt-(D=(N=134217729*rt)-(N-rt)))*(j=ft-($=(N=134217729*ft)-(N-ft)))-((H=rt*ft)-D*$-R*$-D*j))),u[0]=Q-(q+x)+(x-Z),x=(J=G-((V=G+q)-(x=V-G))+(q-x))-(q=J-H),u[1]=J-(q+x)+(x-H),x=(W=V+q)-V,u[2]=V-(W-x)+(q-x),u[3]=W;let jt=(function(ho,Wn){let Zn=Wn[0];for(let We=1;We<ho;We++)Zn+=Wn[We];return Zn})(4,u),de=h*P;if(jt>=de||-jt>=de||(k=E-(ct+(x=E-ct))+(x-F),C=B-(ft+(x=B-ft))+(x-F),T=O-(rt+(x=O-rt))+(x-y),Y=X-(ot+(x=X-ot))+(x-y),k===0&&T===0&&C===0&&Y===0)||(de=l*P+o*Math.abs(jt),(jt+=ct*Y+ot*k-(rt*C+ft*T))>=de||-jt>=de))return jt;x=(Q=(R=k-(D=(N=134217729*k)-(N-k)))*(j=ot-($=(N=134217729*ot)-(N-ot)))-((G=k*ot)-D*$-R*$-D*j))-(q=Q-(Z=(R=T-(D=(N=134217729*T)-(N-T)))*(j=ft-($=(N=134217729*ft)-(N-ft)))-((H=T*ft)-D*$-R*$-D*j))),_[0]=Q-(q+x)+(x-Z),x=(J=G-((V=G+q)-(x=V-G))+(q-x))-(q=J-H),_[1]=J-(q+x)+(x-H),x=(W=V+q)-V,_[2]=V-(W-x)+(q-x),_[3]=W;const ao=r(4,u,4,_,c);x=(Q=(R=ct-(D=(N=134217729*ct)-(N-ct)))*(j=Y-($=(N=134217729*Y)-(N-Y)))-((G=ct*Y)-D*$-R*$-D*j))-(q=Q-(Z=(R=rt-(D=(N=134217729*rt)-(N-rt)))*(j=C-($=(N=134217729*C)-(N-C)))-((H=rt*C)-D*$-R*$-D*j))),_[0]=Q-(q+x)+(x-Z),x=(J=G-((V=G+q)-(x=V-G))+(q-x))-(q=J-H),_[1]=J-(q+x)+(x-H),x=(W=V+q)-V,_[2]=V-(W-x)+(q-x),_[3]=W;const co=r(ao,c,4,_,f);x=(Q=(R=k-(D=(N=134217729*k)-(N-k)))*(j=Y-($=(N=134217729*Y)-(N-Y)))-((G=k*Y)-D*$-R*$-D*j))-(q=Q-(Z=(R=T-(D=(N=134217729*T)-(N-T)))*(j=C-($=(N=134217729*C)-(N-C)))-((H=T*C)-D*$-R*$-D*j))),_[0]=Q-(q+x)+(x-Z),x=(J=G-((V=G+q)-(x=V-G))+(q-x))-(q=J-H),_[1]=J-(q+x)+(x-H),x=(W=V+q)-V,_[2]=V-(W-x)+(q-x),_[3]=W;const lo=r(co,f,4,_,p);return p[lo-1]})(g,I,M,m,b,d,S)},n.orient2dfast=function(g,I,M,m,b,d){return(I-d)*(M-b)-(g-b)*(m-d)},Object.defineProperty(n,"__esModule",{value:!0})})})(ne,ne.exports)),ne.exports}var vn;function Ri(){if(vn)return be.exports;vn=1;var e=Ni(),t=Ti,n=Di(),i=Fi().orient2d;t.default&&(t=t.default),be.exports=o,be.exports.default=o;function o(d,v,w){v=Math.max(0,v===void 0?2:v),w=w||0;var A=p(d),S=new e(16);S.toBBox=function(D){return{minX:D[0],minY:D[1],maxX:D[0],maxY:D[1]}},S.compareMinX=function(D,R){return D[0]-R[0]},S.compareMinY=function(D,R){return D[1]-R[1]},S.load(d);for(var E=[],O=0,B;O<A.length;O++){var X=A[O];S.remove(X),B=_(X,B),E.push(B)}var F=new e(16);for(O=0;O<E.length;O++)F.insert(f(E[O]));for(var y=v*v,P=w*w;E.length;){var k=E.shift(),T=k.p,C=k.next.p,Y=g(T,C);if(!(Y<P)){var x=Y/y;X=r(S,k.prev.p,T,C,k.next.next.p,x,F),X&&Math.min(g(X,T),g(X,C))<=x&&(E.push(k),E.push(_(X,k)),S.remove(X),F.remove(k),F.insert(f(k)),F.insert(f(k.next)))}}k=B;var N=[];do N.push(k.p),k=k.next;while(k!==B);return N.push(k.p),N}function r(d,v,w,A,S,E,O){for(var B=new t([],s),X=d.data;X;){for(var F=0;F<X.children.length;F++){var y=X.children[F],P=X.leaf?I(y,w,A):a(w,A,y);P>E||B.push({node:y,dist:P})}for(;B.length&&!B.peek().node.children;){var k=B.pop(),T=k.node,C=I(T,v,w),Y=I(T,A,S);if(k.dist<C&&k.dist<Y&&l(w,T,O)&&l(A,T,O))return T}X=B.pop(),X&&(X=X.node)}return null}function s(d,v){return d.dist-v.dist}function a(d,v,w){if(h(d,w)||h(v,w))return 0;var A=M(d[0],d[1],v[0],v[1],w.minX,w.minY,w.maxX,w.minY);if(A===0)return 0;var S=M(d[0],d[1],v[0],v[1],w.minX,w.minY,w.minX,w.maxY);if(S===0)return 0;var E=M(d[0],d[1],v[0],v[1],w.maxX,w.minY,w.maxX,w.maxY);if(E===0)return 0;var O=M(d[0],d[1],v[0],v[1],w.minX,w.maxY,w.maxX,w.maxY);return O===0?0:Math.min(A,S,E,O)}function h(d,v){return d[0]>=v.minX&&d[0]<=v.maxX&&d[1]>=v.minY&&d[1]<=v.maxY}function l(d,v,w){for(var A=Math.min(d[0],v[0]),S=Math.min(d[1],v[1]),E=Math.max(d[0],v[0]),O=Math.max(d[1],v[1]),B=w.search({minX:A,minY:S,maxX:E,maxY:O}),X=0;X<B.length;X++)if(c(B[X].p,B[X].next.p,d,v))return!1;return!0}function u(d,v,w){return i(d[0],d[1],v[0],v[1],w[0],w[1])}function c(d,v,w,A){return d!==A&&v!==w&&u(d,v,w)>0!=u(d,v,A)>0&&u(w,A,d)>0!=u(w,A,v)>0}function f(d){var v=d.p,w=d.next.p;return d.minX=Math.min(v[0],w[0]),d.minY=Math.min(v[1],w[1]),d.maxX=Math.max(v[0],w[0]),d.maxY=Math.max(v[1],w[1]),d}function p(d){for(var v=d[0],w=d[0],A=d[0],S=d[0],E=0;E<d.length;E++){var O=d[E];O[0]<v[0]&&(v=O),O[0]>A[0]&&(A=O),O[1]<w[1]&&(w=O),O[1]>S[1]&&(S=O)}var B=[v,w,A,S],X=B.slice();for(E=0;E<d.length;E++)n(d[E],B)||X.push(d[E]);return b(X)}function _(d,v){var w={p:d,prev:null,next:null,minX:0,minY:0,maxX:0,maxY:0};return v?(w.next=v.next,w.prev=v,v.next.prev=w,v.next=w):(w.prev=w,w.next=w),w}function g(d,v){var w=d[0]-v[0],A=d[1]-v[1];return w*w+A*A}function I(d,v,w){var A=v[0],S=v[1],E=w[0]-A,O=w[1]-S;if(E!==0||O!==0){var B=((d[0]-A)*E+(d[1]-S)*O)/(E*E+O*O);B>1?(A=w[0],S=w[1]):B>0&&(A+=E*B,S+=O*B)}return E=d[0]-A,O=d[1]-S,E*E+O*O}function M(d,v,w,A,S,E,O,B){var X=w-d,F=A-v,y=O-S,P=B-E,k=d-S,T=v-E,C=X*X+F*F,Y=X*y+F*P,x=y*y+P*P,N=X*k+F*T,D=y*k+P*T,R=C*x-Y*Y,$,j,q,V,J=R,G=R;R===0?(j=0,J=1,V=D,G=x):(j=Y*D-x*N,V=C*D-Y*N,j<0?(j=0,V=D,G=x):j>J&&(j=J,V=D+Y,G=x)),V<0?(V=0,-N<0?j=0:-N>C?j=J:(j=-N,J=C)):V>G&&(V=G,-N+Y<0?j=0:-N+Y>C?j=J:(j=-N+Y,J=C)),$=j===0?0:j/J,q=V===0?0:V/G;var Q=(1-$)*d+$*w,H=(1-$)*v+$*A,Z=(1-q)*S+q*O,W=(1-q)*E+q*B,ct=Z-Q,ft=W-H;return ct*ct+ft*ft}function m(d,v){return d[0]===v[0]?d[1]-v[1]:d[0]-v[0]}function b(d){d.sort(m);for(var v=[],w=0;w<d.length;w++){for(;v.length>=2&&u(v[v.length-2],v[v.length-1],d[w])<=0;)v.pop();v.push(d[w])}for(var A=[],S=d.length-1;S>=0;S--){for(;A.length>=2&&u(A[A.length-2],A[A.length-1],d[S])<=0;)A.pop();A.push(d[S])}return A.pop(),v.pop(),v.concat(A)}return be.exports}var Li=Ri();const $i=Ii(Li);function bn(e,t={}){t.concavity=t.concavity||1/0;const n=[];if(Ae(e,o=>{n.push([o[0],o[1]])}),!n.length)return null;const i=$i(n,t.concavity);return i.length>3?Zt([i],t.properties):null}function xn(e,t,n={}){const i={type:"Feature"};return(n.id===0||n.id)&&(i.id=n.id),n.bbox&&(i.bbox=n.bbox),i.properties=t||{},i.geometry=e,i}function ie(e,t,n={}){if(!e)throw new Error("coordinates is required");if(!Array.isArray(e))throw new Error("coordinates must be an Array");if(e.length<2)throw new Error("coordinates must be at least 2 numbers long");if(!Mn(e[0])||!Mn(e[1]))throw new Error("coordinates must contain numbers");return xn({type:"Point",coordinates:e},t,n)}function _n(e,t,n={}){for(const i of e){if(i.length<4)throw new Error("Each LinearRing of a Polygon must have 4 or more Positions.");if(i[i.length-1].length!==i[0].length)throw new Error("First and last Position are not equivalent.");for(let o=0;o<i[i.length-1].length;o++)if(i[i.length-1][o]!==i[0][o])throw new Error("First and last Position are not equivalent.")}return xn({type:"Polygon",coordinates:e},t,n)}function Qt(e,t={}){const n={type:"FeatureCollection"};return t.id&&(n.id=t.id),t.bbox&&(n.bbox=t.bbox),n.features=e,n}function Mn(e){return!isNaN(e)&&e!==null&&!Array.isArray(e)}function ji(e){if(!e)throw new Error("coord is required");if(!Array.isArray(e)){if(e.type==="Feature"&&e.geometry!==null&&e.geometry.type==="Point")return[...e.geometry.coordinates];if(e.type==="Point")return[...e.coordinates]}if(Array.isArray(e)&&e.length>=2&&!Array.isArray(e[0])&&!Array.isArray(e[1]))return[...e];throw new Error("coord must be GeoJSON Point or an Array of numbers")}function Sn(e){if(Array.isArray(e))return e;if(e.type==="Feature"){if(e.geometry!==null)return e.geometry.coordinates}else if(e.coordinates)return e.coordinates;throw new Error("coords must be GeoJSON Feature, Geometry Object or an Array")}function Vi(e){return e.type==="Feature"?e.geometry:e}const Tt=11102230246251565e-32,pt=134217729,qi=(3+8*Tt)*Tt;function Le(e,t,n,i,o){let r,s,a,h,l=t[0],u=i[0],c=0,f=0;u>l==u>-l?(r=l,l=t[++c]):(r=u,u=i[++f]);let p=0;if(c<e&&f<n)for(u>l==u>-l?(s=l+r,a=r-(s-l),l=t[++c]):(s=u+r,a=r-(s-u),u=i[++f]),r=s,a!==0&&(o[p++]=a);c<e&&f<n;)u>l==u>-l?(s=r+l,h=s-r,a=r-(s-h)+(l-h),l=t[++c]):(s=r+u,h=s-r,a=r-(s-h)+(u-h),u=i[++f]),r=s,a!==0&&(o[p++]=a);for(;c<e;)s=r+l,h=s-r,a=r-(s-h)+(l-h),l=t[++c],r=s,a!==0&&(o[p++]=a);for(;f<n;)s=r+u,h=s-r,a=r-(s-h)+(u-h),u=i[++f],r=s,a!==0&&(o[p++]=a);return(r!==0||p===0)&&(o[p++]=r),p}function Ui(e,t){let n=t[0];for(let i=1;i<e;i++)n+=t[i];return n}function re(e){return new Float64Array(e)}const zi=(3+16*Tt)*Tt,Gi=(2+12*Tt)*Tt,Ji=(9+64*Tt)*Tt*Tt,Ht=re(4),kn=re(8),En=re(12),An=re(16),vt=re(4);function Ki(e,t,n,i,o,r,s){let a,h,l,u,c,f,p,_,g,I,M,m,b,d,v,w,A,S;const E=e-o,O=n-o,B=t-r,X=i-r;d=E*X,f=pt*E,p=f-(f-E),_=E-p,f=pt*X,g=f-(f-X),I=X-g,v=_*I-(d-p*g-_*g-p*I),w=B*O,f=pt*B,p=f-(f-B),_=B-p,f=pt*O,g=f-(f-O),I=O-g,A=_*I-(w-p*g-_*g-p*I),M=v-A,c=v-M,Ht[0]=v-(M+c)+(c-A),m=d+M,c=m-d,b=d-(m-c)+(M-c),M=b-w,c=b-M,Ht[1]=b-(M+c)+(c-w),S=m+M,c=S-m,Ht[2]=m-(S-c)+(M-c),Ht[3]=S;let F=Ui(4,Ht),y=Gi*s;if(F>=y||-F>=y||(c=e-E,a=e-(E+c)+(c-o),c=n-O,l=n-(O+c)+(c-o),c=t-B,h=t-(B+c)+(c-r),c=i-X,u=i-(X+c)+(c-r),a===0&&h===0&&l===0&&u===0)||(y=Ji*s+qi*Math.abs(F),F+=E*u+X*a-(B*l+O*h),F>=y||-F>=y))return F;d=a*X,f=pt*a,p=f-(f-a),_=a-p,f=pt*X,g=f-(f-X),I=X-g,v=_*I-(d-p*g-_*g-p*I),w=h*O,f=pt*h,p=f-(f-h),_=h-p,f=pt*O,g=f-(f-O),I=O-g,A=_*I-(w-p*g-_*g-p*I),M=v-A,c=v-M,vt[0]=v-(M+c)+(c-A),m=d+M,c=m-d,b=d-(m-c)+(M-c),M=b-w,c=b-M,vt[1]=b-(M+c)+(c-w),S=m+M,c=S-m,vt[2]=m-(S-c)+(M-c),vt[3]=S;const P=Le(4,Ht,4,vt,kn);d=E*u,f=pt*E,p=f-(f-E),_=E-p,f=pt*u,g=f-(f-u),I=u-g,v=_*I-(d-p*g-_*g-p*I),w=B*l,f=pt*B,p=f-(f-B),_=B-p,f=pt*l,g=f-(f-l),I=l-g,A=_*I-(w-p*g-_*g-p*I),M=v-A,c=v-M,vt[0]=v-(M+c)+(c-A),m=d+M,c=m-d,b=d-(m-c)+(M-c),M=b-w,c=b-M,vt[1]=b-(M+c)+(c-w),S=m+M,c=S-m,vt[2]=m-(S-c)+(M-c),vt[3]=S;const k=Le(P,kn,4,vt,En);d=a*u,f=pt*a,p=f-(f-a),_=a-p,f=pt*u,g=f-(f-u),I=u-g,v=_*I-(d-p*g-_*g-p*I),w=h*l,f=pt*h,p=f-(f-h),_=h-p,f=pt*l,g=f-(f-l),I=l-g,A=_*I-(w-p*g-_*g-p*I),M=v-A,c=v-M,vt[0]=v-(M+c)+(c-A),m=d+M,c=m-d,b=d-(m-c)+(M-c),M=b-w,c=b-M,vt[1]=b-(M+c)+(c-w),S=m+M,c=S-m,vt[2]=m-(S-c)+(M-c),vt[3]=S;const T=Le(k,En,4,vt,An);return An[T-1]}function Qi(e,t,n,i,o,r){const s=(t-r)*(n-o),a=(e-o)*(i-r),h=s-a,l=Math.abs(s+a);return Math.abs(h)>=zi*l?h:-Ki(e,t,n,i,o,r,l)}function Hi(e,t){var n,i,o=0,r,s,a,h,l,u,c,f=e[0],p=e[1],_=t.length;for(n=0;n<_;n++){i=0;var g=t[n],I=g.length-1;if(u=g[0],u[0]!==g[I][0]&&u[1]!==g[I][1])throw new Error("First and last coordinates in a ring must be the same");for(s=u[0]-f,a=u[1]-p,i;i<I;i++){if(c=g[i+1],h=c[0]-f,l=c[1]-p,a===0&&l===0){if(h<=0&&s>=0||s<=0&&h>=0)return 0}else if(l>=0&&a<=0||l<=0&&a>=0){if(r=Qi(s,h,a,l,0,0),r===0)return 0;(r>0&&l>0&&a<=0||r<0&&l<=0&&a>0)&&o++}u=c,a=l,s=h}}return o%2!==0}function $e(e,t,n={}){if(!e)throw new Error("point is required");if(!t)throw new Error("polygon is required");const i=ji(e),o=Vi(t),r=o.type,s=t.bbox;let a=o.coordinates;if(s&&Wi(i,s)===!1)return!1;r==="Polygon"&&(a=[a]);for(var h=0;h<a.length;++h){const l=Hi(i,a[h]);if(l===0&&!n.ignoreBoundary||l)return!0}return!1}function Wi(e,t){return t[0]<=e[0]&&t[1]<=e[1]&&t[2]>=e[0]&&t[3]>=e[1]}function je(e,t){for(let n=0;n<t.features.length;n++)if($e(e,t.features[n]))return t.features[n]}function In(e,t){const n=t.geometry.coordinates[0][0],i=t.geometry.coordinates[0][1],o=t.geometry.coordinates[0][2],r=e.geometry.coordinates,s=t.properties.a.geom,a=t.properties.b.geom,h=t.properties.c.geom,l=[i[0]-n[0],i[1]-n[1]],u=[o[0]-n[0],o[1]-n[1]],c=[r[0]-n[0],r[1]-n[1]],f=[a[0]-s[0],a[1]-s[1]],p=[h[0]-s[0],h[1]-s[1]],_=(u[1]*c[0]-u[0]*c[1])/(l[0]*u[1]-l[1]*u[0]),g=(l[0]*c[1]-l[1]*c[0])/(l[0]*u[1]-l[1]*u[0]);return[_*f[0]+g*p[0]+s[0],_*f[1]+g*p[1]+s[1]]}function Zi(e,t,n){const i=e.geometry.coordinates,o=n.geometry.coordinates,r=Math.atan2(i[0]-o[0],i[1]-o[1]),s=tr(r,t[0]);if(s===void 0)throw new Error("Unable to determine vertex index");const a=t[1][s];return In(e,a.features[0])}function oe(e,t,n,i,o,r,s,a){let h;if(s&&(h=je(e,Qt([s]))),!h)if(n){const l=e.geometry.coordinates,u=n.gridNum,c=n.xOrigin,f=n.yOrigin,p=n.xUnit,_=n.yUnit,g=n.gridCache,I=Ot(l[0],c,p,u),M=Ot(l[1],f,_,u),m=g[I]?g[I][M]?g[I][M]:[]:[],b=Qt(m.map(d=>t.features[d]));h=je(e,b)}else h=je(e,t);return a&&a(h),h?In(e,h):Zi(e,i,o)}function Ot(e,t,n,i){let o=Math.floor((e-t)/n);return o<0&&(o=0),o>=i&&(o=i-1),o}function tr(e,t){let n=Pn(e-t[0]),i=Math.PI*2,o;for(let r=0;r<t.length;r++){const s=(r+1)%t.length,a=Pn(e-t[s]),h=Math.min(Math.abs(n),Math.abs(a));n*a<=0&&h<i&&(i=h,o=r),n=a}return o}function Pn(e,t=!1){const n=2*Math.PI,i=e-Math.floor(e/n)*n;return t?i:i>Math.PI?i-n:i}function On(e){const t=e.features;for(let n=0;n<t.length;n++){const i=t[n];`${i.properties.a.index}`.substring(0,1)==="b"&&`${i.properties.b.index}`.substring(0,1)==="b"?t[n]={geometry:{type:"Polygon",coordinates:[[i.geometry.coordinates[0][2],i.geometry.coordinates[0][0],i.geometry.coordinates[0][1],i.geometry.coordinates[0][2]]]},properties:{a:{geom:i.properties.c.geom,index:i.properties.c.index},b:{geom:i.properties.a.geom,index:i.properties.a.index},c:{geom:i.properties.b.geom,index:i.properties.b.index}},type:"Feature"}:`${i.properties.c.index}`.substring(0,1)==="b"&&`${i.properties.a.index}`.substring(0,1)==="b"&&(t[n]={geometry:{type:"Polygon",coordinates:[[i.geometry.coordinates[0][1],i.geometry.coordinates[0][2],i.geometry.coordinates[0][0],i.geometry.coordinates[0][1]]]},properties:{a:{geom:i.properties.b.geom,index:i.properties.b.index},b:{geom:i.properties.c.geom,index:i.properties.c.index},c:{geom:i.properties.a.geom,index:i.properties.a.index}},type:"Feature"})}return e}function Bn(e){const t=["a","b","c","a"].map(r=>e.properties[r].geom),n=e.geometry.coordinates[0],i=e.properties,o={a:{geom:n[0],index:i.a.index},b:{geom:n[1],index:i.b.index},c:{geom:n[2],index:i.c.index}};return _n([t],o)}function er(e){const t=[0,1,2,0].map(i=>e[i][0][0]),n={a:{geom:e[0][0][1],index:e[0][1]},b:{geom:e[1][0][1],index:e[1][1]},c:{geom:e[2][0][1],index:e[2][1]}};return _n([t],n)}function Ve(e,t,n,i,o,r=!1,s){const a=e.map(h=>{(!s||s<2.00703)&&(h=nr(h));const l=isFinite(h)?t[h]:h==="c"?i:(function(){const u=h.match(/^b(\d+)$/);if(u)return o[parseInt(u[1])];const c=h.match(/^e(\d+)$/);if(c)return n[parseInt(c[1])];throw new Error("Bad index value for indexesToTri")})();return r?[[l[1],l[0]],h]:[[l[0],l[1]],h]});return er(a)}function nr(e){return typeof e=="number"?e:e.replace(/^(c|e|b)(?:ent|dgeNode|box)(\d+)?$/,"$1$2")}function Nn(e,t){return t&&t>=2.00703||Array.isArray(e[0])?e:e.map(n=>[n.illstNodes,n.mercNodes,n.startEnd])}const ir=2.00704;function rr(e){return!!(e.version!==void 0||!e.tins&&e.points&&e.tins_points)}function or(e){return{points:e.points,strictStatus:ar(e),verticesParams:cr(e),centroid:lr(e),edges:Nn(e.edges||[]),edgeNodes:e.edgeNodes||[],tins:hr(e),kinks:fr(e.kinks_points),yaxisMode:e.yaxisMode??"invert",strictMode:e.strictMode??"auto",vertexMode:e.vertexMode,bounds:e.bounds,boundsPolygon:e.boundsPolygon,wh:e.wh,xy:e.xy??[0,0]}}function sr(e){const t=ur(e),n=t.tins;return{compiled:t,tins:n,points:dr(n),strictStatus:t.strict_status,verticesParams:t.vertices_params,centroid:t.centroid,kinks:t.kinks}}function ar(e){return e.strict_status?e.strict_status:e.kinks_points?"strict_error":e.tins_points.length===2?"loose":"strict"}function cr(e){const t={forw:[e.vertices_params[0]],bakw:[e.vertices_params[1]]};return t.forw[1]=Tn(e,!1),t.bakw[1]=Tn(e,!0),t}function Tn(e,t){const n=e.vertices_points.length;return Array.from({length:n},(i,o)=>{const r=(o+1)%n,s=Ve(["c",`b${o}`,`b${r}`],e.points,e.edgeNodes||[],e.centroid_point,e.vertices_points,t,ir);return Qt([s])})}function lr(e){return{forw:ie(e.centroid_point[0],{target:{geom:e.centroid_point[1],index:"c"}}),bakw:ie(e.centroid_point[1],{target:{geom:e.centroid_point[0],index:"c"}})}}function hr(e){const t=e.tins_points.length===1?0:1;return{forw:Qt(e.tins_points[0].map(n=>Ve(n,e.points,e.edgeNodes||[],e.centroid_point,e.vertices_points,!1,e.version))),bakw:Qt(e.tins_points[t].map(n=>Ve(n,e.points,e.edgeNodes||[],e.centroid_point,e.vertices_points,!0,e.version)))}}function fr(e){if(e)return{bakw:Qt(e.map(t=>ie(t)))}}function ur(e){return JSON.parse(JSON.stringify(e).replace('"cent"','"c"').replace(/"bbox(\d+)"/g,'"b$1"'))}function dr(e){const t=[],n=e.forw.features;for(let i=0;i<n.length;i++){const o=n[i];["a","b","c"].forEach((r,s)=>{const a=o.geometry.coordinates[0][s],h=o.properties[r].geom,l=o.properties[r].index;typeof l=="number"&&(t[l]=[a,h])})}return t}class kt{static VERTEX_PLAIN="plain";static VERTEX_BIRDEYE="birdeye";static MODE_STRICT="strict";static MODE_AUTO="auto";static MODE_LOOSE="loose";static STATUS_STRICT="strict";static STATUS_ERROR="strict_error";static STATUS_LOOSE="loose";static YAXIS_FOLLOW="follow";static YAXIS_INVERT="invert";points=[];pointsWeightBuffer;strict_status;vertices_params;centroid;edgeNodes;edges;tins;kinks;yaxisMode=kt.YAXIS_INVERT;strictMode=kt.MODE_AUTO;vertexMode=kt.VERTEX_PLAIN;bounds;boundsPolygon;wh;xy;indexedTins;stateFull=!1;stateTriangle;stateBackward;priority;importance;xyBounds;mercBounds;constructor(){}setCompiled(t){if(rr(t)){this.applyModernState(or(t));return}this.applyLegacyState(sr(t))}applyModernState(t){this.points=t.points,this.strict_status=t.strictStatus,this.vertices_params=t.verticesParams,this.centroid=t.centroid,this.edges=t.edges,this.edgeNodes=t.edgeNodes||[],this.tins=t.tins,this.addIndexedTin(),this.kinks=t.kinks,this.yaxisMode=t.yaxisMode??kt.YAXIS_INVERT,this.vertexMode=t.vertexMode??kt.VERTEX_PLAIN,this.strictMode=t.strictMode??kt.MODE_AUTO,t.bounds?(this.bounds=t.bounds,this.boundsPolygon=t.boundsPolygon,this.xy=t.xy,this.wh=t.wh):(this.bounds=void 0,this.boundsPolygon=void 0,this.xy=t.xy??[0,0],t.wh&&(this.wh=t.wh))}applyLegacyState(t){this.tins=t.tins,this.addIndexedTin(),this.strict_status=t.strictStatus,this.vertices_params=t.verticesParams,this.centroid=t.centroid,this.kinks=t.kinks,this.points=t.points}addIndexedTin(){const t=this.tins,n=t.forw,i=t.bakw,o=Math.ceil(Math.sqrt(n.features.length));if(o<3){this.indexedTins=void 0;return}let r=[],s=[];const a=n.features.map(g=>{let I=[];return Sn(g)[0].map(M=>{r.length===0?r=[Array.from(M),Array.from(M)]:(M[0]<r[0][0]&&(r[0][0]=M[0]),M[0]>r[1][0]&&(r[1][0]=M[0]),M[1]<r[0][1]&&(r[0][1]=M[1]),M[1]>r[1][1]&&(r[1][1]=M[1])),I.length===0?I=[Array.from(M),Array.from(M)]:(M[0]<I[0][0]&&(I[0][0]=M[0]),M[0]>I[1][0]&&(I[1][0]=M[0]),M[1]<I[0][1]&&(I[0][1]=M[1]),M[1]>I[1][1]&&(I[1][1]=M[1]))}),I}),h=(r[1][0]-r[0][0])/o,l=(r[1][1]-r[0][1])/o,u=a.reduce((g,I,M)=>{const m=Ot(I[0][0],r[0][0],h,o),b=Ot(I[1][0],r[0][0],h,o),d=Ot(I[0][1],r[0][1],l,o),v=Ot(I[1][1],r[0][1],l,o);for(let w=m;w<=b;w++){g[w]||(g[w]=[]);for(let A=d;A<=v;A++)g[w][A]||(g[w][A]=[]),g[w][A].push(M)}return g},[]),c=i.features.map(g=>{let I=[];return Sn(g)[0].map(M=>{s.length===0?s=[Array.from(M),Array.from(M)]:(M[0]<s[0][0]&&(s[0][0]=M[0]),M[0]>s[1][0]&&(s[1][0]=M[0]),M[1]<s[0][1]&&(s[0][1]=M[1]),M[1]>s[1][1]&&(s[1][1]=M[1])),I.length===0?I=[Array.from(M),Array.from(M)]:(M[0]<I[0][0]&&(I[0][0]=M[0]),M[0]>I[1][0]&&(I[1][0]=M[0]),M[1]<I[0][1]&&(I[0][1]=M[1]),M[1]>I[1][1]&&(I[1][1]=M[1]))}),I}),f=(s[1][0]-s[0][0])/o,p=(s[1][1]-s[0][1])/o,_=c.reduce((g,I,M)=>{const m=Ot(I[0][0],s[0][0],f,o),b=Ot(I[1][0],s[0][0],f,o),d=Ot(I[0][1],s[0][1],p,o),v=Ot(I[1][1],s[0][1],p,o);for(let w=m;w<=b;w++){g[w]||(g[w]=[]);for(let A=d;A<=v;A++)g[w][A]||(g[w][A]=[]),g[w][A].push(M)}return g},[]);this.indexedTins={forw:{gridNum:o,xOrigin:r[0][0],yOrigin:r[0][1],xUnit:h,yUnit:l,gridCache:u},bakw:{gridNum:o,xOrigin:s[0][0],yOrigin:s[0][1],xUnit:f,yUnit:p,gridCache:_}}}transform(t,n,i){if(!this.tins)throw new Error("setCompiled() must be called before transform()");if(n&&this.strict_status==kt.STATUS_ERROR)throw new Error('Backward transform is not allowed if strict_status == "strict_error"');this.yaxisMode==kt.YAXIS_FOLLOW&&n&&(t=[t[0],-1*t[1]]);const o=ie(t);if(this.bounds&&!n&&!i&&!$e(o,this.boundsPolygon))return!1;const r=n?this.tins.bakw:this.tins.forw,s=n?this.indexedTins.bakw:this.indexedTins.forw,a=n?this.vertices_params.bakw:this.vertices_params.forw,h=n?this.centroid.bakw:this.centroid.forw;let l,u;this.stateFull&&(this.stateBackward==n?l=this.stateTriangle:(this.stateBackward=n,this.stateTriangle=void 0),u=f=>{this.stateTriangle=f});let c=oe(o,r,s,a,h,void 0,l,u);if(this.bounds&&n&&!i){const f=ie(c);if(!$e(f,this.boundsPolygon))return!1}else this.yaxisMode==kt.YAXIS_FOLLOW&&!n&&(c=[c[0],-1*c[1]]);return c}}const Xn=Math.pow(2,-52),_e=new Uint32Array(512);class qe{static from(t,n=yr,i=vr){const o=t.length,r=new Float64Array(o*2);for(let s=0;s<o;s++){const a=t[s];r[2*s]=n(a),r[2*s+1]=i(a)}return new qe(r)}constructor(t){const n=t.length>>1;if(n>0&&typeof t[0]!="number")throw new Error("Expected coords to contain numbers.");this.coords=t;const i=Math.max(2*n-5,0);this._triangles=new Uint32Array(i*3),this._halfedges=new Int32Array(i*3),this._hashSize=Math.ceil(Math.sqrt(n)),this._hullPrev=new Uint32Array(n),this._hullNext=new Uint32Array(n),this._hullTri=new Uint32Array(n),this._hullHash=new Int32Array(this._hashSize),this._ids=new Uint32Array(n),this._dists=new Float64Array(n),this.trianglesLen=0,this._cx=0,this._cy=0,this._hullStart=0,this.hull=this._triangles,this.triangles=this._triangles,this.halfedges=this._halfedges,this.update()}update(){const{coords:t,_hullPrev:n,_hullNext:i,_hullTri:o,_hullHash:r}=this,s=t.length>>1;let a=1/0,h=1/0,l=-1/0,u=-1/0;for(let E=0;E<s;E++){const O=t[2*E],B=t[2*E+1];O<a&&(a=O),B<h&&(h=B),O>l&&(l=O),B>u&&(u=B),this._ids[E]=E}const c=(a+l)/2,f=(h+u)/2;let p=0,_=0,g=0;for(let E=0,O=1/0;E<s;E++){const B=Ue(c,f,t[2*E],t[2*E+1]);B<O&&(p=E,O=B)}const I=t[2*p],M=t[2*p+1];for(let E=0,O=1/0;E<s;E++){if(E===p)continue;const B=Ue(I,M,t[2*E],t[2*E+1]);B<O&&B>0&&(_=E,O=B)}let m=t[2*_],b=t[2*_+1],d=1/0;for(let E=0;E<s;E++){if(E===p||E===_)continue;const O=gr(I,M,m,b,t[2*E],t[2*E+1]);O<d&&(g=E,d=O)}let v=t[2*g],w=t[2*g+1];if(d===1/0){for(let B=0;B<s;B++)this._dists[B]=t[2*B]-t[0]||t[2*B+1]-t[1];Wt(this._ids,this._dists,0,s-1);const E=new Uint32Array(s);let O=0;for(let B=0,X=-1/0;B<s;B++){const F=this._ids[B],y=this._dists[F];y>X&&(E[O++]=F,X=y)}this.hull=E.subarray(0,O),this.triangles=new Uint32Array(0),this.halfedges=new Int32Array(0);return}if(Et(I,M,m,b,v,w)<0){const E=_,O=m,B=b;_=g,m=v,b=w,g=E,v=O,w=B}const A=wr(I,M,m,b,v,w);this._cx=A.x,this._cy=A.y;for(let E=0;E<s;E++)this._dists[E]=Ue(t[2*E],t[2*E+1],A.x,A.y);Wt(this._ids,this._dists,0,s-1),this._hullStart=p;let S=3;i[p]=n[g]=_,i[_]=n[p]=g,i[g]=n[_]=p,o[p]=0,o[_]=1,o[g]=2,r.fill(-1),r[this._hashKey(I,M)]=p,r[this._hashKey(m,b)]=_,r[this._hashKey(v,w)]=g,this.trianglesLen=0,this._addTriangle(p,_,g,-1,-1,-1);for(let E=0,O=0,B=0;E<this._ids.length;E++){const X=this._ids[E],F=t[2*X],y=t[2*X+1];if(E>0&&Math.abs(F-O)<=Xn&&Math.abs(y-B)<=Xn||(O=F,B=y,X===p||X===_||X===g))continue;let P=0;for(let x=0,N=this._hashKey(F,y);x<this._hashSize&&(P=r[(N+x)%this._hashSize],!(P!==-1&&P!==i[P]));x++);P=n[P];let k=P,T;for(;T=i[k],Et(F,y,t[2*k],t[2*k+1],t[2*T],t[2*T+1])>=0;)if(k=T,k===P){k=-1;break}if(k===-1)continue;let C=this._addTriangle(k,X,i[k],-1,-1,o[k]);o[X]=this._legalize(C+2),o[k]=C,S++;let Y=i[k];for(;T=i[Y],Et(F,y,t[2*Y],t[2*Y+1],t[2*T],t[2*T+1])<0;)C=this._addTriangle(Y,X,T,o[X],-1,o[Y]),o[X]=this._legalize(C+2),i[Y]=Y,S--,Y=T;if(k===P)for(;T=n[k],Et(F,y,t[2*T],t[2*T+1],t[2*k],t[2*k+1])<0;)C=this._addTriangle(T,X,k,-1,o[k],o[T]),this._legalize(C+2),o[T]=C,i[k]=k,S--,k=T;this._hullStart=n[X]=k,i[k]=n[Y]=X,i[X]=Y,r[this._hashKey(F,y)]=X,r[this._hashKey(t[2*k],t[2*k+1])]=k}this.hull=new Uint32Array(S);for(let E=0,O=this._hullStart;E<S;E++)this.hull[E]=O,O=i[O];this.triangles=this._triangles.subarray(0,this.trianglesLen),this.halfedges=this._halfedges.subarray(0,this.trianglesLen)}_hashKey(t,n){return Math.floor(pr(t-this._cx,n-this._cy)*this._hashSize)%this._hashSize}_legalize(t){const{_triangles:n,_halfedges:i,coords:o}=this;let r=0,s=0;for(;;){const a=i[t],h=t-t%3;if(s=h+(t+2)%3,a===-1){if(r===0)break;t=_e[--r];continue}const l=a-a%3,u=h+(t+1)%3,c=l+(a+2)%3,f=n[s],p=n[t],_=n[u],g=n[c];if(mr(o[2*f],o[2*f+1],o[2*p],o[2*p+1],o[2*_],o[2*_+1],o[2*g],o[2*g+1])){n[t]=g,n[a]=f;const M=i[c];if(M===-1){let b=this._hullStart;do{if(this._hullTri[b]===c){this._hullTri[b]=t;break}b=this._hullPrev[b]}while(b!==this._hullStart)}this._link(t,M),this._link(a,i[s]),this._link(s,c);const m=l+(a+1)%3;r<_e.length&&(_e[r++]=m)}else{if(r===0)break;t=_e[--r]}}return s}_link(t,n){this._halfedges[t]=n,n!==-1&&(this._halfedges[n]=t)}_addTriangle(t,n,i,o,r,s){const a=this.trianglesLen;return this._triangles[a]=t,this._triangles[a+1]=n,this._triangles[a+2]=i,this._link(a,o),this._link(a+1,r),this._link(a+2,s),this.trianglesLen+=3,a}}function pr(e,t){const n=e/(Math.abs(e)+Math.abs(t));return(t>0?3-n:1+n)/4}function Ue(e,t,n,i){const o=e-n,r=t-i;return o*o+r*r}function mr(e,t,n,i,o,r,s,a){const h=e-s,l=t-a,u=n-s,c=i-a,f=o-s,p=r-a,_=h*h+l*l,g=u*u+c*c,I=f*f+p*p;return h*(c*I-g*p)-l*(u*I-g*f)+_*(u*p-c*f)<0}function gr(e,t,n,i,o,r){const s=n-e,a=i-t,h=o-e,l=r-t,u=s*s+a*a,c=h*h+l*l,f=.5/(s*l-a*h),p=(l*u-a*c)*f,_=(s*c-h*u)*f;return p*p+_*_}function wr(e,t,n,i,o,r){const s=n-e,a=i-t,h=o-e,l=r-t,u=s*s+a*a,c=h*h+l*l,f=.5/(s*l-a*h),p=e+(l*u-a*c)*f,_=t+(s*c-h*u)*f;return{x:p,y:_}}function Wt(e,t,n,i){if(i-n<=20)for(let o=n+1;o<=i;o++){const r=e[o],s=t[r];let a=o-1;for(;a>=n&&t[e[a]]>s;)e[a+1]=e[a--];e[a+1]=r}else{const o=n+i>>1;let r=n+1,s=i;se(e,o,r),t[e[n]]>t[e[i]]&&se(e,n,i),t[e[r]]>t[e[i]]&&se(e,r,i),t[e[n]]>t[e[r]]&&se(e,n,r);const a=e[r],h=t[a];for(;;){do r++;while(t[e[r]]<h);do s--;while(t[e[s]]>h);if(s<r)break;se(e,r,s)}e[n+1]=e[s],e[s]=a,i-r+1>=s-n?(Wt(e,t,r,i),Wt(e,t,n,s-1)):(Wt(e,t,n,s-1),Wt(e,t,r,i))}}function se(e,t,n){const i=e[t];e[t]=e[n],e[n]=i}function yr(e){return e[0]}function vr(e){return e[1]}class br{bs;width;constructor(t,n){this.width=t,this.bs=n}add(t){const n=Math.floor(t/this.width),i=t%this.width;return this.bs[n]|=1<<i,this}delete(t){const n=Math.floor(t/this.width),i=t%this.width;return this.bs[n]&=~(1<<i),this}set(t,n){const i=Math.floor(t/this.width),r=1<<t%this.width;return this.bs[i]^=(-Number(n)^this.bs[i])&r,n}has(t){const n=Math.floor(t/this.width),i=t%this.width;return(this.bs[n]&1<<i)!==0}forEach(t){const n=this.bs.length;for(let i=0;i<n;i++){let o=0;for(;this.bs[i]&&o<this.width;)this.bs[i]&1<<o&&t(i*this.width+o),o++}return this}}class Cn extends br{constructor(t){super(8,new Uint8Array(Math.ceil(t/8)).fill(0))}}function zt(e){return e%3===2?e-2:e+1}function Xt(e){return e%3===0?e+2:e-1}function Dn(e,t,n,i,o,r,s,a){const h=Et(e,t,o,r,s,a),l=Et(n,i,o,r,s,a);if(h>0&&l>0||h<0&&l<0)return!1;const u=Et(o,r,e,t,n,i),c=Et(s,a,e,t,n,i);return u>0&&c>0||u<0&&c<0?!1:h===0&&l===0&&u===0&&c===0?!(Math.max(o,s)<Math.min(e,n)||Math.max(e,n)<Math.min(o,s)||Math.max(r,a)<Math.min(t,i)||Math.max(t,i)<Math.min(r,a)):!0}class xr{del;constructor(t){this.del=t}}class _r extends xr{vertMap;flips;consd;constructor(t,n){if(!t||typeof t!="object"||!t.triangles||!t.halfedges||!t.coords)throw new Error("Expected an object with Delaunator output");if(t.triangles.length%3||t.halfedges.length!==t.triangles.length||t.coords.length%2)throw new Error("Delaunator output appears inconsistent");if(t.triangles.length<3)throw new Error("No edges in triangulation");super(t);const i=2**32-1,o=t.coords.length>>1,r=t.triangles.length;this.vertMap=new Uint32Array(o).fill(i),this.flips=new Cn(r),this.consd=new Cn(r);for(let s=0;s<r;s++){const a=t.triangles[s];this.vertMap[a]===i&&this.updateVert(s)}n&&this.constrainAll(n)}constrainOne(t,n){const{triangles:i,halfedges:o}=this.del,r=this.vertMap[t];let s=r;do{const l=i[s],u=zt(s);if(l===n)return this.protect(s);const c=Xt(s),f=i[c];if(f===n)return this.protect(u),u;if(this.intersectSegments(t,n,f,l)){s=c;break}s=o[u]}while(s!==-1&&s!==r);let a=s,h=-1;for(;s!==-1;){const l=o[s],u=Xt(s),c=Xt(l),f=zt(l);if(l===-1)throw new Error("Constraining edge exited the hull");if(this.consd.has(s))throw new Error("Edge intersects already constrained edge");if(this.isCollinear(t,n,i[s])||this.isCollinear(t,n,i[l]))throw new Error("Constraining edge intersects point");if(!this.intersectSegments(i[s],i[l],i[u],i[c])){if(h===-1&&(h=s),i[c]===n){if(s===h)throw new Error("Infinite loop: non-convex quadrilateral");s=h,h=-1;continue}if(this.intersectSegments(t,n,i[c],i[l]))s=c;else if(this.intersectSegments(t,n,i[f],i[c]))s=f;else if(h===s)throw new Error("Infinite loop: no further intersect after non-convex");continue}if(this.flipDiagonal(s),this.intersectSegments(t,n,i[u],i[c])&&(h===-1&&(h=u),h===u))throw new Error("Infinite loop: flipped diagonal still intersects");i[c]===n?(a=c,s=h,h=-1):this.intersectSegments(t,n,i[f],i[c])&&(s=f)}return this.protect(a),this.delaunify(!0),this.findEdge(t,n)}delaunify(t=!1){const{halfedges:n}=this.del,i=this.flips,o=this.consd,r=n.length;let s;do{s=0;for(let a=0;a<r;a++){if(o.has(a))continue;i.delete(a);const h=n[a];h!==-1&&(i.delete(h),this.isDelaunay(a)||(this.flipDiagonal(a),s++))}}while(t&&s>0);return this}constrainAll(t){const n=t.length;for(let i=0;i<n;i++){const o=t[i];this.constrainOne(o[0],o[1])}return this}isConstrained(t){return this.consd.has(t)}findEdge(t,n){const i=this.vertMap[n],{triangles:o,halfedges:r}=this.del;let s=i,a;do{if(o[s]===t)return s;a=zt(s),s=r[a]}while(s!==-1&&s!==i);return o[zt(a)]===t?-a:1/0}protect(t){const n=this.del.halfedges[t],i=this.flips,o=this.consd;return i.delete(t),o.add(t),n!==-1?(i.delete(n),o.add(n),n):-t}markFlip(t){const n=this.del.halfedges,i=this.flips;if(this.consd.has(t))return!1;const r=n[t];return r!==-1&&(i.add(t),i.add(r)),!0}flipDiagonal(t){const{triangles:n,halfedges:i}=this.del,o=this.flips,r=this.consd,s=i[t],a=Xt(t),h=zt(t),l=Xt(s),u=zt(s),c=i[a],f=i[l];if(r.has(t))throw new Error("Trying to flip a constrained edge");return n[t]=n[l],i[t]=f,o.set(t,o.has(l))||r.set(t,r.has(l)),f!==-1&&(i[f]=t),i[a]=l,n[s]=n[a],i[s]=c,o.set(s,o.has(a))||r.set(s,r.has(a)),c!==-1&&(i[c]=s),i[l]=a,this.markFlip(t),this.markFlip(h),this.markFlip(s),this.markFlip(u),o.add(a),r.delete(a),o.add(l),r.delete(l),this.updateVert(t),this.updateVert(h),this.updateVert(s),this.updateVert(u),a}isCollinear(t,n,i){const o=this.del.coords;return Et(o[t*2],o[t*2+1],o[n*2],o[n*2+1],o[i*2],o[i*2+1])===0}inCircle(t,n,i,o){const r=this.del.coords;return hi(r[t*2],r[t*2+1],r[n*2],r[n*2+1],r[i*2],r[i*2+1],r[o*2],r[o*2+1])<0}isDelaunay(t){const{triangles:n,halfedges:i}=this.del,o=i[t];if(o===-1)return!0;const r=n[Xt(t)],s=n[t],a=n[zt(t)],h=n[Xt(o)];return!this.inCircle(r,s,a,h)}updateVert(t){const{triangles:n,halfedges:i}=this.del,o=this.vertMap,r=n[t];let s=Xt(t),a=i[s];for(;a!==-1&&a!==t;)s=Xt(a),a=i[s];return o[r]=s,s}intersectSegments(t,n,i,o){const r=this.del.coords;return t===i||t===o||n===i||n===o?!1:Dn(r[t*2],r[t*2+1],r[n*2],r[n*2+1],r[i*2],r[i*2+1],r[o*2],r[o*2+1])}static intersectSegments=Dn}function ae(e,t,n){if(t||(t=[]),typeof e!="object"||e.type!=="FeatureCollection")throw"Argument points must be FeatureCollection";if(!Array.isArray(t))throw"Argument points must be Array of Array";const i=e.features.map(h=>h.geometry.coordinates),o=qe.from(i);let r;const s=[];o.triangles.length!==0&&t.length!==0&&(r=new _r(o),r.constrainAll(t));for(let h=0;h<o.triangles.length;h+=3)s.push([o.triangles[h],o.triangles[h+1],o.triangles[h+2]]);const a=["a","b","c"];return St(s.map(h=>{const l={},u=h.map((c,f)=>{const p=e.features[c],_=p.geometry.coordinates,g=[_[0],_[1]];return _.length===3?g[2]=_[2]:l[a[f]]=p.properties[n],g});return u[3]=u[0],Zt([u],l)}))}function Mr(e,t){const n=[[],[],[],[]],i=[];return Object.keys(e).forEach(o=>{const r=e[o],s=r.forw,a=r.bakw,h=[s[0]-t.forw[0],s[1]-t.forw[1]],l=[a[0]-t.bakw[0],t.bakw[1]-a[1]],u={forw:h,bakw:l};if(i.push(u),h[0]===0||h[1]===0)return;let c=0;h[0]>0&&(c+=1),h[1]>0&&(c+=2),n[c].push(u)}),{perQuad:n,aggregate:i}}function Sr(e){let t=1/0,n=0,i=0;return e.forEach(o=>{const{forw:r,bakw:s}=o,a=Math.hypot(r[0],r[1]),h=Math.hypot(s[0],s[1]);if(h===0)return;const l=a/h,u=Math.atan2(r[0],r[1])-Math.atan2(s[0],s[1]);t=Math.min(t,l),n+=Math.cos(u),i+=Math.sin(u)}),isFinite(t)?[t,Math.atan2(i,n)]:[1,0]}function kr(e,t,n){const{perQuad:i,aggregate:o}=Mr(e,t),r=i.every(h=>h.length>0),a=(n==="birdeye"?r?i:[o]:[o]).map(h=>Sr(h));return a.length===1?[a[0],a[0],a[0],a[0]]:a}function Er(e,t){let n=0;return e[0]>t[0]&&(n+=1),e[1]>t[1]&&(n+=2),n}function Ar(e,t,n){const i=[e[0]-t.forw[0],e[1]-t.forw[1]],r=Math.sqrt(i[0]**2+i[1]**2)/n[0],s=Math.atan2(i[0],i[1])-n[1];return[t.bakw[0]+r*Math.sin(s),t.bakw[1]-r*Math.cos(s)]}function Ir(e,t,n,i){const o=t[0]-e[0],r=t[1]-e[1];if(Math.abs(o)<1e-12&&Math.abs(r)<1e-12)return null;const s=i[0]-n[0],a=i[1]-n[1],h=n[0]-e[0],l=n[1]-e[1],u=o*a-r*s;if(Math.abs(u)<1e-12)return null;const c=(h*a-l*s)/u,f=(h*r-l*o)/u;return c<=1e-10||f<-1e-10||f>1+1e-10?null:{t:c,point:[e[0]+c*o,e[1]+c*r]}}function Pr(e,t,n){const i=n.length;let o=-1/0,r=null;for(let s=0;s<i;s++){const a=(s+1)%i,h=Ir(e,t,n[s].bakw,n[a].bakw);h&&h.t>o&&(o=h.t,r=h.point)}return r}function Yn(e,t){const i=Math.atan2(e[0]-t[0],e[1]-t[1])*(180/Math.PI);return i<0?i+360:i}function Fn(e,t,n,i,o,r){const s=t[0]-e[0],a=t[1]-e[1];if(s===0&&a===0)return null;const h=[];if(s!==0)for(const u of[n,i]){const c=(u-e[0])/s;if(c>0){const f=e[1]+c*a;f>=o&&f<=r&&h.push({t:c,x:u,y:f})}}if(a!==0)for(const u of[o,r]){const c=(u-e[1])/a;if(c>0){const f=e[0]+c*s;f>=n&&f<=i&&h.push({t:c,x:f,y:u})}}if(h.length===0)return null;h.sort((u,c)=>u.t-c.t);const l=h[0];return[l.x,l.y]}function Rn(e,t,n){const i=e.length,o=new Array(i).fill(1);for(const r of t)for(let s=0;s<i;s++){const a=(s+1)%i,h=Ze([e[s].bakw,e[a].bakw]),l=Ze([n.bakw,r.bakw]),u=Ai(h,l);if(u.features.length>0&&u.features[0].geometry){const c=u.features[0],f=Math.sqrt(Math.pow(r.bakw[0]-n.bakw[0],2)+Math.pow(r.bakw[1]-n.bakw[1],2)),p=Math.sqrt(Math.pow(c.geometry.coordinates[0]-n.bakw[0],2)+Math.pow(c.geometry.coordinates[1]-n.bakw[1],2)),_=f/p;_>o[s]&&(o[s]=_),_>o[a]&&(o[a]=_)}}e.forEach((r,s)=>{const a=o[s];r.bakw=[(r.bakw[0]-n.bakw[0])*a+n.bakw[0],(r.bakw[1]-n.bakw[1])*a+n.bakw[1]]})}function Ln(e,t,n){const{convexBuf:i,centroid:o,allGcps:r,minx:s,maxx:a,miny:h,maxy:l}=e,u=kr(i,o,t),f=[[s,h],[a,h],[a,l],[s,l]].map(w=>({forw:w,bakw:Ar(w,o,u[Er(w,o.forw)])}));if(f.sort((w,A)=>Math.atan2(w.forw[0]-o.forw[0],w.forw[1]-o.forw[1])-Math.atan2(A.forw[0]-o.forw[0],A.forw[1]-o.forw[1])),Rn(f,r,o),!n)return f;const p=4,_=f.map(w=>Math.atan2(w.forw[0]-o.forw[0],w.forw[1]-o.forw[1])),g=f.map(w=>Math.atan2(w.bakw[0]-o.bakw[0],-(w.bakw[1]-o.bakw[1])));function I(w){for(let A=0;A<p;A++){const S=(A+1)%p,E=_[A],O=A<p-1?_[S]:_[S]+2*Math.PI;let B=w;for(;B<E;)B+=2*Math.PI;for(;B>=E+2*Math.PI;)B-=2*Math.PI;if(B>=E&&B<O)return{i:A,j:S,frac:(B-E)/(O-E)}}return{i:0,j:1,frac:0}}function M(w){const{i:A,j:S,frac:E}=I(w),O=g[A];let X=g[S]-O;for(;X>Math.PI;)X-=2*Math.PI;for(;X<-Math.PI;)X+=2*Math.PI;return O+E*X}const m=new Set(f.map(w=>Math.floor(Yn(w.forw,o.forw)/10)%36)),b=r.map(w=>({forw:w.forw,bakw:w.bakw,angleDeg:Yn(w.forw,o.forw),forwDist:Math.hypot(w.forw[0]-o.forw[0],w.forw[1]-o.forw[1])})),d=[];for(let w=0;w<36;w++){if(m.has(w))continue;const A=w*10,S=b.filter(P=>P.angleDeg>=A&&P.angleDeg<A+10);let E=null;if(S.length>0){const P=S.reduce((k,T)=>T.forwDist>k.forwDist?T:k);E=Fn(o.forw,P.forw,s,a,h,l)}if(!E){const P=(A+5)%360*(Math.PI/180),k=[o.forw[0]+Math.sin(P),o.forw[1]+Math.cos(P)];E=Fn(o.forw,k,s,a,h,l)}if(!E)continue;const O=[E[0]-o.forw[0],E[1]-o.forw[1]],B=Math.atan2(O[0],O[1]),X=M(B),F=[o.bakw[0]+Math.sin(X),o.bakw[1]-Math.cos(X)],y=Pr(o.bakw,F,f);y&&d.push({forw:E,bakw:y})}const v=[...f,...d];return v.sort((w,A)=>Math.atan2(w.forw[0]-o.forw[0],w.forw[1]-o.forw[1])-Math.atan2(A.forw[0]-o.forw[0],A.forw[1]-o.forw[1])),Rn(v,r,o),v}function Or(e,t=!1){return Ln(e,"plain",t)}function Br(e,t=!1){return Ln(e,"birdeye",t)}function $n(e){const n=new Nr(e).findSegmentIntersections(),i=Gn(n),o=new Map;return i.forEach(r=>{o.set(`${r.x}:${r.y}`,r)}),Array.from(o.values()).map(r=>Dt([r.x,r.y]))}class Nr{_xx;_yy;_ii;_nn;_zz=null;_zlimit=0;_bb=null;_allBounds=null;_arcIter=null;_filteredArcIter=null;buf;constructor(t){this.initArcs(t)}initArcs(t){const n=[],i=[],o=t.map(r=>{const s=r?r.length:0;for(let a=0;a<s;a++)n.push(r[a][0]),i.push(r[a][1]);return s});this.initXYData(o,n,i)}initXYData(t,n,i){const o=t.length;this._xx=new Float64Array(n),this._yy=new Float64Array(i),this._nn=new Uint32Array(t),this._zz=null,this._zlimit=0,this._filteredArcIter=null,this._ii=new Uint32Array(o);let r=0;for(let s=0;s<o;s++)this._ii[s]=r,r+=t[s];(r!=this._xx.length||this._xx.length!=this._yy.length)&&ze("ArcCollection#initXYData() Counting error"),this.initBounds(),this._arcIter=new Wr(this._xx,this._yy)}initBounds(){const t=this.calcArcBounds_(this._xx,this._yy,this._nn);this._bb=t.bb,this._allBounds=t.bounds}calcArcBounds_(t,n,i){const o=i.length,r=new Float64Array(o*4),s=new le;let a=0,h,l,u;for(let c=0;c<o;c++)h=i[c],h>0&&(l=c*4,u=Zr(t,n,a,h),r[l++]=u[0],r[l++]=u[1],r[l++]=u[2],r[l]=u[3],a+=h,s.mergeBounds(u));return{bb:r,bounds:s}}getBounds(){return this._allBounds?this._allBounds.clone():new le}forEachSegment(t){let n=0;for(let i=0,o=this.size();i<o;i++)n+=this.forEachArcSegment(i,t);return n}size(){return this._ii&&this._ii.length||0}forEachArcSegment(t,n){const i=t>=0,o=i?t:~t,r=this.getRetainedInterval(),s=this._nn[o],a=i?1:-1;let h=i?this._ii[o]:this._ii[o]+s-1,l=h,u=0;for(let c=1;c<s;c++)l+=a,(r===0||this._zz[l]>=r)&&(n(h,l,this._xx,this._yy),h=l,u++);return u}getRetainedInterval(){return this._zlimit}getVertexData(){return{xx:this._xx,yy:this._yy,zz:this._zz,bb:this._bb,nn:this._nn,ii:this._ii}}getUint32Array(t){const n=t*4;return(!this.buf||this.buf.byteLength<n)&&(this.buf=new ArrayBuffer(n)),new Uint32Array(this.buf,0,t)}getAvgSegment2(){let t=0,n=0;const i=this.forEachSegment((o,r,s,a)=>{t+=Math.abs(s[o]-s[r]),n+=Math.abs(a[o]-a[r])});return[t/i||0,n/i||0]}calcSegmentIntersectionStripeCount(){const t=this.getBounds().height(),n=this.getAvgSegment2()[1];let i=1;return n>0&&t>0&&(i=Math.ceil(t/n/20)),i||1}findSegmentIntersections(){const t=this.getBounds(),n=t.ymin||0,i=(t.ymax||0)-n,o=this.calcSegmentIntersectionStripeCount(),r=new Uint32Array(o),s=o>1?g=>Math.floor((o-1)*(g-n)/i):()=>0;let a,h;this.forEachSegment((g,I,M,m)=>{let b=s(m[g]);const d=s(m[I]);for(;r[b]=r[b]+2,b!=d;)b+=d>b?1:-1});const l=this.getUint32Array(Cr(r));let u=0;const c=[];Dr(r,g=>{const I=u;u+=g,c.push(l.subarray(I,u))}),Yr(r,0),this.forEachSegment((g,I,M,m)=>{let b=s(m[g]);const d=s(m[I]);let v,w;for(;v=r[b],r[b]=v+2,w=c[b],w[v]=g,w[v+1]=I,b!=d;)b+=d>b?1:-1});const f=this.getVertexData(),p=[];let _;for(a=0;a<o;a++)if(f.xx&&f.yy)for(_=Fr(c[a],f.xx,f.yy),h=0;h<_.length;h++)p.push(_[h]);return Gn(p)}}function ze(...e){const t=e.join(" ");throw new Error(t)}function Ge(e){return e?Xr(e)?!0:Tr(e)?!1:e.length===0?!0:e.length>0:!1}function Tr(e){return e!=null&&e.toString===String.prototype.toString}function Xr(e){return Array.isArray(e)}function Cr(e,t){Ge(e)||ze("utils.sum() expects an array, received:",e);let n=0,i;for(let o=0,r=e.length;o<r;o++)i=e[o],i&&(n+=i);return n}function Dr(e,t,n){if(!Ge(e))throw new Error(`#forEach() takes an array-like argument. ${e}`);for(let i=0,o=e.length;i<o;i++)t.call(n,e[i],i)}function Yr(e,t){for(let n=0,i=e.length;n<i;n++)e[n]=t;return e}function Fr(e,t,n){const i=e.length-2,o=[];let r,s,a,h,l,u,c,f,p,_,g,I,M,m,b,d,v;for(Jr(t,e),d=0;d<i;){for(r=e[d],s=e[d+1],l=t[r],u=t[s],p=n[r],_=n[s],v=d;v<i&&(v+=2,a=e[v],c=t[a],!(u<c));){if(g=n[a],h=e[v+1],f=t[h],I=n[h],p>=g){if(p>I&&_>g&&_>I)continue}else if(p<I&&_<g&&_<I)continue;r==a||r==h||s==a||s==h||(M=Rr(l,p,u,_,c,g,f,I),M&&(m=[r,s],b=[a,h],o.push(Un(M,m,b,t,n)),M.length==4&&o.push(Un(M.slice(2),m,b,t,n))))}d+=2}return o}function Rr(e,t,n,i,o,r,s,a){const h=Lr(e,t,n,i,o,r,s,a);let l=null;return h&&(l=$r(e,t,n,i,o,r,s,a),l?Gr(e,t,n,i,o,r,s,a)&&(l=null):l=zr(e,t,n,i,o,r,s,a)),l}function Lr(e,t,n,i,o,r,s,a){return ce(e,t,n,i,o,r)*ce(e,t,n,i,s,a)<=0&&ce(o,r,s,a,e,t)*ce(o,r,s,a,n,i)<=0}function ce(e,t,n,i,o,r){return jn(e-o,t-r,n-o,i-r)}function jn(e,t,n,i){return e*i-t*n}function $r(e,t,n,i,o,r,s,a){let h=Me(e,t,n,i,o,r,s,a),l;return h&&(l=Vr(h[0],h[1],e,t,n,i,o,r,s,a),l==1?h=Me(n,i,e,t,o,r,s,a):l==2?h=Me(o,r,s,a,e,t,n,i):l==3&&(h=Me(s,a,o,r,e,t,n,i))),h&&Ur(h,e,t,n,i,o,r,s,a),h}function Me(e,t,n,i,o,r,s,a){const h=jn(n-e,i-t,s-o,a-r),l=1e-18;let u;if(h===0)return null;const c=ce(o,r,s,a,e,t)/h;return h<=l&&h>=-l?u=jr(e,t,n,i,o,r,s,a):u=[e+c*(n-e),t+c*(i-t)],u}function jr(e,t,n,i,o,r,s,a){let h=null;return!Ct(e,o,s)&&!Ct(t,r,a)?h=[e,t]:!Ct(n,o,s)&&!Ct(i,r,a)?h=[n,i]:!Ct(o,e,n)&&!Ct(r,t,i)?h=[o,r]:!Ct(s,e,n)&&!Ct(a,t,i)&&(h=[s,a]),h}function Ct(e,t,n){let i;return t<n?i=e<t||e>n:t>n?i=e>t||e<n:i=e!=t,i}function Vr(e,t,...n){let i=-1,o=1/0,r;for(let s=0,a=0,h=n.length;a<h;s++,a+=2)r=qr(e,t,n[a],n[a+1]),r<o&&(o=r,i=s);return i}function qr(e,t,n,i){const o=e-n,r=t-i;return o*o+r*r}function Ur(e,t,n,i,o,r,s,a,h){let l=e[0],u=e[1];l=Se(l,t,i),l=Se(l,r,a),u=Se(u,n,o),u=Se(u,s,h),e[0]=l,e[1]=u}function Se(e,t,n){let i;return Ct(e,t,n)&&(i=Math.abs(e-t)<Math.abs(e-n)?t:n,e=i),e}function zr(e,t,n,i,o,r,s,a){const h=Math.min(e,n,o,s),l=Math.max(e,n,o,s),u=Math.min(t,i,r,a),c=Math.max(t,i,r,a),f=c-u>l-h;let p=[];return(f?$t(t,u,c):$t(e,h,l))&&p.push(e,t),(f?$t(i,u,c):$t(n,h,l))&&p.push(n,i),(f?$t(r,u,c):$t(o,h,l))&&p.push(o,r),(f?$t(a,u,c):$t(s,h,l))&&p.push(s,a),(p.length!=2&&p.length!=4||p.length==4&&p[0]==p[2]&&p[1]==p[3])&&(p=null),p}function Gr(e,t,n,i,o,r,s,a){return e==o&&t==r||e==s&&t==a||n==o&&i==r||n==s&&i==a}function $t(e,t,n){return e>t&&e<n}function Jr(e,t){Kr(e,t),Vn(e,t,0,t.length-2)}function Kr(e,t){for(let n=0,i=t.length;n<i;n+=2)e[t[n]]>e[t[n+1]]&&Qr(t,n,n+1)}function Qr(e,t,n){const i=e[t];e[t]=e[n],e[n]=i}function Vn(e,t,n,i){let o=n,r=i,s,a;for(;o<i;){for(s=e[t[n+i>>2<<1]];o<=r;){for(;e[t[o]]<s;)o+=2;for(;e[t[r]]>s;)r-=2;o<=r&&(a=t[o],t[o]=t[r],t[r]=a,a=t[o+1],t[o+1]=t[r+1],t[r+1]=a,o+=2,r-=2)}if(r-n<40?qn(e,t,n,r):Vn(e,t,n,r),i-o<40){qn(e,t,o,i);return}n=o,r=i}}function qn(e,t,n,i){let o,r;for(let s=n+2;s<=i;s+=2){o=t[s],r=t[s+1];let a;for(a=s-2;a>=n&&e[o]<e[t[a]];a-=2)t[a+2]=t[a],t[a+3]=t[a+1];t[a+2]=o,t[a+3]=r}}function Un(e,t,n,i,o){const r=e[0],s=e[1];t=zn(r,s,t[0],t[1],i,o),n=zn(r,s,n[0],n[1],i,o);const a=t[0]<n[0]?t:n,h=a==t?n:t;return{x:r,y:s,a,b:h}}function zn(e,t,n,i,o,r){let s=n<i?n:i,a=s===n?i:n;return o[s]==e&&r[s]==t?a=s:o[a]==e&&r[a]==t&&(s=a),[s,a]}function Gn(e){const t={};return e.filter(n=>{const i=Hr(n);return i in t?!1:(t[i]=!0,!0)})}function Hr(e){return`${e.a.join(",")};${e.b.join(",")}`}class Wr{_i=0;_n=0;_inc=1;_xx;_yy;i=0;x=0;y=0;constructor(t,n){this._xx=t,this._yy=n}}function Zr(e,t,n,i){let o=n|0;const r=isNaN(i)?e.length-o:i+o;let s,a,h,l,u,c;if(r>0)h=u=e[o],l=c=t[o];else return[void 0,void 0,void 0,void 0];for(o++;o<r;o++)s=e[o],a=t[o],s<h&&(h=s),s>u&&(u=s),a<l&&(l=a),a>c&&(c=a);return[h,l,u,c]}class le{xmin;ymin;xmax;ymax;constructor(...t){t.length>0&&this.setBounds(t)}cloneBounds(){return this.clone()}clone(){return new le(this.xmin,this.ymin,this.xmax,this.ymax)}width(){return this.xmax-this.xmin||0}height(){return this.ymax-this.ymin||0}setBounds(t,n,i,o){let r,s,a,h;if(arguments.length==1)if(Ge(t)){const l=t;r=l[0],s=l[1],a=l[2],h=l[3]}else{const l=t;r=l.xmin,s=l.ymin,a=l.xmax,h=l.ymax}else r=t,s=n,a=i,h=o;return this.xmin=r,this.ymin=s,this.xmax=a,this.ymax=h,(r>a||s>h)&&this.update(),this}update(){let t;this.xmin>this.xmax&&(t=this.xmin,this.xmin=this.xmax,this.xmax=t),this.ymin>this.ymax&&(t=this.ymin,this.ymin=this.ymax,this.ymax=t)}mergeBounds(t,...n){let i,o,r,s;return t instanceof le?(i=t.xmin,o=t.ymin,r=t.xmax,s=t.ymax):n.length==3?(i=t,o=n[0],r=n[1],s=n[2]):t.length==4?(i=t[0],o=t[1],r=t[2],s=t[3]):ze("Bounds#mergeBounds() invalid argument:",t),this.xmin===void 0?this.setBounds(i,o,r,s):(i<this.xmin&&(this.xmin=i),o<this.ymin&&(this.ymin=o),r>this.xmax&&(this.xmax=r),s>this.ymax&&(this.ymax=s)),this}}function ke(e){const t=["a","b","c"].map(n=>e.properties[n].index);return[[0,1],[0,2],[1,2],[0,1,2]].map(n=>n.map(i=>t[i]).sort().join("-")).sort()}function Je(e,t,n){const i=ke(t.forw),o=ke(t.bakw);if(JSON.stringify(i)!=JSON.stringify(o))throw`${JSON.stringify(t,null,2)}
|
|
2
2
|
${JSON.stringify(i)}
|
|
3
|
-
${JSON.stringify(o)}`;for(let r=0;r<i.length;r++){const s=i[r];
|
|
3
|
+
${JSON.stringify(o)}`;for(let r=0;r<i.length;r++){const s=i[r];e[s]||(e[s]=[]),e[s].push(t)}n&&(n.forw.features.push(t.forw),n.bakw.features.push(t.bakw))}function Jn(e,t,n){const i=ke(t.forw),o=ke(t.bakw);if(JSON.stringify(i)!=JSON.stringify(o))throw`${JSON.stringify(t,null,2)}
|
|
4
4
|
${JSON.stringify(i)}
|
|
5
|
-
${JSON.stringify(o)}`;if(i.forEach(r=>{const s=n[r];if(!s)return;const a=s.filter(c=>c!==t);a.length===0?delete n[r]:n[r]=a}),e){const r=(s,a)=>{!s||!a||(s.features=s.features.filter(c=>c!==a))};r(e.forw,t.forw),r(e.bakw,t.bakw)}}function oe(n,t,e){return Nt(n,{target:{geom:t,index:e}})}function se(n){return Nt(n.properties.target.geom,{target:{geom:n.geometry.coordinates,index:n.properties.target.index}})}function Ve(n,t){const e=n.length,i=t.geometry.coordinates;return Array.from({length:e},(o,r)=>r).map(o=>{const r=(o+1)%e,s=n[o],a=n[r],c=s.geometry.coordinates,f=Math.atan2(c[0]-i[0],c[1]-i[1]),l=[t,s,a,t].map(p=>p.geometry.coordinates),h={a:{geom:t.properties.target.geom,index:t.properties.target.index},b:{geom:s.properties.target.geom,index:s.properties.target.index},c:{geom:a.properties.target.geom,index:a.properties.target.index}},u=_t([Jt([l],h)]);return[f,u]}).reduce((o,r)=>(o[0].push(r[0]),o[1].push(r[1]),o),[[],[]])}function jr(n){const{tins:t,targets:e,includeReciprocals:i,numBoundaryVertices:o=4}=n,r={};e.forEach(a=>{const c=t[a];if(!c||!c.features)return;r[a]={};const f={};c.features.forEach(l=>{const h=["a","b","c"];for(let u=0;u<3;u++){const p=(u+1)%3,x=h[u],y=h[p],k=l.properties[x].index,S=l.properties[y].index,g=[k,S].sort().join("-");if(f[g])continue;f[g]=!0;const v=l.geometry.coordinates[0][u],d=l.geometry.coordinates[0][p],b=l.properties[x].geom,m=l.properties[y].geom,A=Math.sqrt(Math.pow(b[0]-m[0],2)+Math.pow(b[1]-m[1],2))/Math.sqrt(Math.pow(v[0]-d[0],2)+Math.pow(v[1]-d[1],2)),B=r[a];B[`${k}:${g}`]=A,B[`${S}:${g}`]=A}})});const s={};return i&&(s.bakw={}),e.forEach(a=>{const c=r[a];if(s[a]={},!c)return;const f={};Object.keys(c).forEach(h=>{const[u]=h.split(":");f[u]||(f[u]=[]),f[u].push(c[h])}),Object.keys(f).forEach(h=>{const u=f[h],p=u.reduce((x,y)=>x+y,0)/u.length;s[a][h]=p,i&&s.bakw&&(s.bakw[h]=1/p)});let l=0;for(let h=0;h<o;h++){const u=`b${h}`,p=s[a][u]||0;l+=p}s[a].c=l/o,i&&s.bakw&&(s.bakw.c=1/s[a].c)}),s}function xe(n,t=1e-6){const[e,i]=n[0],[o,r]=n[1],[s,a]=n[2];return Math.abs((o-e)*(a-i)-(s-e)*(r-i))<t}function $r(n,t){const e=n.split("-");if(e.length!==2||!e.every(r=>/^-?\d+$/.test(r)))return!1;const[i,o]=e.map(r=>parseInt(r,10)).sort((r,s)=>r-s);return t.some(r=>{if(r.length!==2)return!1;const s=r.map(c=>parseInt(`${c}`,10));if(s.some(c=>Number.isNaN(c)))return!1;const a=s.sort((c,f)=>c-f);return a[0]===i&&a[1]===o})}function ae(n){return["a","b","c"].map((t,e)=>({prop:n.properties[t],geom:n.geometry.coordinates[0][e]}))}const qr=10;function Vr(n,t,e,i,o,r){if(!n&&!t)return!1;const s=n?0:1,a=1-s,c=e[s],f=e[a];if(!c||!f)return!1;const l=bt(f.geom);let h=!1,u=!1;for(let p=0;p<=1;p++){const x=i[p];if(!x)continue;const y=[String(x.prop.index),String(c.prop.index)].sort().join("-"),k=o[y];if(!k||k.length<2)continue;const S=k.find(N=>N.bakw!==r[s].bakw);if(!S)continue;const v=ae(S.bakw).find(N=>String(N.prop.index)!==String(x.prop.index)&&String(N.prop.index)!==String(c.prop.index));if(!v)continue;h=!0;const d=bt(v.geom),b=bt(x.geom),m=bt(c.geom),A=m[0]-b[0],B=m[1]-b[1],P=A*(l[1]-b[1])-B*(l[0]-b[0]),I=A*(d[1]-b[1])-B*(d[0]-b[0]);if(P*I>0){u=!0;break}}return h&&!u}function Ur(n,t,e,i){if(!n&&!t)return!1;if(e[0]&&e[1]&&i[0]&&i[1]){const o=i.map(l=>bt(l.geom)),r=e.map(l=>bt(l.geom)),s=o[1][0]-o[0][0],a=o[1][1]-o[0][1],c=s*(r[0][1]-o[0][1])-a*(r[0][0]-o[0][0]),f=s*(r[1][1]-o[0][1])-a*(r[1][0]-o[0][0]);return c*f<0}return!1}function zr(n,t,e){const i=new Set;let o=!1;for(let r=0;r<qr;r++){let s=!1;for(const a of Object.keys(t)){if(i.has(a))continue;i.add(a);const c=t[a];if(!c||c.length<2)continue;const f=a.split("-");if(f.length!==2||$r(a,e))continue;const l=ae(c[0].bakw),h=ae(c[1].bakw),u=ae(c[0].forw),p=ae(c[1].forw),x=f.map(O=>l.find(D=>`${D.prop.index}`===O)||h.find(D=>`${D.prop.index}`===O)),y=f.map(O=>u.find(D=>`${D.prop.index}`===O)||p.find(D=>`${D.prop.index}`===O));if(x.some(O=>!O)||y.some(O=>!O))continue;const k=[l,h].map(O=>O.find(D=>!f.includes(`${D.prop.index}`))),S=[u,p].map(O=>O.find(D=>!f.includes(`${D.prop.index}`)));if(k.some(O=>!O)||S.some(O=>!O))continue;const g=c[0].bakw.geometry.coordinates[0].slice(0,3).map(O=>bt(O)),v=c[1].bakw.geometry.coordinates[0].slice(0,3).map(O=>bt(O)),d=c[0].forw.geometry.coordinates[0].slice(0,3).map(O=>bt(O)),b=c[1].forw.geometry.coordinates[0].slice(0,3).map(O=>bt(O)),m=xe(g),A=xe(v),B=xe(d),P=xe(b),I=Vr(m,A,k,x,t,c),N=Ur(B,P,k,x);if(!(I||N||jn(bt(k[0].geom),v)||jn(bt(k[1].geom),g)))continue;const F=y.map(O=>bt(O.geom)),w=S.map(O=>bt(O.geom)),E=Wr([...F,...w]),M=Gr(E),T=$n(F[0],F[1],w[0])+$n(F[0],F[1],w[1]);Ue(M,T)&&(Ln(t,c[0],n),Ln(t,c[1],n),x.forEach(O=>{if(!O)return;const D=[O.geom,k[0].geom,k[1].geom,O.geom],_={a:O.prop,b:k[0].prop,c:k[1].prop},C=Jt([D],_),R=_n(C);qe(t,{forw:R,bakw:C},n)}),s=!0,o=!0)}if(!s)break}return o}function bt(n){return[n[0],n[1]]}function jn(n,t){const[e,i]=t[0],[o,r]=t[1],[s,a]=t[2],c=s-e,f=a-i,l=o-e,h=r-i,u=n[0]-e,p=n[1]-i,x=c*c+f*f,y=c*l+f*h,k=c*u+f*p,S=l*l+h*h,g=l*u+h*p,v=x*S-y*y;if(v===0)return!1;const d=1/v,b=(S*k-y*g)*d,m=(x*g-y*k)*d,A=1e-9;return b>=-A&&m>=-A&&b+m<=1+A}function Wr(n){const t=n.map(s=>s.slice()).filter((s,a,c)=>c.findIndex(f=>Ue(f[0],s[0])&&Ue(f[1],s[1]))===a);if(t.length<=1)return t;const e=t.sort((s,a)=>s[0]===a[0]?s[1]-a[1]:s[0]-a[0]),i=(s,a,c)=>(a[0]-s[0])*(c[1]-s[1])-(a[1]-s[1])*(c[0]-s[0]),o=[];for(const s of e){for(;o.length>=2&&i(o[o.length-2],o[o.length-1],s)<=0;)o.pop();o.push(s)}const r=[];for(let s=e.length-1;s>=0;s--){const a=e[s];for(;r.length>=2&&i(r[r.length-2],r[r.length-1],a)<=0;)r.pop();r.push(a)}return r.pop(),o.pop(),o.concat(r)}function Gr(n){if(n.length<3)return 0;let t=0;for(let e=0;e<n.length;e++){const[i,o]=n[e],[r,s]=n[(e+1)%n.length];t+=i*s-r*o}return Math.abs(t)/2}function $n(n,t,e){return Math.abs((n[0]*(t[1]-e[1])+t[0]*(e[1]-n[1])+e[0]*(n[1]-t[1]))/2)}function Ue(n,t,e=1e-9){return Math.abs(n-t)<=e}const qn=3;class ct extends Mt{importance;priority;pointsSet;useV2Algorithm;constructor(t={}){super(),t.bounds?this.setBounds(t.bounds):(this.setWh(t.wh),this.vertexMode=t.vertexMode||ct.VERTEX_PLAIN),this.strictMode=t.strictMode||ct.MODE_AUTO,this.yaxisMode=t.yaxisMode||ct.YAXIS_INVERT,this.importance=t.importance||0,this.priority=t.priority||0,this.stateFull=t.stateFull||!1,this.useV2Algorithm=t.useV2Algorithm??!1,t.points&&this.setPoints(t.points),t.edges&&this.setEdges(t.edges)}getFormatVersion(){return this.useV2Algorithm?Ye:qn}setPoints(t){this.yaxisMode===ct.YAXIS_FOLLOW&&(t=t.map(e=>[e[0],[e[1][0],-1*e[1][1]]])),this.points=t,this.tins=void 0,this.indexedTins=void 0}setEdges(t=[]){this.edges=Sn(t),this.edgeNodes=void 0,this.tins=void 0,this.indexedTins=void 0}setBounds(t){this.bounds=t;let e=t[0][0],i=e,o=t[0][1],r=o;const s=[t[0]];for(let a=1;a<t.length;a++){const c=t[a];c[0]<e&&(e=c[0]),c[0]>i&&(i=c[0]),c[1]<o&&(o=c[1]),c[1]>r&&(r=c[1]),s.push(c)}s.push(t[0]),this.boundsPolygon=Jt([s]),this.xy=[e,o],this.wh=[i-e,r-o],this.vertexMode=ct.VERTEX_PLAIN,this.tins=void 0,this.indexedTins=void 0}getCompiled(){const t={};t.version=this.useV2Algorithm?Ye:qn,t.points=this.points,t.weight_buffer=this.pointsWeightBuffer??{},t.centroid_point=[this.centroid.forw.geometry.coordinates,this.centroid.forw.properties.target.geom],t.vertices_params=[this.vertices_params.forw[0],this.vertices_params.bakw[0]],t.vertices_points=[];const e=this.vertices_params.forw[1];if(e)for(let i=0;i<e.length;i++){const o=e[i].features[0],r=o.geometry.coordinates[0][1],s=o.properties.b.geom;t.vertices_points[i]=[r,s]}return t.strict_status=this.strict_status,t.tins_points=[[]],this.tins.forw.features.map(i=>{t.tins_points[0].push(["a","b","c"].map(o=>i.properties[o].index))}),this.strict_status===ct.STATUS_LOOSE?(t.tins_points[1]=[],this.tins.bakw.features.map(i=>{t.tins_points[1].push(["a","b","c"].map(o=>i.properties[o].index))})):this.strict_status===ct.STATUS_ERROR&&this.kinks?.bakw&&(t.kinks_points=this.kinks.bakw.features.map(i=>i.geometry.coordinates)),t.yaxisMode=this.yaxisMode,t.vertexMode=this.vertexMode,t.strictMode=this.strictMode,this.bounds?(t.bounds=this.bounds,t.boundsPolygon=this.boundsPolygon,this.useV2Algorithm&&(t.xy=this.xy,t.wh=this.wh)):t.wh=this.wh,t.edges=this.edges??[],t.edgeNodes=this.edgeNodes??[],t}setCompiled(t){super.setCompiled(t)}setWh(t){this.wh=t||[100,100],this.xy=[0,0],this.bounds=void 0,this.boundsPolygon=void 0,this.tins=void 0,this.indexedTins=void 0}setVertexMode(t){this.vertexMode=t,this.tins=void 0,this.indexedTins=void 0}setStrictMode(t){this.strictMode=t,this.tins=void 0,this.indexedTins=void 0}calcurateStrictTin(){const t=this.tins.forw.features.map(o=>_n(o));this.tins.bakw=_t(t);const e={};this.tins.forw.features.forEach((o,r)=>{const s=this.tins.bakw.features[r];qe(e,{forw:o,bakw:s})}),zr(this.tins,e,this.pointsSet?.edges||[]);const i=["forw","bakw"].map(o=>{const r=this.tins[o].features.map(s=>s.geometry.coordinates[0]);return Nn(r)});i[0].length===0&&i[1].length===0?(this.strict_status=ct.STATUS_STRICT,delete this.kinks):(this.strict_status=ct.STATUS_ERROR,this.kinks={forw:_t(i[0]),bakw:_t(i[1])})}generatePointsSet(){const t={forw:[],bakw:[]};for(let o=0;o<this.points.length;o++){const r=this.points[o][0],s=this.points[o][1],a=oe(r,s,o);t.forw.push(a),t.bakw.push(se(a))}const e=[];let i=0;this.edgeNodes=[],this.edges||(this.edges=[]);for(let o=0;o<this.edges.length;o++){const r=this.edges[o][2],s=Object.assign([],this.edges[o][0]),a=Object.assign([],this.edges[o][1]);if(s.length===0&&a.length===0){e.push(r);continue}s.unshift(this.points[r[0]][0]),s.push(this.points[r[1]][0]),a.unshift(this.points[r[0]][1]),a.push(this.points[r[1]][1]);const c=[s,a].map(f=>{const l=f.map((u,p,x)=>{if(p===0)return 0;const y=x[p-1];return Math.sqrt(Math.pow(u[0]-y[0],2)+Math.pow(u[1]-y[1],2))}),h=l.reduce((u,p,x)=>x===0?[0]:(u.push(u[x-1]+p),u),[]);return h.map((u,p,x)=>{const y=u/x[x.length-1];return[f[p],l[p],h[p],y]})});c.map((f,l)=>{const h=c[l?0:1];return f.filter((u,p)=>!(p===0||p===f.length-1||u[4]==="handled")).flatMap(u=>{const p=u[0],x=u[3],y=h.reduce((k,S,g,v)=>{if(k)return k;const d=v[g+1];if(S[3]===x)return S[4]="handled",[S];if(S[3]<x&&d&&d[3]>x)return[S,d]},void 0);if(y&&y.length===1)return l===0?[[p,y[0][0],x]]:[[y[0][0],p,x]];if(y&&y.length===2){const k=y[0],S=y[1],g=(x-k[3])/(S[3]-k[3]),v=[(S[0][0]-k[0][0])*g+k[0][0],(S[0][1]-k[0][1])*g+k[0][1]];return l===0?[[p,v,x]]:[[v,p,x]]}return[]})}).reduce((f,l)=>f.concat(l),[]).sort((f,l)=>f[2]<l[2]?-1:1).map((f,l,h)=>{this.edgeNodes[i]=[f[0],f[1]];const u=oe(f[0],f[1],`e${i}`);i++,t.forw.push(u),t.bakw.push(se(u)),l===0?e.push([r[0],t.forw.length-1]):e.push([t.forw.length-2,t.forw.length-1]),l===h.length-1&&e.push([t.forw.length-1,r[1]])})}return{forw:t.forw,bakw:t.bakw,edges:e}}validateAndPrepareInputs(){const t=this.xy[0]-.05*this.wh[0],e=this.xy[0]+1.05*this.wh[0],i=this.xy[1]-.05*this.wh[1],o=this.xy[1]+1.05*this.wh[1];if(this.bounds&&!this.boundsPolygon)throw new Error("Internal error: bounds is set but boundsPolygon is missing");const r=this.bounds?this.boundsPolygon:void 0;if(!this.points.reduce((c,f)=>c&&(r?Be(f[0],r):f[0][0]>=t&&f[0][0]<=e&&f[0][1]>=i&&f[0][1]<=o),!0))throw"SOME POINTS OUTSIDE";let a=[];return this.wh&&(a=[[t,i],[e,i],[t,o],[e,o]]),{pointsSet:this.generatePointsSet(),bbox:a,minx:t,maxx:e,miny:i,maxy:o}}computeGcpBbox(){let t=1/0,e=-1/0,i=1/0,o=-1/0;for(const a of this.points){const c=a[0][0],f=a[0][1];c<t&&(t=c),c>e&&(e=c),f<i&&(i=f),f>o&&(o=f)}const r=e-t,s=o-i;return{minx:t-.05*r,maxx:e+.05*r,miny:i-.05*s,maxy:o+.05*s}}updateTin(){let t=this.strictMode;t!==ct.MODE_STRICT&&t!==ct.MODE_LOOSE&&(t=ct.MODE_AUTO);const e=!this.useV2Algorithm;let i,o,r,s,a;if(e){if(this.bounds){const I=this.boundsPolygon;if(!I)throw new Error("Internal error: bounds is set but boundsPolygon is missing");if(!this.points.every(X=>Be(X[0],I)))throw"SOME POINTS OUTSIDE"}i=this.generatePointsSet(),{minx:o,maxx:r,miny:s,maxy:a}=this.computeGcpBbox()}else{const I=this.validateAndPrepareInputs();i=I.pointsSet,o=I.minx,r=I.maxx,s=I.miny,a=I.maxy}const c={forw:_t(i.forw),bakw:_t(i.bakw)},f=ne(c.forw,i.edges,"target"),l=ne(c.bakw,i.edges,"target");if(f.features.length===0||l.features.length===0)throw"TOO LINEAR1";const h=mi(c.forw),u=ln(c.forw);if(!u)throw"TOO LINEAR2";const p={},x=u.geometry.coordinates[0];let y;try{y=x.map(I=>({forw:I,bakw:te(Nt(I),f)})),y.forEach(I=>{p[`${I.forw[0]}:${I.forw[1]}`]=I})}catch{throw"TOO LINEAR2"}const k=ln(c.bakw);if(!k)throw"TOO LINEAR2";const S=k.geometry.coordinates[0];try{y=S.map(I=>({bakw:I,forw:te(Nt(I),l)})),y.forEach(I=>{p[`${I.forw[0]}:${I.forw[1]}`]=I})}catch{throw"TOO LINEAR2"}let g;if(e){const I=h.geometry.coordinates,N=f.features.find(X=>Be(Nt(I),X));if(N){const X=N.geometry.coordinates[0],F=N.properties.a.geom,w=N.properties.b.geom,E=N.properties.c.geom;g={forw:[(X[0][0]+X[1][0]+X[2][0])/3,(X[0][1]+X[1][1]+X[2][1])/3],bakw:[(F[0]+w[0]+E[0])/3,(F[1]+w[1]+E[1])/3]}}else g={forw:I,bakw:te(h,f)}}else g={forw:h.geometry.coordinates,bakw:te(h,f)};const v=oe(g.forw,g.bakw,"c");this.centroid={forw:v,bakw:se(v)};const d=[...this.points.map(I=>({forw:I[0],bakw:I[1]})),...(this.edgeNodes??[]).map(I=>({forw:I[0],bakw:I[1]}))],b={convexBuf:p,centroid:g,allGcps:d,minx:o,maxx:r,miny:s,maxy:a},m=this.vertexMode===ct.VERTEX_BIRDEYE?yr(b,e):wr(b,e),A={forw:[],bakw:[]};for(let I=0;I<m.length;I++){const N=m[I].forw,X=m[I].bakw,F=oe(N,X,`b${I}`),w=se(F);i.forw.push(F),i.bakw.push(w),A.forw.push(F),A.bakw.push(w)}this.pointsSet={forw:_t(i.forw),bakw:_t(i.bakw),edges:i.edges},this.tins={forw:xn(ne(this.pointsSet.forw,i.edges,"target"))},(t===ct.MODE_STRICT||t===ct.MODE_AUTO)&&this.calcurateStrictTin(),(t===ct.MODE_LOOSE||t===ct.MODE_AUTO&&this.strict_status===ct.STATUS_ERROR)&&(this.tins.bakw=xn(ne(this.pointsSet.bakw,i.edges,"target")),delete this.kinks,this.strict_status=ct.STATUS_LOOSE),this.vertices_params={forw:Ve(A.forw,this.centroid.forw),bakw:Ve(A.bakw,this.centroid.bakw)},this.addIndexedTin();const B=["forw"];this.strict_status===ct.STATUS_LOOSE&&B.push("bakw");const P=this.strict_status===ct.STATUS_STRICT;this.pointsWeightBuffer=jr({tins:this.tins,targets:B,includeReciprocals:P,numBoundaryVertices:m.length})}async updateTinAsync(){this.updateTin()}}yt.Tin=ct,yt.constrainedTin=ne,yt.counterPoint=se,yt.createPoint=oe,yt.default=ct,yt.findIntersections=Nn,yt.format_version=Ye,yt.insertSearchIndex=qe,yt.vertexCalc=Ve,Object.defineProperties(yt,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
|
|
5
|
+
${JSON.stringify(o)}`;if(i.forEach(r=>{const s=e[r];if(!s)return;const a=s.filter(h=>h!==t);a.length===0?delete e[r]:e[r]=a}),n){const r=(s,a)=>{!s||!a||(s.features=s.features.filter(h=>h!==a))};r(n.forw,t.forw),r(n.bakw,t.bakw)}}function he(e,t,n){return Dt(e,{target:{geom:t,index:n}})}function fe(e){return Dt(e.properties.target.geom,{target:{geom:e.geometry.coordinates,index:e.properties.target.index}})}function Ke(e,t){const n=e.length,i=t.geometry.coordinates;return Array.from({length:n},(o,r)=>r).map(o=>{const r=(o+1)%n,s=e[o],a=e[r],h=s.geometry.coordinates,l=Math.atan2(h[0]-i[0],h[1]-i[1]),u=[t,s,a,t].map(p=>p.geometry.coordinates),c={a:{geom:t.properties.target.geom,index:t.properties.target.index},b:{geom:s.properties.target.geom,index:s.properties.target.index},c:{geom:a.properties.target.geom,index:a.properties.target.index}},f=St([Zt([u],c)]);return[l,f]}).reduce((o,r)=>(o[0].push(r[0]),o[1].push(r[1]),o),[[],[]])}function Ee(e,t=1e-6){const[n,i]=e[0],[o,r]=e[1],[s,a]=e[2];return Math.abs((o-n)*(a-i)-(s-n)*(r-i))<t}function to(e,t){const n=new Set;return e.forEach(i=>{if(i.length!==2)return;const o=i.map(r=>`${t?.[r]??r}`);n.add(o.sort().join("-"))}),n}function ue(e){return["a","b","c"].map((t,n)=>({prop:e.properties[t],geom:e.geometry.coordinates[0][n]}))}const eo=10;function no(e,t,n,i,o,r){if(!e&&!t)return!1;const s=e?0:1,a=1-s,h=n[s],l=n[a];if(!h||!l)return!1;const u=_t(l.geom);let c=!1,f=!1;for(let p=0;p<=1;p++){const _=i[p];if(!_)continue;const g=[String(_.prop.index),String(h.prop.index)].sort().join("-"),I=o[g];if(!I||I.length<2)continue;const M=I.find(B=>B.bakw!==r[s].bakw);if(!M)continue;const b=ue(M.bakw).find(B=>String(B.prop.index)!==String(_.prop.index)&&String(B.prop.index)!==String(h.prop.index));if(!b)continue;c=!0;const d=_t(b.geom),v=_t(_.geom),w=_t(h.geom),A=w[0]-v[0],S=w[1]-v[1],E=A*(u[1]-v[1])-S*(u[0]-v[0]),O=A*(d[1]-v[1])-S*(d[0]-v[0]);if(E*O>0){f=!0;break}}return c&&!f}function io(e,t,n,i){if(!e&&!t)return!1;if(n[0]&&n[1]&&i[0]&&i[1]){const o=i.map(u=>_t(u.geom)),r=n.map(u=>_t(u.geom)),s=o[1][0]-o[0][0],a=o[1][1]-o[0][1],h=s*(r[0][1]-o[0][1])-a*(r[0][0]-o[0][0]),l=s*(r[1][1]-o[0][1])-a*(r[1][0]-o[0][0]);return h*l<0}return!1}function ro(e,t,n,i){const o=to(n,i),r=new Set;let s=!1;for(let a=0;a<eo;a++){let h=!1;for(const l of Object.keys(t)){if(r.has(l))continue;r.add(l);const u=t[l];if(!u||u.length<2)continue;const c=l.split("-");if(c.length!==2||o.has(l))continue;const f=ue(u[0].bakw),p=ue(u[1].bakw),_=ue(u[0].forw),g=ue(u[1].forw),I=c.map(x=>f.find(N=>`${N.prop.index}`===x)||p.find(N=>`${N.prop.index}`===x)),M=c.map(x=>_.find(N=>`${N.prop.index}`===x)||g.find(N=>`${N.prop.index}`===x));if(I.some(x=>!x)||M.some(x=>!x))continue;const m=[f,p].map(x=>x.find(N=>!c.includes(`${N.prop.index}`))),b=[_,g].map(x=>x.find(N=>!c.includes(`${N.prop.index}`)));if(m.some(x=>!x)||b.some(x=>!x))continue;const d=u[0].bakw.geometry.coordinates[0].slice(0,3).map(x=>_t(x)),v=u[1].bakw.geometry.coordinates[0].slice(0,3).map(x=>_t(x)),w=u[0].forw.geometry.coordinates[0].slice(0,3).map(x=>_t(x)),A=u[1].forw.geometry.coordinates[0].slice(0,3).map(x=>_t(x)),S=Ee(d),E=Ee(v),O=Ee(w),B=Ee(A),X=no(S,E,m,I,t,u),F=io(O,B,m,I);if(!(X||F||Kn(_t(m[0].geom),v)||Kn(_t(m[1].geom),d)))continue;const P=M.map(x=>_t(x.geom)),k=b.map(x=>_t(x.geom)),T=oo([...P,...k]),C=so(T),Y=Qn(P[0],P[1],k[0])+Qn(P[0],P[1],k[1]);Qe(C,Y)&&(Jn(t,u[0],e),Jn(t,u[1],e),I.forEach(x=>{if(!x)return;const N=[x.geom,m[0].geom,m[1].geom,x.geom],D={a:x.prop,b:m[0].prop,c:m[1].prop},R=Zt([N],D),$=Bn(R);Je(t,{forw:$,bakw:R},e)}),h=!0,s=!0)}if(!h)break}return s}function _t(e){return[e[0],e[1]]}function Kn(e,t){const[n,i]=t[0],[o,r]=t[1],[s,a]=t[2],h=s-n,l=a-i,u=o-n,c=r-i,f=e[0]-n,p=e[1]-i,_=h*h+l*l,g=h*u+l*c,I=h*f+l*p,M=u*u+c*c,m=u*f+c*p,b=_*M-g*g;if(b===0)return!1;const d=1/b,v=(M*I-g*m)*d,w=(_*m-g*I)*d,A=1e-9;return v>=-A&&w>=-A&&v+w<=1+A}function oo(e){const t=e.map(s=>s.slice()).filter((s,a,h)=>h.findIndex(l=>Qe(l[0],s[0])&&Qe(l[1],s[1]))===a);if(t.length<=1)return t;const n=t.sort((s,a)=>s[0]===a[0]?s[1]-a[1]:s[0]-a[0]),i=(s,a,h)=>(a[0]-s[0])*(h[1]-s[1])-(a[1]-s[1])*(h[0]-s[0]),o=[];for(const s of n){for(;o.length>=2&&i(o[o.length-2],o[o.length-1],s)<=0;)o.pop();o.push(s)}const r=[];for(let s=n.length-1;s>=0;s--){const a=n[s];for(;r.length>=2&&i(r[r.length-2],r[r.length-1],a)<=0;)r.pop();r.push(a)}return r.pop(),o.pop(),o.concat(r)}function so(e){if(e.length<3)return 0;let t=0;for(let n=0;n<e.length;n++){const[i,o]=e[n],[r,s]=e[(n+1)%e.length];t+=i*s-r*o}return Math.abs(t)/2}function Qn(e,t,n){return Math.abs((e[0]*(t[1]-n[1])+t[0]*(n[1]-e[1])+n[0]*(e[1]-t[1]))/2)}function Qe(e,t,n=1e-9){return Math.abs(e-t)<=n}const He=2.00704,Hn=3.00001;class lt extends kt{importance;priority;pointsSet;useV2Algorithm;constructor(t={}){super(),t.bounds?this.setBounds(t.bounds):(this.setWh(t.wh),this.vertexMode=t.vertexMode||lt.VERTEX_PLAIN),this.strictMode=t.strictMode||lt.MODE_AUTO,this.yaxisMode=t.yaxisMode||lt.YAXIS_INVERT,this.importance=t.importance||0,this.priority=t.priority||0,this.stateFull=t.stateFull||!1,this.useV2Algorithm=t.useV2Algorithm??!1,t.points&&this.setPoints(t.points),t.edges&&this.setEdges(t.edges)}getFormatVersion(){return this.useV2Algorithm?He:Hn}setPoints(t){this.yaxisMode===lt.YAXIS_FOLLOW&&(t=t.map(n=>[n[0],[n[1][0],-1*n[1][1]]])),this.points=t,this.tins=void 0,this.indexedTins=void 0}setEdges(t=[]){this.edges=Nn(t),this.edgeNodes=void 0,this.tins=void 0,this.indexedTins=void 0}setBounds(t){this.bounds=t;let n=t[0][0],i=n,o=t[0][1],r=o;const s=[t[0]];for(let a=1;a<t.length;a++){const h=t[a];h[0]<n&&(n=h[0]),h[0]>i&&(i=h[0]),h[1]<o&&(o=h[1]),h[1]>r&&(r=h[1]),s.push(h)}s.push(t[0]),this.boundsPolygon=Zt([s]),this.xy=[n,o],this.wh=[i-n,r-o],this.vertexMode=lt.VERTEX_PLAIN,this.tins=void 0,this.indexedTins=void 0}getCompiled(){const t={};t.version=this.useV2Algorithm?He:Hn,t.points=this.points,t.weight_buffer={},t.centroid_point=[this.centroid.forw.geometry.coordinates,this.centroid.forw.properties.target.geom],t.vertices_params=[this.vertices_params.forw[0],this.vertices_params.bakw[0]],t.vertices_points=[];const n=this.vertices_params.forw[1];if(n)for(let i=0;i<n.length;i++){const o=n[i].features[0],r=o.geometry.coordinates[0][1],s=o.properties.b.geom;t.vertices_points[i]=[r,s]}return t.strict_status=this.strict_status,t.tins_points=[[]],this.tins.forw.features.map(i=>{t.tins_points[0].push(["a","b","c"].map(o=>i.properties[o].index))}),this.strict_status===lt.STATUS_LOOSE?(t.tins_points[1]=[],this.tins.bakw.features.map(i=>{t.tins_points[1].push(["a","b","c"].map(o=>i.properties[o].index))})):this.strict_status===lt.STATUS_ERROR&&this.kinks?.bakw&&(t.kinks_points=this.kinks.bakw.features.map(i=>i.geometry.coordinates)),t.yaxisMode=this.yaxisMode,t.vertexMode=this.vertexMode,t.strictMode=this.strictMode,this.bounds?(t.bounds=this.bounds,t.boundsPolygon=this.boundsPolygon,this.useV2Algorithm&&(t.xy=this.xy,t.wh=this.wh)):t.wh=this.wh,t.edges=this.edges??[],t.edgeNodes=this.edgeNodes??[],t}setCompiled(t){super.setCompiled(t)}setWh(t){this.wh=t||[100,100],this.xy=[0,0],this.bounds=void 0,this.boundsPolygon=void 0,this.tins=void 0,this.indexedTins=void 0}setVertexMode(t){this.vertexMode=t,this.tins=void 0,this.indexedTins=void 0}setStrictMode(t){this.strictMode=t,this.tins=void 0,this.indexedTins=void 0}calculateStrictTin(){const t=this.tins.forw.features.map(r=>Bn(r));this.tins.bakw=St(t);const n={};this.tins.forw.features.forEach((r,s)=>{const a=this.tins.bakw.features[s];Je(n,{forw:r,bakw:a})});const i=(this.pointsSet?.forw.features??[]).map(r=>r.properties.target.index);ro(this.tins,n,this.pointsSet?.edges||[],i);const o=["forw","bakw"].map(r=>{const s=this.tins[r].features.map(a=>a.geometry.coordinates[0]);return $n(s)});o[0].length===0&&o[1].length===0?(this.strict_status=lt.STATUS_STRICT,delete this.kinks):(this.strict_status=lt.STATUS_ERROR,this.kinks={forw:St(o[0]),bakw:St(o[1])})}generatePointsSet(){const t={forw:[],bakw:[]};for(let o=0;o<this.points.length;o++){const r=this.points[o][0],s=this.points[o][1],a=he(r,s,o);t.forw.push(a),t.bakw.push(fe(a))}const n=[];let i=0;this.edgeNodes=[],this.edges||(this.edges=[]);for(let o=0;o<this.edges.length;o++){const r=this.edges[o][2],s=Object.assign([],this.edges[o][0]),a=Object.assign([],this.edges[o][1]);if(s.length===0&&a.length===0){n.push(r);continue}s.unshift(this.points[r[0]][0]),s.push(this.points[r[1]][0]),a.unshift(this.points[r[0]][1]),a.push(this.points[r[1]][1]);const h=[s,a].map(l=>{const u=l.map((f,p,_)=>{if(p===0)return 0;const g=_[p-1];return Math.sqrt(Math.pow(f[0]-g[0],2)+Math.pow(f[1]-g[1],2))}),c=u.reduce((f,p,_)=>_===0?[0]:(f.push(f[_-1]+p),f),[]);return c.map((f,p,_)=>{const g=f/_[_.length-1];return[l[p],u[p],c[p],g]})});h.map((l,u)=>{const c=h[u?0:1];return l.filter((f,p)=>!(p===0||p===l.length-1||f[4]==="handled")).flatMap(f=>{const p=f[0],_=f[3],g=c.reduce((I,M,m,b)=>{if(I)return I;const d=b[m+1];if(M[3]===_)return M[4]="handled",[M];if(M[3]<_&&d&&d[3]>_)return[M,d]},void 0);if(g&&g.length===1)return u===0?[[p,g[0][0],_]]:[[g[0][0],p,_]];if(g&&g.length===2){const I=g[0],M=g[1],m=(_-I[3])/(M[3]-I[3]),b=[(M[0][0]-I[0][0])*m+I[0][0],(M[0][1]-I[0][1])*m+I[0][1]];return u===0?[[p,b,_]]:[[b,p,_]]}return[]})}).reduce((l,u)=>l.concat(u),[]).sort((l,u)=>l[2]<u[2]?-1:1).map((l,u,c)=>{this.edgeNodes[i]=[l[0],l[1]];const f=he(l[0],l[1],`e${i}`);i++,t.forw.push(f),t.bakw.push(fe(f)),u===0?n.push([r[0],t.forw.length-1]):n.push([t.forw.length-2,t.forw.length-1]),u===c.length-1&&n.push([t.forw.length-1,r[1]])})}return{forw:t.forw,bakw:t.bakw,edges:n}}validateAndPrepareInputs(){const t=this.xy[0]-.05*this.wh[0],n=this.xy[0]+1.05*this.wh[0],i=this.xy[1]-.05*this.wh[1],o=this.xy[1]+1.05*this.wh[1];if(this.bounds&&!this.boundsPolygon)throw new Error("Internal error: bounds is set but boundsPolygon is missing");const r=this.bounds?this.boundsPolygon:void 0;if(!this.points.reduce((h,l)=>h&&(r?Ce(l[0],r):l[0][0]>=t&&l[0][0]<=n&&l[0][1]>=i&&l[0][1]<=o),!0))throw"SOME POINTS OUTSIDE";let a=[];return this.wh&&(a=[[t,i],[n,i],[t,o],[n,o]]),{pointsSet:this.generatePointsSet(),bbox:a,minx:t,maxx:n,miny:i,maxy:o}}computeGcpBbox(){let t=1/0,n=-1/0,i=1/0,o=-1/0;for(const a of this.points){const h=a[0][0],l=a[0][1];h<t&&(t=h),h>n&&(n=h),l<i&&(i=l),l>o&&(o=l)}const r=n-t,s=o-i;return{minx:t-.05*r,maxx:n+.05*r,miny:i-.05*s,maxy:o+.05*s}}updateTin(){let t=this.strictMode;t!==lt.MODE_STRICT&&t!==lt.MODE_LOOSE&&(t=lt.MODE_AUTO);const n=!this.useV2Algorithm;let i,o,r,s,a;if(n){if(this.bounds){const S=this.boundsPolygon;if(!S)throw new Error("Internal error: bounds is set but boundsPolygon is missing");if(!this.points.every(O=>Ce(O[0],S)))throw"SOME POINTS OUTSIDE"}i=this.generatePointsSet(),{minx:o,maxx:r,miny:s,maxy:a}=this.computeGcpBbox()}else{const S=this.validateAndPrepareInputs();i=S.pointsSet,o=S.minx,r=S.maxx,s=S.miny,a=S.maxy}const h={forw:St(i.forw),bakw:St(i.bakw)},l=ae(h.forw,i.edges,"target"),u=ae(h.bakw,i.edges,"target");if(l.features.length===0||u.features.length===0)throw"TOO LINEAR1";const c=Oi(h.forw),f=bn(h.forw);if(!f)throw"TOO LINEAR2";const p={},_=f.geometry.coordinates[0];let g;try{g=_.map(S=>({forw:S,bakw:oe(Dt(S),l)})),g.forEach(S=>{p[`${S.forw[0]}:${S.forw[1]}`]=S})}catch{throw"TOO LINEAR2"}const I=bn(h.bakw);if(!I)throw"TOO LINEAR2";const M=I.geometry.coordinates[0];try{g=M.map(S=>({bakw:S,forw:oe(Dt(S),u)})),g.forEach(S=>{p[`${S.forw[0]}:${S.forw[1]}`]=S})}catch{throw"TOO LINEAR2"}let m;if(n){const S=c.geometry.coordinates,E=l.features.find(O=>Ce(Dt(S),O));if(E){const O=E.geometry.coordinates[0],B=E.properties.a.geom,X=E.properties.b.geom,F=E.properties.c.geom;m={forw:[(O[0][0]+O[1][0]+O[2][0])/3,(O[0][1]+O[1][1]+O[2][1])/3],bakw:[(B[0]+X[0]+F[0])/3,(B[1]+X[1]+F[1])/3]}}else m={forw:S,bakw:oe(c,l)}}else m={forw:c.geometry.coordinates,bakw:oe(c,l)};const b=he(m.forw,m.bakw,"c");this.centroid={forw:b,bakw:fe(b)};const d=[...this.points.map(S=>({forw:S[0],bakw:S[1]})),...(this.edgeNodes??[]).map(S=>({forw:S[0],bakw:S[1]}))],v={convexBuf:p,centroid:m,allGcps:d,minx:o,maxx:r,miny:s,maxy:a},w=this.vertexMode===lt.VERTEX_BIRDEYE?Br(v,n):Or(v,n),A={forw:[],bakw:[]};for(let S=0;S<w.length;S++){const E=w[S].forw,O=w[S].bakw,B=he(E,O,`b${S}`),X=fe(B);i.forw.push(B),i.bakw.push(X),A.forw.push(B),A.bakw.push(X)}this.pointsSet={forw:St(i.forw),bakw:St(i.bakw),edges:i.edges},this.tins={forw:On(ae(this.pointsSet.forw,i.edges,"target"))},(t===lt.MODE_STRICT||t===lt.MODE_AUTO)&&this.calculateStrictTin(),(t===lt.MODE_LOOSE||t===lt.MODE_AUTO&&this.strict_status===lt.STATUS_ERROR)&&(this.tins.bakw=On(ae(this.pointsSet.bakw,i.edges,"target")),delete this.kinks,this.strict_status=lt.STATUS_LOOSE),this.vertices_params={forw:Ke(A.forw,this.centroid.forw),bakw:Ke(A.bakw,this.centroid.bakw)},this.addIndexedTin(),this.pointsWeightBuffer={}}async updateTinAsync(){this.updateTin()}}bt.Tin=lt,bt.constrainedTin=ae,bt.counterPoint=fe,bt.createPoint=he,bt.default=lt,bt.findIntersections=$n,bt.format_version=He,bt.insertSearchIndex=Je,bt.vertexCalc=Ke,Object.defineProperties(bt,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
|
package/dist/strict-overlap.d.ts
CHANGED
|
@@ -1,5 +1,26 @@
|
|
|
1
1
|
import { TinsBD } from '@maplat/transform';
|
|
2
2
|
import { SearchIndex } from "./searchutils";
|
|
3
3
|
type ConstraintEdges = number[][];
|
|
4
|
-
|
|
4
|
+
/**
|
|
5
|
+
* pointsSet 内の配列位置 → 頂点 index(properties.target.index)の対応表。
|
|
6
|
+
* GCP は数値、エッジ中間ノードは "e12"、境界頂点は "b3" のような文字列。
|
|
7
|
+
*/
|
|
8
|
+
export type PointIndices = readonly (number | string)[];
|
|
9
|
+
/**
|
|
10
|
+
* 制約エッジを searchIndex のキー形式へ正規化した集合を作る。
|
|
11
|
+
*
|
|
12
|
+
* 二つの名前空間が混在している点に注意すること:
|
|
13
|
+
* - `edges` の要素は **pointsSet 内の配列位置**(数値)
|
|
14
|
+
* - searchIndex のキーは **頂点 index**(properties.target.index。
|
|
15
|
+
* GCP は数値だがエッジ中間ノードは "e58" のような文字列)
|
|
16
|
+
*
|
|
17
|
+
* GCP は「配列位置 == index」なので偶然一致するが、エッジ中間ノードは
|
|
18
|
+
* 配列位置と `e` の連番が別物であり、対応表なしでは一致しない。
|
|
19
|
+
* そのため pointIndices で配列位置を頂点 index へ引き直してからキー化する。
|
|
20
|
+
*
|
|
21
|
+
* キーの作り方は searchutils.ts の calcSearchKeys と厳密に揃える
|
|
22
|
+
* (String 化 → sort(既定の文字列比較)→ "-" 連結)。
|
|
23
|
+
*/
|
|
24
|
+
export declare function buildConstraintEdgeKeys(edges: ConstraintEdges, pointIndices?: PointIndices): Set<string>;
|
|
25
|
+
export declare function resolveOverlaps(tins: TinsBD, searchIndex: SearchIndex, edges: ConstraintEdges, pointIndices?: PointIndices): boolean;
|
|
5
26
|
export {};
|
package/dist/tin.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { Feature, Point, Position } from 'geojson';
|
|
2
2
|
import { Transform, Compiled, CompiledLegacy, Edge, EdgeSet, EdgeSetLegacy, PointSet, StrictMode, VertexMode, YaxisMode } from '@maplat/transform';
|
|
3
3
|
import { PointsSetBD } from "./types/tin.d";
|
|
4
|
+
export declare const FORMAT_VERSION_V2 = 2.00704;
|
|
5
|
+
export declare const FORMAT_VERSION_V3 = 3.00001;
|
|
4
6
|
/**
|
|
5
7
|
* Tinクラスの初期化オプション
|
|
6
8
|
*/
|
|
@@ -76,7 +78,7 @@ export declare class Tin extends Transform {
|
|
|
76
78
|
/**
|
|
77
79
|
* 厳密なTINを計算します
|
|
78
80
|
*/
|
|
79
|
-
|
|
81
|
+
calculateStrictTin(): void;
|
|
80
82
|
/**
|
|
81
83
|
* 点群セットを生成します。
|
|
82
84
|
* GCP と中間エッジノードを GeoJSON Point に変換し、後続の三角分割に備えます。
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
7
|
-
"version": "1.
|
|
7
|
+
"version": "1.1.0-rc.1",
|
|
8
8
|
"description": "JavaScript library which performs homeomorphic conversion mutually between the coordinate systems of two planes based on the control points.",
|
|
9
9
|
"type": "module",
|
|
10
10
|
"module": "./dist/maplat_tin.js",
|
|
@@ -49,36 +49,36 @@
|
|
|
49
49
|
"deno"
|
|
50
50
|
],
|
|
51
51
|
"dependencies": {
|
|
52
|
-
"@maplat/transform": "^1.
|
|
53
|
-
"@turf/turf": "^7.
|
|
52
|
+
"@maplat/transform": "^1.1.0-rc.1",
|
|
53
|
+
"@turf/turf": "^7.4.0",
|
|
54
54
|
"delaunator": "^5.0.1",
|
|
55
55
|
"robust-predicates": "^3.0.2"
|
|
56
56
|
},
|
|
57
57
|
"devDependencies": {
|
|
58
|
-
"@eslint/js": "^
|
|
58
|
+
"@eslint/js": "^10.0.1",
|
|
59
59
|
"@testing-library/jest-dom": "^6.9.1",
|
|
60
60
|
"@types/delaunator": "^5.0.3",
|
|
61
61
|
"@types/estree": "^1.0.8",
|
|
62
62
|
"@types/geojson": "^7946.0.16",
|
|
63
63
|
"@types/node": "^25.5.2",
|
|
64
|
-
"@typescript-eslint/eslint-plugin": "^8.
|
|
65
|
-
"@typescript-eslint/parser": "^8.
|
|
66
|
-
"@vitest/coverage-v8": "^
|
|
64
|
+
"@typescript-eslint/eslint-plugin": "^8.66.0",
|
|
65
|
+
"@typescript-eslint/parser": "^8.66.0",
|
|
66
|
+
"@vitest/coverage-v8": "^4.1.11",
|
|
67
67
|
"cross-env": "^10.1.0",
|
|
68
68
|
"dotenv": "^17.4.0",
|
|
69
69
|
"dotenv-cli": "^11.0.0",
|
|
70
|
-
"eslint": "^
|
|
70
|
+
"eslint": "^10.10.0",
|
|
71
71
|
"eslint-config-prettier": "^10.1.8",
|
|
72
72
|
"globals": "^16.5.0",
|
|
73
73
|
"jest-matcher-deep-close-to": "^3.0.2",
|
|
74
|
-
"jsdom": "^
|
|
75
|
-
"prettier": "^3.
|
|
74
|
+
"jsdom": "^30.0.1",
|
|
75
|
+
"prettier": "^3.9.6",
|
|
76
76
|
"robust-segment-intersect": "^1.0.1",
|
|
77
77
|
"typescript": "^5.9.3",
|
|
78
|
-
"typescript-eslint": "^8.
|
|
78
|
+
"typescript-eslint": "^8.66.0",
|
|
79
79
|
"vite": "^7.3.5",
|
|
80
|
-
"vite-plugin-dts": "^
|
|
81
|
-
"vitest": "^
|
|
80
|
+
"vite-plugin-dts": "^5.1.0",
|
|
81
|
+
"vitest": "^4.1.11"
|
|
82
82
|
},
|
|
83
83
|
"scripts": {
|
|
84
84
|
"dev": "vite --host",
|
|
@@ -282,7 +282,7 @@ export class Constrain extends Base {
|
|
|
282
282
|
const start1 = this.vertMap[p2];
|
|
283
283
|
const { triangles, halfedges } = this.del;
|
|
284
284
|
let edg = start1;
|
|
285
|
-
let prv
|
|
285
|
+
let prv: number;
|
|
286
286
|
// Walk around p2, iterating over the edges pointing to it.
|
|
287
287
|
do {
|
|
288
288
|
if (triangles[edg] === p1) {
|
package/src/index.ts
CHANGED