@maplat/tin 0.11.0 → 0.11.2

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.
@@ -0,0 +1,3 @@
1
+ (function(ot,xt){typeof exports=="object"&&typeof module<"u"?xt(exports,require("@turf/boolean-point-in-polygon"),require("@turf/centroid"),require("@turf/convex"),require("@turf/helpers"),require("@turf/line-intersect"),require("delaunator")):typeof define=="function"&&define.amd?define(["exports","@turf/boolean-point-in-polygon","@turf/centroid","@turf/convex","@turf/helpers","@turf/line-intersect","delaunator"],xt):(ot=typeof globalThis<"u"?globalThis:ot||self,xt(ot.tin={},ot.turf.booleanPointInPolygon,ot.turf.centroid,ot.turf.convex,ot.turf.helpers,ot.turf.lineIntersect,ot.Delaunator))})(this,function(ot,xt,Wt,_e,ut,tn,en){"use strict";var ni=Object.defineProperty;var ii=(ot,xt,Wt)=>xt in ot?ni(ot,xt,{enumerable:!0,configurable:!0,writable:!0,value:Wt}):ot[xt]=Wt;var rt=(ot,xt,Wt)=>ii(ot,typeof xt!="symbol"?xt+"":xt,Wt);var nn=Object.defineProperty,sn=(o,t,e)=>t in o?nn(o,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):o[t]=e,et=(o,t,e)=>sn(o,typeof t!="symbol"?t+"":t,e);const Tt=11102230246251565e-32,gt=134217729,rn=(3+8*Tt)*Tt;function fe(o,t,e,n,s){let i,r,a,f,h=t[0],u=n[0],c=0,l=0;u>h==u>-h?(i=h,h=t[++c]):(i=u,u=n[++l]);let p=0;if(c<o&&l<e)for(u>h==u>-h?(r=h+i,a=i-(r-h),h=t[++c]):(r=u+i,a=i-(r-u),u=n[++l]),i=r,a!==0&&(s[p++]=a);c<o&&l<e;)u>h==u>-h?(r=i+h,f=r-i,a=i-(r-f)+(h-f),h=t[++c]):(r=i+u,f=r-i,a=i-(r-f)+(u-f),u=n[++l]),i=r,a!==0&&(s[p++]=a);for(;c<o;)r=i+h,f=r-i,a=i-(r-f)+(h-f),h=t[++c],i=r,a!==0&&(s[p++]=a);for(;l<e;)r=i+u,f=r-i,a=i-(r-f)+(u-f),u=n[++l],i=r,a!==0&&(s[p++]=a);return(i!==0||p===0)&&(s[p++]=i),p}function on(o,t){let e=t[0];for(let n=1;n<o;n++)e+=t[n];return e}function Yt(o){return new Float64Array(o)}const an=(3+16*Tt)*Tt,cn=(2+12*Tt)*Tt,hn=(9+64*Tt)*Tt*Tt,zt=Yt(4),Se=Yt(8),Me=Yt(12),Ae=Yt(16),wt=Yt(4);function fn(o,t,e,n,s,i,r){let a,f,h,u,c,l,p,y,g,b,w,M,_,v,T,I,N,V;const W=o-s,K=e-s,tt=t-i,z=n-i;v=W*z,l=gt*W,p=l-(l-W),y=W-p,l=gt*z,g=l-(l-z),b=z-g,T=y*b-(v-p*g-y*g-p*b),I=tt*K,l=gt*tt,p=l-(l-tt),y=tt-p,l=gt*K,g=l-(l-K),b=K-g,N=y*b-(I-p*g-y*g-p*b),w=T-N,c=T-w,zt[0]=T-(w+c)+(c-N),M=v+w,c=M-v,_=v-(M-c)+(w-c),w=_-I,c=_-w,zt[1]=_-(w+c)+(c-I),V=M+w,c=V-M,zt[2]=M-(V-c)+(w-c),zt[3]=V;let st=on(4,zt),d=cn*r;if(st>=d||-st>=d||(c=o-W,a=o-(W+c)+(c-s),c=e-K,h=e-(K+c)+(c-s),c=t-tt,f=t-(tt+c)+(c-i),c=n-z,u=n-(z+c)+(c-i),a===0&&f===0&&h===0&&u===0)||(d=hn*r+rn*Math.abs(st),st+=W*u+z*a-(tt*h+K*f),st>=d||-st>=d))return st;v=a*z,l=gt*a,p=l-(l-a),y=a-p,l=gt*z,g=l-(l-z),b=z-g,T=y*b-(v-p*g-y*g-p*b),I=f*K,l=gt*f,p=l-(l-f),y=f-p,l=gt*K,g=l-(l-K),b=K-g,N=y*b-(I-p*g-y*g-p*b),w=T-N,c=T-w,wt[0]=T-(w+c)+(c-N),M=v+w,c=M-v,_=v-(M-c)+(w-c),w=_-I,c=_-w,wt[1]=_-(w+c)+(c-I),V=M+w,c=V-M,wt[2]=M-(V-c)+(w-c),wt[3]=V;const m=fe(4,zt,4,wt,Se);v=W*u,l=gt*W,p=l-(l-W),y=W-p,l=gt*u,g=l-(l-u),b=u-g,T=y*b-(v-p*g-y*g-p*b),I=tt*h,l=gt*tt,p=l-(l-tt),y=tt-p,l=gt*h,g=l-(l-h),b=h-g,N=y*b-(I-p*g-y*g-p*b),w=T-N,c=T-w,wt[0]=T-(w+c)+(c-N),M=v+w,c=M-v,_=v-(M-c)+(w-c),w=_-I,c=_-w,wt[1]=_-(w+c)+(c-I),V=M+w,c=V-M,wt[2]=M-(V-c)+(w-c),wt[3]=V;const x=fe(m,Se,4,wt,Me);v=a*u,l=gt*a,p=l-(l-a),y=a-p,l=gt*u,g=l-(l-u),b=u-g,T=y*b-(v-p*g-y*g-p*b),I=f*h,l=gt*f,p=l-(l-f),y=f-p,l=gt*h,g=l-(l-h),b=h-g,N=y*b-(I-p*g-y*g-p*b),w=T-N,c=T-w,wt[0]=T-(w+c)+(c-N),M=v+w,c=M-v,_=v-(M-c)+(w-c),w=_-I,c=_-w,wt[1]=_-(w+c)+(c-I),V=M+w,c=V-M,wt[2]=M-(V-c)+(w-c),wt[3]=V;const A=fe(x,Me,4,wt,Ae);return Ae[A-1]}function un(o,t,e,n,s,i){const r=(t-i)*(e-s),a=(o-s)*(n-i),f=r-a,h=Math.abs(r+a);return Math.abs(f)>=an*h?f:-fn(o,t,e,n,s,i,h)}function ln(o,t){var e,n,s=0,i,r,a,f,h,u,c,l=o[0],p=o[1],y=t.length;for(e=0;e<y;e++){n=0;var g=t[e],b=g.length-1;if(u=g[0],u[0]!==g[b][0]&&u[1]!==g[b][1])throw new Error("First and last coordinates in a ring must be the same");for(r=u[0]-l,a=u[1]-p,n;n<b;n++){if(c=g[n+1],f=c[0]-l,h=c[1]-p,a===0&&h===0){if(f<=0&&r>=0||r<=0&&f>=0)return 0}else if(h>=0&&a<=0||h<=0&&a>=0){if(i=un(r,f,a,h,0,0),i===0)return 0;(i>0&&h>0&&a<=0||i<0&&h<=0&&a>0)&&s++}u=c,a=h,r=f}}return s%2!==0}function Ee(o,t,e={}){const n={type:"Feature"};return(e.id===0||e.id)&&(n.id=e.id),e.bbox&&(n.bbox=e.bbox),n.properties=t||{},n.geometry=o,n}function Jt(o,t,e={}){if(!o)throw new Error("coordinates is required");if(!Array.isArray(o))throw new Error("coordinates must be an Array");if(o.length<2)throw new Error("coordinates must be at least 2 numbers long");if(!Oe(o[0])||!Oe(o[1]))throw new Error("coordinates must contain numbers");return Ee({type:"Point",coordinates:o},t,e)}function ve(o,t,e={}){for(const n of o){if(n.length<4)throw new Error("Each LinearRing of a Polygon must have 4 or more Positions.");if(n[n.length-1].length!==n[0].length)throw new Error("First and last Position are not equivalent.");for(let s=0;s<n[n.length-1].length;s++)if(n[n.length-1][s]!==n[0][s])throw new Error("First and last Position are not equivalent.")}return Ee({type:"Polygon",coordinates:o},t,e)}function Dt(o,t={}){const e={type:"FeatureCollection"};return t.id&&(e.id=t.id),t.bbox&&(e.bbox=t.bbox),e.features=o,e}function Oe(o){return!isNaN(o)&&o!==null&&!Array.isArray(o)}function dn(o){if(!o)throw new Error("coord is required");if(!Array.isArray(o)){if(o.type==="Feature"&&o.geometry!==null&&o.geometry.type==="Point")return[...o.geometry.coordinates];if(o.type==="Point")return[...o.coordinates]}if(Array.isArray(o)&&o.length>=2&&!Array.isArray(o[0])&&!Array.isArray(o[1]))return[...o];throw new Error("coord must be GeoJSON Point or an Array of numbers")}function Te(o){if(Array.isArray(o))return o;if(o.type==="Feature"){if(o.geometry!==null)return o.geometry.coordinates}else if(o.coordinates)return o.coordinates;throw new Error("coords must be GeoJSON Feature, Geometry Object or an Array")}function gn(o){return o.type==="Feature"?o.geometry:o}function pn(o,t,e={}){if(!o)throw new Error("point is required");if(!t)throw new Error("polygon is required");const n=dn(o),s=gn(t),i=s.type,r=t.bbox;let a=s.coordinates;if(r&&wn(n,r)===!1)return!1;i==="Polygon"&&(a=[a]);let f=!1;for(var h=0;h<a.length;++h){const u=ln(n,a[h]);if(u===0)return!e.ignoreBoundary;u&&(f=!0)}return f}function wn(o,t){return t[0]<=o[0]&&t[1]<=o[1]&&t[2]>=o[0]&&t[3]>=o[1]}var ue=pn;function Ie(o){const t=o.features;for(let e=0;e<t.length;e++){const n=t[e];`${n.properties.a.index}`.substring(0,1)==="b"&&`${n.properties.b.index}`.substring(0,1)==="b"?t[e]={geometry:{type:"Polygon",coordinates:[[n.geometry.coordinates[0][2],n.geometry.coordinates[0][0],n.geometry.coordinates[0][1],n.geometry.coordinates[0][2]]]},properties:{a:{geom:n.properties.c.geom,index:n.properties.c.index},b:{geom:n.properties.a.geom,index:n.properties.a.index},c:{geom:n.properties.b.geom,index:n.properties.b.index}},type:"Feature"}:`${n.properties.c.index}`.substring(0,1)==="b"&&`${n.properties.a.index}`.substring(0,1)==="b"&&(t[e]={geometry:{type:"Polygon",coordinates:[[n.geometry.coordinates[0][1],n.geometry.coordinates[0][2],n.geometry.coordinates[0][0],n.geometry.coordinates[0][1]]]},properties:{a:{geom:n.properties.b.geom,index:n.properties.b.index},b:{geom:n.properties.c.geom,index:n.properties.c.index},c:{geom:n.properties.a.geom,index:n.properties.a.index}},type:"Feature"})}return o}function mn(o){const t=["a","b","c","a"].map(i=>o.properties[i].geom),e=o.geometry.coordinates[0],n=o.properties,s={a:{geom:e[0],index:n.a.index},b:{geom:e[1],index:n.b.index},c:{geom:e[2],index:n.c.index}};return ve([t],s)}function bn(o){const t=[0,1,2,0].map(n=>o[n][0][0]),e={a:{geom:o[0][0][1],index:o[0][1]},b:{geom:o[1][0][1],index:o[1][1]},c:{geom:o[2][0][1],index:o[2][1]}};return ve([t],e)}function ee(o,t,e,n,s,i=!1,r){const a=o.map(f=>{(!r||r<2.00703)&&(f=Pe(f));const h=isFinite(f)?t[f]:f==="c"?n:f==="b0"?s[0]:f==="b1"?s[1]:f==="b2"?s[2]:f==="b3"?s[3]:function(){const u=f.match(/e(\d+)/);if(u){const c=parseInt(u[1]);return e[c]}throw"Bad index value for indexesToTri"}();return i?[[h[1],h[0]],f]:[[h[0],h[1]],f]});return bn(a)}function Pe(o){return typeof o=="number"?o:o.replace(/^(c|e|b)(?:ent|dgeNode|box)(\d+)?$/,"$1$2")}function $e(o,t){return t&&t>=2.00703||Array.isArray(o[0])?o:o.map(e=>[e.illstNodes,e.mercNodes,e.startEnd])}function Re(o,t){for(let e=0;e<t.features.length;e++)if(ue(o,t.features[e]))return t.features[e]}function Ne(o,t,e){const n=t.geometry.coordinates[0][0],s=t.geometry.coordinates[0][1],i=t.geometry.coordinates[0][2],r=o.geometry.coordinates,a=t.properties.a.geom,f=t.properties.b.geom,h=t.properties.c.geom,u=[s[0]-n[0],s[1]-n[1]],c=[i[0]-n[0],i[1]-n[1]],l=[r[0]-n[0],r[1]-n[1]],p=[f[0]-a[0],f[1]-a[1]],y=[h[0]-a[0],h[1]-a[1]];let g=(c[1]*l[0]-c[0]*l[1])/(u[0]*c[1]-u[1]*c[0]),b=(u[0]*l[1]-u[1]*l[0])/(u[0]*c[1]-u[1]*c[0]);if(e){const w=e[t.properties.a.index],M=e[t.properties.b.index],_=e[t.properties.c.index];let v;if(g<0||b<0||1-g-b<0){const T=g/(g+b),I=b/(g+b);v=g/M/(T/M+I/_),b=b/_/(T/M+I/_)}else v=g/M/(g/M+b/_+(1-g-b)/w),b=b/_/(g/M+b/_+(1-g-b)/w);g=v}return[g*p[0]+b*y[0]+a[0],g*p[1]+b*y[1]+a[1]]}function yn(o,t,e,n){const s=o.geometry.coordinates,i=e.geometry.coordinates,r=Math.atan2(s[0]-i[0],s[1]-i[1]),a=kn(r,t[0]);if(a===void 0)throw new Error("Unable to determine vertex index");const f=t[1][a];return Ne(o,f.features[0],n)}function ne(o,t,e,n,s,i,r,a){let f;if(r&&(f=Re(o,Dt([r]))),!f){if(e){const h=o.geometry.coordinates,u=e.gridNum,c=e.xOrigin,l=e.yOrigin,p=e.xUnit,y=e.yUnit,g=e.gridCache,b=At(h[0],c,p,u),w=At(h[1],l,y,u),M=g[b]?g[b][w]?g[b][w]:[]:[];t=Dt(M.map(_=>t.features[_]))}f=Re(o,t)}return a&&a(f),f?Ne(o,f,i):yn(o,n,s,i)}function At(o,t,e,n){let s=Math.floor((o-t)/e);return s>=n&&(s=n-1),s}function kn(o,t){let e=Ue(o-t[0]),n=Math.PI*2,s;for(let i=0;i<t.length;i++){const r=(i+1)%t.length,a=Ue(o-t[r]),f=Math.min(Math.abs(e),Math.abs(a));e*a<=0&&f<n&&(n=f,s=i),e=a}return s}function Ue(o,t=!1){const e=t?function(n){return!(n>=0&&n<Math.PI*2)}:function(n){return!(n>-1*Math.PI&&n<=Math.PI)};for(;e(o);)o=o+2*Math.PI*(o>0?-1:1);return o}const ie=2.00703,St=class Mt{constructor(){et(this,"points",[]),et(this,"pointsWeightBuffer"),et(this,"strict_status"),et(this,"vertices_params"),et(this,"centroid"),et(this,"edgeNodes"),et(this,"edges"),et(this,"tins"),et(this,"kinks"),et(this,"yaxisMode",Mt.YAXIS_INVERT),et(this,"strictMode",Mt.MODE_AUTO),et(this,"vertexMode",Mt.VERTEX_PLAIN),et(this,"bounds"),et(this,"boundsPolygon"),et(this,"wh"),et(this,"xy"),et(this,"indexedTins"),et(this,"stateFull",!1),et(this,"stateTriangle"),et(this,"stateBackward")}setCompiled(t){if(t.version||!t.tins&&t.points&&t.tins_points){this.points=t.points,this.pointsWeightBuffer=!t.version||t.version<2.00703?["forw","bakw"].reduce((n,s)=>{const i=t.weight_buffer[s];return i&&(n[s]=Object.keys(i).reduce((r,a)=>{const f=Pe(a);return r[f]=i[a],r},{})),n},{}):t.weight_buffer,t.strict_status?this.strict_status=t.strict_status:t.kinks_points?this.strict_status=Mt.STATUS_ERROR:t.tins_points.length==2?this.strict_status=Mt.STATUS_LOOSE:this.strict_status=Mt.STATUS_STRICT,this.vertices_params={forw:[t.vertices_params[0]],bakw:[t.vertices_params[1]]},this.vertices_params.forw[1]=[0,1,2,3].map(n=>{const s=(n+1)%4,i=ee(["c",`b${n}`,`b${s}`],t.points,t.edgeNodes||[],t.centroid_point,t.vertices_points,!1,ie);return Dt([i])}),this.vertices_params.bakw[1]=[0,1,2,3].map(n=>{const s=(n+1)%4,i=ee(["c",`b${n}`,`b${s}`],t.points,t.edgeNodes||[],t.centroid_point,t.vertices_points,!0,ie);return Dt([i])}),this.centroid={forw:Jt(t.centroid_point[0],{target:{geom:t.centroid_point[1],index:"c"}}),bakw:Jt(t.centroid_point[1],{target:{geom:t.centroid_point[0],index:"c"}})},this.edges=$e(t.edges||[]),this.edgeNodes=t.edgeNodes||[];const e=t.tins_points.length==1?0:1;this.tins={forw:Dt(t.tins_points[0].map(n=>ee(n,t.points,t.edgeNodes||[],t.centroid_point,t.vertices_points,!1,t.version))),bakw:Dt(t.tins_points[e].map(n=>ee(n,t.points,t.edgeNodes||[],t.centroid_point,t.vertices_points,!0,t.version)))},this.addIndexedTin(),t.kinks_points&&(this.kinks={bakw:Dt(t.kinks_points.map(n=>Jt(n)))}),t.yaxisMode?this.yaxisMode=t.yaxisMode:this.yaxisMode=Mt.YAXIS_INVERT,t.vertexMode&&(this.vertexMode=t.vertexMode),t.strictMode&&(this.strictMode=t.strictMode),t.bounds?(this.bounds=t.bounds,this.boundsPolygon=t.boundsPolygon,this.xy=t.xy,this.wh=t.wh):(this.xy=[0,0],t.wh&&(this.wh=t.wh),this.bounds=void 0,this.boundsPolygon=void 0)}else{t=JSON.parse(JSON.stringify(t).replace('"cent"','"c"').replace(/"bbox(\d+)"/g,'"b$1"')),this.tins=t.tins,this.addIndexedTin(),this.strict_status=t.strict_status,this.pointsWeightBuffer=t.weight_buffer,this.vertices_params=t.vertices_params,this.centroid=t.centroid,this.kinks=t.kinks;const e=[];for(let n=0;n<this.tins.forw.features.length;n++){const s=this.tins.forw.features[n];["a","b","c"].map((i,r)=>{const a=s.geometry.coordinates[0][r],f=s.properties[i].geom,h=s.properties[i].index;typeof h=="number"&&(e[h]=[a,f])})}this.points=e}}addIndexedTin(){const t=this.tins,e=t.forw,n=t.bakw,s=Math.ceil(Math.sqrt(e.features.length));if(s<3){this.indexedTins=void 0;return}let i=[],r=[];const a=e.features.map(g=>{let b=[];return Te(g)[0].map(w=>{i.length===0?i=[Array.from(w),Array.from(w)]:(w[0]<i[0][0]&&(i[0][0]=w[0]),w[0]>i[1][0]&&(i[1][0]=w[0]),w[1]<i[0][1]&&(i[0][1]=w[1]),w[1]>i[1][1]&&(i[1][1]=w[1])),b.length===0?b=[Array.from(w),Array.from(w)]:(w[0]<b[0][0]&&(b[0][0]=w[0]),w[0]>b[1][0]&&(b[1][0]=w[0]),w[1]<b[0][1]&&(b[0][1]=w[1]),w[1]>b[1][1]&&(b[1][1]=w[1]))}),b}),f=(i[1][0]-i[0][0])/s,h=(i[1][1]-i[0][1])/s,u=a.reduce((g,b,w)=>{const M=At(b[0][0],i[0][0],f,s),_=At(b[1][0],i[0][0],f,s),v=At(b[0][1],i[0][1],h,s),T=At(b[1][1],i[0][1],h,s);for(let I=M;I<=_;I++){g[I]||(g[I]=[]);for(let N=v;N<=T;N++)g[I][N]||(g[I][N]=[]),g[I][N].push(w)}return g},[]),c=n.features.map(g=>{let b=[];return Te(g)[0].map(w=>{r.length===0?r=[Array.from(w),Array.from(w)]:(w[0]<r[0][0]&&(r[0][0]=w[0]),w[0]>r[1][0]&&(r[1][0]=w[0]),w[1]<r[0][1]&&(r[0][1]=w[1]),w[1]>r[1][1]&&(r[1][1]=w[1])),b.length===0?b=[Array.from(w),Array.from(w)]:(w[0]<b[0][0]&&(b[0][0]=w[0]),w[0]>b[1][0]&&(b[1][0]=w[0]),w[1]<b[0][1]&&(b[0][1]=w[1]),w[1]>b[1][1]&&(b[1][1]=w[1]))}),b}),l=(r[1][0]-r[0][0])/s,p=(r[1][1]-r[0][1])/s,y=c.reduce((g,b,w)=>{const M=At(b[0][0],r[0][0],l,s),_=At(b[1][0],r[0][0],l,s),v=At(b[0][1],r[0][1],p,s),T=At(b[1][1],r[0][1],p,s);for(let I=M;I<=_;I++){g[I]||(g[I]=[]);for(let N=v;N<=T;N++)g[I][N]||(g[I][N]=[]),g[I][N].push(w)}return g},[]);this.indexedTins={forw:{gridNum:s,xOrigin:i[0][0],yOrigin:i[0][1],xUnit:f,yUnit:h,gridCache:u},bakw:{gridNum:s,xOrigin:r[0][0],yOrigin:r[0][1],xUnit:l,yUnit:p,gridCache:y}}}transform(t,e,n){if(e&&this.strict_status==Mt.STATUS_ERROR)throw'Backward transform is not allowed if strict_status == "strict_error"';this.yaxisMode==Mt.YAXIS_FOLLOW&&e&&(t=[t[0],-1*t[1]]);const s=Jt(t);if(this.bounds&&!e&&!n&&!ue(s,this.boundsPolygon))return!1;const i=e?this.tins.bakw:this.tins.forw,r=e?this.indexedTins.bakw:this.indexedTins.forw,a=e?this.vertices_params.bakw:this.vertices_params.forw,f=e?this.centroid.bakw:this.centroid.forw,h=e?this.pointsWeightBuffer.bakw:this.pointsWeightBuffer.forw;let u,c;this.stateFull&&(this.stateBackward==e?u=this.stateTriangle:(this.stateBackward=e,this.stateTriangle=void 0),c=p=>{this.stateTriangle=p});let l=ne(s,i,r,a,f,h,u,c);if(this.bounds&&e&&!n){const p=Jt(l);if(!ue(p,this.boundsPolygon))return!1}else this.yaxisMode==Mt.YAXIS_FOLLOW&&!e&&(l=[l[0],-1*l[1]]);return l}};et(St,"VERTEX_PLAIN","plain"),et(St,"VERTEX_BIRDEYE","birdeye"),et(St,"MODE_STRICT","strict"),et(St,"MODE_AUTO","auto"),et(St,"MODE_LOOSE","loose"),et(St,"STATUS_STRICT","strict"),et(St,"STATUS_ERROR","strict_error"),et(St,"STATUS_LOOSE","loose"),et(St,"YAXIS_FOLLOW","follow"),et(St,"YAXIS_INVERT","invert");let xn=St;const pt=11102230246251565e-32,$=134217729,Be=(3+8*pt)*pt;function ft(o,t,e,n,s){let i,r,a,f,h=t[0],u=n[0],c=0,l=0;u>h==u>-h?(i=h,h=t[++c]):(i=u,u=n[++l]);let p=0;if(c<o&&l<e)for(u>h==u>-h?(r=h+i,a=i-(r-h),h=t[++c]):(r=u+i,a=i-(r-u),u=n[++l]),i=r,a!==0&&(s[p++]=a);c<o&&l<e;)u>h==u>-h?(r=i+h,f=r-i,a=i-(r-f)+(h-f),h=t[++c]):(r=i+u,f=r-i,a=i-(r-f)+(u-f),u=n[++l]),i=r,a!==0&&(s[p++]=a);for(;c<o;)r=i+h,f=r-i,a=i-(r-f)+(h-f),h=t[++c],i=r,a!==0&&(s[p++]=a);for(;l<e;)r=i+u,f=r-i,a=i-(r-f)+(u-f),u=n[++l],i=r,a!==0&&(s[p++]=a);return(i!==0||p===0)&&(s[p++]=i),p}function _t(o,t,e,n,s,i,r,a){return ft(ft(o,t,e,n,r),r,s,i,a)}function S(o,t,e,n){let s,i,r,a,f,h,u,c,l,p,y;u=$*e,p=u-(u-e),y=e-p;let g=t[0];s=g*e,u=$*g,c=u-(u-g),l=g-c,r=l*y-(s-c*p-l*p-c*y);let b=0;r!==0&&(n[b++]=r);for(let w=1;w<o;w++)g=t[w],a=g*e,u=$*g,c=u-(u-g),l=g-c,f=l*y-(a-c*p-l*p-c*y),i=s+f,h=i-s,r=s-(i-h)+(f-h),r!==0&&(n[b++]=r),s=a+i,r=i-(s-a),r!==0&&(n[b++]=r);return(s!==0||b===0)&&(n[b++]=s),b}function De(o,t){let e=t[0];for(let n=1;n<o;n++)e+=t[n];return e}function H(o){return new Float64Array(o)}const _n=(3+16*pt)*pt,Sn=(2+12*pt)*pt,Mn=(9+64*pt)*pt*pt,Xt=H(4),Fe=H(8),je=H(12),Le=H(16),mt=H(4);function An(o,t,e,n,s,i,r){let a,f,h,u,c,l,p,y,g,b,w,M,_,v,T,I,N,V;const W=o-s,K=e-s,tt=t-i,z=n-i;v=W*z,l=$*W,p=l-(l-W),y=W-p,l=$*z,g=l-(l-z),b=z-g,T=y*b-(v-p*g-y*g-p*b),I=tt*K,l=$*tt,p=l-(l-tt),y=tt-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*f,p=l-(l-f),y=f-p,l=$*h,g=l-(l-h),b=h-g,N=y*b-(I-p*g-y*g-p*b),w=T-N,c=T-w,mt[0]=T-(w+c)+(c-N),M=v+w,c=M-v,_=v-(M-c)+(w-c),w=_-I,c=_-w,mt[1]=_-(w+c)+(c-I),V=M+w,c=V-M,mt[2]=M-(V-c)+(w-c),mt[3]=V;const A=ft(x,je,4,mt,Le);return Le[A-1]}function Ht(o,t,e,n,s,i){const r=(t-i)*(e-s),a=(o-s)*(n-i),f=r-a,h=Math.abs(r+a);return Math.abs(f)>=_n*h?f:-An(o,t,e,n,s,i,h)}const En=(10+96*pt)*pt,vn=(4+48*pt)*pt,On=(44+576*pt)*pt*pt,$t=H(4),Rt=H(4),Nt=H(4),Et=H(4),vt=H(4),Ot=H(4),bt=H(4),yt=H(4),le=H(8),de=H(8),ge=H(8),pe=H(8),we=H(8),me=H(8),se=H(8),re=H(8),oe=H(8),Ft=H(4),jt=H(4),Lt=H(4),U=H(8),L=H(16),nt=H(16),it=H(16),G=H(32),Ut=H(32),ct=H(48),kt=H(64);let qt=H(1152),be=H(1152);function ht(o,t,e){o=ft(o,qt,t,e,be);const n=qt;return qt=be,be=n,o}function Tn(o,t,e,n,s,i,r,a,f){let h,u,c,l,p,y,g,b,w,M,_,v,T,I,N,V,W,K,tt,z,st,d,m,x,A,E,R,k,O,B,P,D,F,C,j;const X=o-r,q=e-r,Y=s-r,Q=t-a,J=n-a,Z=i-a;P=q*Z,m=$*q,x=m-(m-q),A=q-x,m=$*Z,E=m-(m-Z),R=Z-E,D=A*R-(P-x*E-A*E-x*R),F=Y*J,m=$*Y,x=m-(m-Y),A=Y-x,m=$*J,E=m-(m-J),R=J-E,C=A*R-(F-x*E-A*E-x*R),k=D-C,d=D-k,$t[0]=D-(k+d)+(d-C),O=P+k,d=O-P,B=P-(O-d)+(k-d),k=B-F,d=B-k,$t[1]=B-(k+d)+(d-F),j=O+k,d=j-O,$t[2]=O-(j-d)+(k-d),$t[3]=j,P=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,Et,-l,U),U,y,L),L))}if(g!==0){const lt=S(I,se,g,it);h=ht(h,ft(S(T,me,g,L),L,S(lt,it,2*Z,G),G,ct),ct);const dt=S(W,Ft,g,U);h=ht(h,_t(S(dt,U,2*Z,L),L,S(dt,U,g,nt),nt,S(lt,it,g,G),G,Ut,kt),kt)}}return qt[h-1]}function In(o,t,e,n,s,i,r,a){const f=o-r,h=e-r,u=s-r,c=t-a,l=n-a,p=i-a,y=h*p,g=u*l,b=f*f+c*c,w=u*c,M=f*p,_=h*h+l*l,v=f*l,T=h*c,I=u*u+p*p,N=b*(y-g)+_*(w-M)+I*(v-T),V=(Math.abs(y)+Math.abs(g))*b+(Math.abs(w)+Math.abs(M))*_+(Math.abs(v)+Math.abs(T))*I,W=En*V;return N>W||-N>W?N:Tn(o,t,e,n,s,i,r,a,V)}class Pn{constructor(t,e){this.W=t,this.bs=e}add(t){const e=this.W,n=t/e|0,s=t%e;return this.bs[n]|=1<<s,this}delete(t){const e=this.W,n=t/e|0,s=t%e;return this.bs[n]&=~(1<<s),this}set(t,e){const n=this.W,s=t/n|0,i=t%n,r=1<<i;return this.bs[s]^=(-e^this.bs[s])&r,e}has(t){const e=this.W,n=t/e|0,s=t%e;return!!(this.bs[n]&1<<s)}forEach(t){const e=this.W,n=this.bs,s=n.length;for(let i=0;i<s;i++){let r=0;for(;n[i]&&r<e;)n[i]&1<<r&&t(i*e+r),r++}return this}}class Ve extends Pn{constructor(t){const e=new Uint8Array(Math.ceil(t/8)).fill(0);super(8,e)}}function Vt(o){return o%3===2?o-2:o+1}function It(o){return o%3===0?o+2:o-1}function Ce(o,t,e,n,s,i,r,a){const f=Ht(o,t,s,i,r,a),h=Ht(e,n,s,i,r,a);if(f>0&&h>0||f<0&&h<0)return!1;const u=Ht(s,i,o,t,e,n),c=Ht(r,a,o,t,e,n);return u>0&&c>0||u<0&&c<0?!1:f===0&&h===0&&u===0&&c===0?!(Math.max(s,r)<Math.min(o,e)||Math.max(o,e)<Math.min(s,r)||Math.max(i,a)<Math.min(t,n)||Math.max(t,n)<Math.min(i,a)):!0}class $n{constructor(t){this.del=t}}const We=class extends $n{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 n=2**32-1,s=t.coords.length>>1,i=t.triangles.length;this.vertMap=new Uint32Array(s).fill(n),this.flips=new Ve(i),this.consd=new Ve(i);for(let r=0;r<i;r++){const a=t.triangles[r];this.vertMap[a]===n&&this.updateVert(r)}e&&this.constrainAll(e)}constrainOne(t,e){const{triangles:n,halfedges:s}=this.del,i=this.vertMap[t];let r=i;do{const h=n[r],u=Vt(r);if(h===e)return this.protect(r);const c=It(r),l=n[c];if(l===e)return this.protect(u),u;if(this.intersectSegments(t,e,l,h)){r=c;break}r=s[u]}while(r!==-1&&r!==i);let a=r,f=-1;for(;r!==-1;){const h=s[r],u=It(r),c=It(h),l=Vt(h);if(h===-1)throw new Error("Constraining edge exited the hull");if(this.consd.has(r))throw new Error("Edge intersects already constrained edge");if(this.isCollinear(t,e,n[r])||this.isCollinear(t,e,n[h]))throw new Error("Constraining edge intersects point");if(!this.intersectSegments(n[r],n[h],n[u],n[c])){if(f===-1&&(f=r),n[c]===e){if(r===f)throw new Error("Infinite loop: non-convex quadrilateral");r=f,f=-1;continue}if(this.intersectSegments(t,e,n[c],n[h]))r=c;else if(this.intersectSegments(t,e,n[l],n[c]))r=l;else if(f===r)throw new Error("Infinite loop: no further intersect after non-convex");continue}if(this.flipDiagonal(r),this.intersectSegments(t,e,n[u],n[c])&&(f===-1&&(f=u),f===u))throw new Error("Infinite loop: flipped diagonal still intersects");n[c]===e?(a=c,r=f,f=-1):this.intersectSegments(t,e,n[l],n[c])&&(r=l)}return this.protect(a),this.delaunify(!0),this.findEdge(t,e)}delaunify(t=!1){const{halfedges:e}=this.del,n=this.flips,s=this.consd,i=e.length;do{var r=0;for(let a=0;a<i;a++){if(s.has(a))continue;n.delete(a);const f=e[a];f!==-1&&(n.delete(f),this.isDelaunay(a)||(this.flipDiagonal(a),r++))}}while(t&&r>0);return this}constrainAll(t){const e=t.length;for(let n=0;n<e;n++){const s=t[n];this.constrainOne(s[0],s[1])}return this}isConstrained(t){return this.consd.has(t)}findEdge(t,e){const n=this.vertMap[e],{triangles:s,halfedges:i}=this.del;let r=n,a=-1;do{if(s[r]===t)return r;a=Vt(r),r=i[a]}while(r!==-1&&r!==n);return s[Vt(a)]===t?-a:1/0}protect(t){const e=this.del.halfedges[t],n=this.flips,s=this.consd;return n.delete(t),s.add(t),e!==-1?(n.delete(e),s.add(e),e):-t}markFlip(t){const e=this.del.halfedges,n=this.flips;if(this.consd.has(t))return!1;const s=e[t];return s!==-1&&(n.add(t),n.add(s)),!0}flipDiagonal(t){const{triangles:e,halfedges:n}=this.del,s=this.flips,i=this.consd,r=n[t],a=It(t),f=Vt(t),h=It(r),u=Vt(r),c=n[a],l=n[h];if(i.has(t))throw new Error("Trying to flip a constrained edge");return e[t]=e[h],n[t]=l,s.set(t,s.has(h))||i.set(t,i.has(h)),l!==-1&&(n[l]=t),n[a]=h,e[r]=e[a],n[r]=c,s.set(r,s.has(a))||i.set(r,i.has(a)),c!==-1&&(n[c]=r),n[h]=a,this.markFlip(t),this.markFlip(f),this.markFlip(r),this.markFlip(u),s.add(a),i.delete(a),s.add(h),i.delete(h),this.updateVert(t),this.updateVert(f),this.updateVert(r),this.updateVert(u),a}isCollinear(t,e,n){const s=this.del.coords;return Ht(s[t*2],s[t*2+1],s[e*2],s[e*2+1],s[n*2],s[n*2+1])===0}inCircle(t,e,n,s){const i=this.del.coords;return In(i[t*2],i[t*2+1],i[e*2],i[e*2+1],i[n*2],i[n*2+1],i[s*2],i[s*2+1])<0}isDelaunay(t){const{triangles:e,halfedges:n}=this.del,s=n[t];if(s===-1)return!0;const i=e[It(t)],r=e[t],a=e[Vt(t)],f=e[It(s)];return!this.inCircle(i,r,a,f)}updateVert(t){const{triangles:e,halfedges:n}=this.del,s=this.vertMap,i=e[t];let r=It(t),a=n[r];for(;a!==-1&&a!==t;)r=It(a),a=n[r];return s[i]=r,r}intersectSegments(t,e,n,s){const i=this.del.coords;return t===n||t===s||e===n||e===s?!1:Ce(i[t*2],i[t*2+1],i[e*2],i[e*2+1],i[n*2],i[n*2+1],i[s*2],i[s*2+1])}};We.intersectSegments=Ce;let Rn=We;function Gt(o,t,e){if(t||(t=[]),typeof o!="object"||o.type!=="FeatureCollection")throw"Argument points must be FeatureCollection";if(!Array.isArray(t))throw"Argument points must be Array of Array";const n=o.features.map(f=>f.geometry.coordinates),s=en.from(n);let i;const r=[];s.triangles.length!==0&&t.length!==0&&(i=new Rn(s),i.constrainAll(t));for(let f=0;f<s.triangles.length;f+=3)r.push([s.triangles[f],s.triangles[f+1],s.triangles[f+2]]);const a=["a","b","c"];return ut.featureCollection(r.map(f=>{const h={},u=f.map((c,l)=>{const p=o.features[c],y=p.geometry.coordinates,g=[y[0],y[1]];return y.length===3?g[2]=y[2]:h[a[l]]=p.properties[e],g});return u[3]=u[0],ut.polygon([u],h)}))}function ze(o){const e=new Nn(o).findSegmentIntersections();return Ge(e).reduce((n,s,i,r)=>Array.isArray(n)||(n||(n={}),n[`${s.x}:${s.y}`]=s,i!=r.length-1)?n:Object.keys(n).map(a=>ut.point([n[a].x,n[a].y])),{})}class Nn{constructor(t){rt(this,"_xx");rt(this,"_yy");rt(this,"_ii");rt(this,"_nn");rt(this,"_zz");rt(this,"_zlimit",0);rt(this,"_bb");rt(this,"_allBounds");rt(this,"_arcIter");rt(this,"_filteredArcIter");rt(this,"buf");this.initArcs(t)}initArcs(t){const e=[],n=[],s=t.map(i=>{const r=i?i.length:0;for(let a=0;a<r;a++)e.push(i[a][0]),n.push(i[a][1]);return r});this.initXYData(s,e,n)}initXYData(t,e,n){const s=t.length;this._xx=new Float64Array(e),this._yy=new Float64Array(n),this._nn=new Uint32Array(t),this._zz=null,this._zlimit=0,this._filteredArcIter=null,this._ii=new Uint32Array(s);let i=0;for(let r=0;r<s;r++)this._ii[r]=i,i+=t[r];(i!=this._xx.length||this._xx.length!=this._yy.length)&&ye("ArcCollection#initXYData() Counting error"),this.initBounds(),this._arcIter=new ti(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,n){const s=n.length,i=new Float64Array(s*4),r=new he;let a=0,f,h,u;for(let c=0;c<s;c++)f=n[c],f>0&&(h=c*4,u=ei(t,e,a,f),i[h++]=u[0],i[h++]=u[1],i[h++]=u[2],i[h]=u[3],a+=f,r.mergeBounds(u));return{bb:i,bounds:r}}getBounds(){return this._allBounds.clone()}forEachSegment(t){let e=0;for(let n=0,s=this.size();n<s;n++)e+=this.forEachArcSegment(n,t);return e}size(){return this._ii&&this._ii.length||0}forEachArcSegment(t,e){const n=t>=0,s=n?t:~t,i=this.getRetainedInterval(),r=this._nn[s],a=n?1:-1;let f=n?this._ii[s]:this._ii[s]+r-1,h=f,u=0;for(let c=1;c<r;c++)h+=a,(i===0||this._zz[h]>=i)&&(e(f,h,this._xx,this._yy),f=h,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 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 n=this.forEachSegment((s,i,r,a)=>{t+=Math.abs(r[s]-r[i]),e+=Math.abs(a[s]-a[i])});return[t/n||0,e/n||0]}calcSegmentIntersectionStripeCount(){const t=this.getBounds().height(),e=this.getAvgSegment2()[1];let n=1;return e>0&&t>0&&(n=Math.ceil(t/e/20)),n||1}findSegmentIntersections(){const t=this.getBounds(),e=t.ymin,n=t.ymax-e,s=this.calcSegmentIntersectionStripeCount(),i=new Uint32Array(s),r=s>1?g=>Math.floor((s-1)*(g-e)/n):()=>0;let a,f;this.forEachSegment((g,b,w,M)=>{let _=r(M[g]);const v=r(M[b]);for(;i[_]=i[_]+2,_!=v;)_+=v>_?1:-1});const h=this.getUint32Array(Dn(i));let u=0;const c=[];Fn(i,g=>{const b=u;u+=g,c.push(h.subarray(b,u))}),jn(i,0),this.forEachSegment((g,b,w,M)=>{let _=r(M[g]);const v=r(M[b]);let T,I;for(;T=i[_],i[_]=T+2,I=c[_],I[T]=g,I[T+1]=b,_!=v;)_+=v>_?1:-1});const l=this.getVertexData(),p=[];let y;for(a=0;a<s;a++)for(y=Ln(c[a],l.xx,l.yy),f=0;f<y.length;f++)p.push(y[f]);return Ge(p)}}function ye(...o){const t=o.join(" ");throw new Error(t)}function ke(o){return o?Bn(o)?!0:Un(o)?!1:o.length===0?!0:o.length>0:!1}function Un(o){return o!=null&&o.toString===String.prototype.toString}function Bn(o){return Array.isArray(o)}function Dn(o,t){ke(o)||ye("utils.sum() expects an array, received:",o);let e=0,n;for(let s=0,i=o.length;s<i;s++)n=o[s],n&&(e+=n);return e}function Fn(o,t,e){if(!ke(o))throw new Error(`#forEach() takes an array-like argument. ${o}`);for(let n=0,s=o.length;n<s;n++)t.call(e,o[n],n)}function jn(o,t){for(let e=0,n=o.length;e<n;e++)o[e]=t;return o}function Ln(o,t,e){const n=o.length-2,s=[];let i,r,a,f,h,u,c,l,p,y,g,b,w,M,_,v,T;for(Gn(t,o),v=0;v<n;){for(i=o[v],r=o[v+1],h=t[i],u=t[r],p=e[i],y=e[r],T=v;T<n&&(T+=2,a=o[T],c=t[a],!(u<c));){if(g=e[a],f=o[T+1],l=t[f],b=e[f],p>=g){if(p>b&&y>g&&y>b)continue}else if(p<b&&y<g&&y<b)continue;i==a||i==f||r==a||r==f||(w=Vn(h,p,u,y,c,g,l,b),w&&(M=[i,r],_=[a,f],s.push(Je(w,M,_,t,e)),w.length==4&&s.push(Je(w.slice(2),M,_,t,e))))}v+=2}return s}function Vn(o,t,e,n,s,i,r,a){const f=Cn(o,t,e,n,s,i,r,a);let h=null;return f&&(h=Wn(o,t,e,n,s,i,r,a),h?Hn(o,t,e,n,s,i,r,a)&&(h=null):h=Jn(o,t,e,n,s,i,r,a)),h}function Cn(o,t,e,n,s,i,r,a){return Kt(o,t,e,n,s,i)*Kt(o,t,e,n,r,a)<=0&&Kt(s,i,r,a,o,t)*Kt(s,i,r,a,e,n)<=0}function Kt(o,t,e,n,s,i){return Xe(o-s,t-i,e-s,n-i)}function Xe(o,t,e,n){return o*n-t*e}function Wn(o,t,e,n,s,i,r,a){let f=ae(o,t,e,n,s,i,r,a),h;return f&&(h=Xn(f[0],f[1],o,t,e,n,s,i,r,a),h==1?f=ae(e,n,o,t,s,i,r,a):h==2?f=ae(s,i,r,a,o,t,e,n):h==3&&(f=ae(r,a,s,i,o,t,e,n))),f&&Yn(f,o,t,e,n,s,i,r,a),f}function ae(o,t,e,n,s,i,r,a){const f=Xe(e-o,n-t,r-s,a-i),h=1e-18;let u;if(f===0)return null;const c=Kt(s,i,r,a,o,t)/f;return f<=h&&f>=-h?u=zn(o,t,e,n,s,i,r,a):u=[o+c*(e-o),t+c*(n-t)],u}function zn(o,t,e,n,s,i,r,a){let f=null;return!Pt(o,s,r)&&!Pt(t,i,a)?f=[o,t]:!Pt(e,s,r)&&!Pt(n,i,a)?f=[e,n]:!Pt(s,o,e)&&!Pt(i,t,n)?f=[s,i]:!Pt(r,o,e)&&!Pt(a,t,n)&&(f=[r,a]),f}function Pt(o,t,e){let n;return t<e?n=o<t||o>e:t>e?n=o>t||o<e:n=o!=t,n}function Xn(o,t,...e){let n=-1,s=1/0,i;for(let r=0,a=0,f=e.length;a<f;r++,a+=2)i=qn(o,t,e[a],e[a+1]),i<s&&(s=i,n=r);return n}function qn(o,t,e,n){const s=o-e,i=t-n;return s*s+i*i}function Yn(o,t,e,n,s,i,r,a,f){let h=o[0],u=o[1];h=ce(h,t,n),h=ce(h,i,a),u=ce(u,e,s),u=ce(u,r,f),o[0]=h,o[1]=u}function ce(o,t,e){let n;return Pt(o,t,e)&&(n=Math.abs(o-t)<Math.abs(o-e)?t:e,o=n),o}function Jn(o,t,e,n,s,i,r,a){const f=Math.min(o,e,s,r),h=Math.max(o,e,s,r),u=Math.min(t,n,i,a),c=Math.max(t,n,i,a),l=c-u>h-f;let p=[];return(l?Bt(t,u,c):Bt(o,f,h))&&p.push(o,t),(l?Bt(n,u,c):Bt(e,f,h))&&p.push(e,n),(l?Bt(i,u,c):Bt(s,f,h))&&p.push(s,i),(l?Bt(a,u,c):Bt(r,f,h))&&p.push(r,a),(p.length!=2&&p.length!=4||p.length==4&&p[0]==p[2]&&p[1]==p[3])&&(p=null),p}function Hn(o,t,e,n,s,i,r,a){return o==s&&t==i||o==r&&t==a||e==s&&n==i||e==r&&n==a}function Bt(o,t,e){return o>t&&o<e}function Gn(o,t){Kn(o,t),qe(o,t,0,t.length-2)}function Kn(o,t){for(let e=0,n=t.length;e<n;e+=2)o[t[e]]>o[t[e+1]]&&Qn(t,e,e+1)}function Qn(o,t,e){const n=o[t];o[t]=o[e],o[e]=n}function qe(o,t,e,n){let s=e,i=n,r,a;for(;s<n;){for(r=o[t[e+n>>2<<1]];s<=i;){for(;o[t[s]]<r;)s+=2;for(;o[t[i]]>r;)i-=2;s<=i&&(a=t[s],t[s]=t[i],t[i]=a,a=t[s+1],t[s+1]=t[i+1],t[i+1]=a,s+=2,i-=2)}if(i-e<40?Ye(o,t,e,i):qe(o,t,e,i),n-s<40){Ye(o,t,s,n);return}e=s,i=n}}function Ye(o,t,e,n){let s,i;for(let r=e+2;r<=n;r+=2){s=t[r],i=t[r+1];let a;for(a=r-2;a>=e&&o[s]<o[t[a]];a-=2)t[a+2]=t[a],t[a+3]=t[a+1];t[a+2]=s,t[a+3]=i}}function Je(o,t,e,n,s){const i=o[0],r=o[1];t=He(i,r,t[0],t[1],n,s),e=He(i,r,e[0],e[1],n,s);const a=t[0]<e[0]?t:e,f=a==t?e:t;return{x:i,y:r,a,b:f}}function He(o,t,e,n,s,i){let r=e<n?e:n,a=r===e?n:e;return s[r]==o&&i[r]==t?a=r:s[a]==o&&i[a]==t&&(r=a),[r,a]}function Ge(o){const t={};return o.filter(e=>{const n=Zn(e);return n in t?!1:(t[n]=!0,!0)})}function Zn(o){return`${o.a.join(",")};${o.b.join(",")}`}class ti{constructor(t,e){rt(this,"_i",0);rt(this,"_n",0);rt(this,"_inc",1);rt(this,"_xx");rt(this,"_yy");rt(this,"i",0);rt(this,"x",0);rt(this,"y",0);this._xx=t,this._yy=e}}function ei(o,t,e,n){let s=e|0;const i=isNaN(n)?o.length-s:n+s;let r,a,f,h,u,c;if(i>0)f=u=o[s],h=c=t[s];else return[void 0,void 0,void 0,void 0];for(s++;s<i;s++)r=o[s],a=t[s],r<f&&(f=r),r>u&&(u=r),a<h&&(h=a),a>c&&(c=a);return[f,h,u,c]}class he{constructor(...t){rt(this,"xmin");rt(this,"ymin");rt(this,"xmax");rt(this,"ymax");t.length>0&&this.setBounds(t)}cloneBounds(){return this.clone()}clone(){return new he(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,n,s){return arguments.length==1&&(ke(t)?(e=t[1],n=t[2],s=t[3],t=t[0]):(e=t.ymin,n=t.xmax,s=t.ymax,t=t.xmin)),this.xmin=t,this.ymin=e,this.xmax=n,this.ymax=s,(t>n||e>s)&&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 n,s,i,r;return t instanceof he?(n=t.xmin,s=t.ymin,i=t.xmax,r=t.ymax):e.length==3?(n=t,s=e[0],i=e[1],r=e[2]):t.length==4?(n=t[0],s=t[1],i=t[2],r=t[3]):ye("Bounds#mergeBounds() invalid argument:",t),this.xmin===void 0?this.setBounds(n,s,i,r):(n<this.xmin&&(this.xmin=n),s<this.ymin&&(this.ymin=s),i>this.xmax&&(this.xmax=i),r>this.ymax&&(this.ymax=r)),this}}function Ke(o){const t=["a","b","c"].map(e=>o.properties[e].index);return[[0,1],[0,2],[1,2],[0,1,2]].map(e=>e.map(n=>t[n]).sort().join("-")).sort()}function Qe(o,t,e){const n=Ke(t.forw),s=Ke(t.bakw);if(JSON.stringify(n)!=JSON.stringify(s))throw`${JSON.stringify(t,null,2)}
2
+ ${JSON.stringify(n)}
3
+ ${JSON.stringify(s)}`;for(let i=0;i<n.length;i++){const r=n[i];o[r]||(o[r]=[]),o[r].push(t)}e&&(e.forw.features.push(t.forw),e.bakw.features.push(t.bakw))}function Qt(o,t,e){return ut.point(o,{target:{geom:t,index:e}})}function Zt(o){return ut.point(o.properties.target.geom,{target:{geom:o.geometry.coordinates,index:o.properties.target.index}})}function xe(o,t){const e=t.geometry.coordinates;return[0,1,2,3].map(n=>{const s=(n+1)%4,i=o[n],r=o[s],a=i.geometry.coordinates,f=Math.atan2(a[0]-e[0],a[1]-e[1]),h=[t,i,r,t].map(l=>l.geometry.coordinates),u={a:{geom:t.properties.target.geom,index:t.properties.target.index},b:{geom:i.properties.target.geom,index:i.properties.target.index},c:{geom:r.properties.target.geom,index:r.properties.target.index}},c=ut.featureCollection([ut.polygon([h],u)]);return[f,c]}).reduce((n,s)=>(n[0].push(s[0]),n[1].push(s[1]),n),[[],[]])}const Ze=ie;class at extends xn{constructor(e={}){super();rt(this,"importance");rt(this,"priority");rt(this,"pointsSet");e.bounds?this.setBounds(e.bounds):(this.setWh(e.wh),this.vertexMode=e.vertexMode||at.VERTEX_PLAIN),this.strictMode=e.strictMode||at.MODE_AUTO,this.yaxisMode=e.yaxisMode||at.YAXIS_INVERT,this.importance=e.importance||0,this.priority=e.priority||0,this.stateFull=e.stateFull||!1,e.points&&this.setPoints(e.points),e.edges&&this.setEdges(e.edges)}getFormatVersion(){return Ze}setPoints(e){this.yaxisMode===at.YAXIS_FOLLOW&&(e=e.map(n=>[n[0],[n[1][0],-1*n[1][1]]])),this.points=e,this.tins=void 0,this.indexedTins=void 0}setEdges(e=[]){this.edges=$e(e),this.edgeNodes=void 0,this.tins=void 0,this.indexedTins=void 0}setBounds(e){this.bounds=e;let n=e[0][0],s=n,i=e[0][1],r=i;const a=[e[0]];for(let f=1;f<e.length;f++){const h=e[f];h[0]<n&&(n=h[0]),h[0]>s&&(s=h[0]),h[1]<i&&(i=h[1]),h[1]>r&&(r=h[1]),a.push(h)}a.push(e[0]),this.boundsPolygon=ut.polygon([a]),this.xy=[n,i],this.wh=[s-n,r-i],this.vertexMode=at.VERTEX_PLAIN,this.tins=void 0,this.indexedTins=void 0}getCompiled(){var s;const e={};e.version=Ze,e.points=this.points,e.weight_buffer=this.pointsWeightBuffer,e.centroid_point=[this.centroid.forw.geometry.coordinates,this.centroid.forw.properties.target.geom],e.vertices_params=[this.vertices_params.forw[0],this.vertices_params.bakw[0]],e.vertices_points=[];const n=this.vertices_params.forw[1];return n&&[0,1,2,3].map(i=>{const r=n[i].features[0],a=r.geometry.coordinates[0][1],f=r.properties.b.geom;e.vertices_points[i]=[a,f]}),e.strict_status=this.strict_status,e.tins_points=[[]],this.tins.forw.features.map(i=>{e.tins_points[0].push(["a","b","c"].map(r=>i.properties[r].index))}),this.strict_status===at.STATUS_LOOSE?(e.tins_points[1]=[],this.tins.bakw.features.map(i=>{e.tins_points[1].push(["a","b","c"].map(r=>i.properties[r].index))})):this.strict_status===at.STATUS_ERROR&&((s=this.kinks)!=null&&s.bakw)&&(e.kinks_points=this.kinks.bakw.features.map(i=>i.geometry.coordinates)),e.yaxisMode=this.yaxisMode,e.vertexMode=this.vertexMode,e.strictMode=this.strictMode,this.bounds?(e.bounds=this.bounds,e.boundsPolygon=this.boundsPolygon,e.xy=this.xy,e.wh=this.wh):e.wh=this.wh,e.edges=this.edges,e.edgeNodes=this.edgeNodes,e}setWh(e){this.wh=e||[100,100],this.xy=[0,0],this.bounds=void 0,this.boundsPolygon=void 0,this.tins=void 0,this.indexedTins=void 0}setVertexMode(e){this.vertexMode=e,this.tins=void 0,this.indexedTins=void 0}setStrictMode(e){this.strictMode=e,this.tins=void 0,this.indexedTins=void 0}calcurateStrictTin(){const e=this.tins.forw.features.map(i=>mn(i));this.tins.bakw=ut.featureCollection(e);const n={};this.tins.forw.features.forEach((i,r)=>{const a=this.tins.bakw.features[r];Qe(n,{forw:i,bakw:a})});const s=["forw","bakw"].map(i=>{const r=this.tins[i].features.map(a=>a.geometry.coordinates[0]);return ze(r)});s[0].length===0&&s[1].length===0?(this.strict_status=at.STATUS_STRICT,delete this.kinks):(this.strict_status=at.STATUS_ERROR,this.kinks={},s[0].length>0&&(this.kinks.forw=ut.featureCollection(s[0])),s[1].length>0&&(this.kinks.bakw=ut.featureCollection(s[1])))}generatePointsSet(){const e={forw:[],bakw:[]};for(let i=0;i<this.points.length;i++){const r=this.points[i][0],a=this.points[i][1],f=Qt(r,a,i);e.forw.push(f),e.bakw.push(Zt(f))}const n=[];let s=0;this.edgeNodes=[],this.edges||(this.edges=[]);for(let i=0;i<this.edges.length;i++){const r=this.edges[i][2],a=Object.assign([],this.edges[i][0]),f=Object.assign([],this.edges[i][1]);if(a.length===0&&f.length===0){n.push(r);continue}a.unshift(this.points[r[0]][0]),a.push(this.points[r[1]][0]),f.unshift(this.points[r[0]][1]),f.push(this.points[r[1]][1]);const h=[a,f].map(u=>{const c=u.map((p,y,g)=>{if(y===0)return 0;const b=g[y-1];return Math.sqrt(Math.pow(p[0]-b[0],2)+Math.pow(p[1]-b[1],2))}),l=c.reduce((p,y,g)=>g===0?[0]:(p.push(p[g-1]+y),p),[]);return l.map((p,y,g)=>{const b=p/g[g.length-1];return[u[y],c[y],l[y],b]})});h.map((u,c)=>{const l=h[c?0:1];return u.filter((p,y)=>!(y===0||y===u.length-1||p[4]==="handled")).map(p=>{const y=p[0],g=p[3],b=l.reduce((w,M,_,v)=>{if(w)return w;const T=v[_+1];if(M[3]===g)return M[4]="handled",[M];if(M[3]<g&&T&&T[3]>g)return[M,T]},void 0);if(b&&b.length===1)return c===0?[y,b[0][0],g]:[b[0][0],y,g];if(b&&b.length===2){const w=b[0],M=b[1],_=(g-w[3])/(M[3]-w[3]),v=[(M[0][0]-w[0][0])*_+w[0][0],(M[0][1]-w[0][1])*_+w[0][1]];return c===0?[y,v,g]:[v,y,g]}return[]})}).reduce((u,c)=>u.concat(c),[]).sort((u,c)=>u[2]<c[2]?-1:1).map((u,c,l)=>{this.edgeNodes[s]=[u[0],u[1]];const p=Qt(u[0],u[1],`e${s}`);s++,e.forw.push(p),e.bakw.push(Zt(p)),c===0?n.push([r[0],e.forw.length-1]):n.push([e.forw.length-2,e.forw.length-1]),c===l.length-1&&n.push([e.forw.length-1,r[1]])})}return{forw:e.forw,bakw:e.bakw,edges:n}}validateAndPrepareInputs(){const e=this.xy[0]-.05*this.wh[0],n=this.xy[0]+1.05*this.wh[0],s=this.xy[1]-.05*this.wh[1],i=this.xy[1]+1.05*this.wh[1];if(!this.points.reduce((f,h)=>f&&(this.bounds?xt(h[0],this.boundsPolygon):h[0][0]>=e&&h[0][0]<=n&&h[0][1]>=s&&h[0][1]<=i),!0))throw"SOME POINTS OUTSIDE";let a=[];return this.wh&&(a=[[e,s],[n,s],[e,i],[n,i]]),{pointsSet:this.generatePointsSet(),bbox:a,minx:e,maxx:n,miny:s,maxy:i}}updateTin(){let e=this.strictMode;e!==at.MODE_STRICT&&e!==at.MODE_LOOSE&&(e=at.MODE_AUTO);const{pointsSet:n,bbox:s,minx:i,maxx:r,miny:a,maxy:f}=this.validateAndPrepareInputs(),h={forw:ut.featureCollection(n.forw),bakw:ut.featureCollection(n.bakw)},u=Gt(h.forw,n.edges,"target"),c=Gt(h.bakw,n.edges,"target");if(u.features.length===0||c.features.length===0)throw"TOO LINEAR1";const l=Wt(h.forw),p=_e(h.forw);if(!p)throw"TOO LINEAR2";const y={},g=p.geometry.coordinates[0];let b;try{b=g.map(N=>({forw:N,bakw:ne(ut.point(N),u)})),b.forEach(N=>{y[`${N.forw[0]}:${N.forw[1]}`]=N})}catch{throw"TOO LINEAR2"}const w=_e(h.bakw);if(!w)throw"TOO LINEAR2";const M=w.geometry.coordinates[0];try{b=M.map(N=>({bakw:N,forw:ne(ut.point(N),c)})),b.forEach(N=>{y[`${N.forw[0]}:${N.forw[1]}`]=N})}catch{throw"TOO LINEAR2"}const _={forw:l.geometry.coordinates,bakw:ne(l,u)},v=Qt(_.forw,_.bakw,"c");this.centroid={forw:v,bakw:Zt(v)};const T=this.vertexMode===at.VERTEX_BIRDEYE?this.calculateBirdeyeVertices(y,_,s,i,r,a,f):this.calculatePlainVertices(y,_,s,i,r,a,f),I={forw:[],bakw:[]};for(let N=0;N<T.length;N++){const V=T[N].forw,W=T[N].bakw,K=Qt(V,W,`b${N}`),tt=Zt(K);n.forw.push(K),n.bakw.push(tt),I.forw.push(K),I.bakw.push(tt)}this.pointsSet={forw:ut.featureCollection(n.forw),bakw:ut.featureCollection(n.bakw),edges:[]},this.tins={forw:Ie(Gt(this.pointsSet.forw,n.edges,"target"))},(e===at.MODE_STRICT||e===at.MODE_AUTO)&&this.calcurateStrictTin(),(e===at.MODE_LOOSE||e===at.MODE_AUTO&&this.strict_status===at.STATUS_ERROR)&&(this.tins.bakw=Ie(Gt(this.pointsSet.bakw,n.edges,"target")),delete this.kinks,this.strict_status=at.STATUS_LOOSE),this.vertices_params={forw:xe(I.forw,this.centroid.forw),bakw:xe(I.bakw,this.centroid.bakw)},this.addIndexedTin(),this.calculatePointsWeight()}calculatePlainVertices(e,n,s,i,r,a,f){const h=Object.keys(e).reduce((y,g)=>{const b=e[g],w=b.forw,M=b.bakw,_={forw:[w[0]-n.forw[0],w[1]-n.forw[1]],bakw:[M[0]-n.bakw[0],M[1]-n.bakw[1]]},v=_.forw[0]===0?1/0:((_.forw[0]<0?i:r)-n.forw[0])/_.forw[0],T=_.forw[1]===0?1/0:((_.forw[1]<0?a:f)-n.forw[1])/_.forw[1];if(Math.abs(v)/Math.abs(T)<1.1){const I={forw:[_.forw[0]*v+n.forw[0],_.forw[1]*v+n.forw[1]],bakw:[_.bakw[0]*v+n.bakw[0],_.bakw[1]*v+n.bakw[1]]};_.forw[0]<0?y[3].push(I):y[1].push(I)}if(Math.abs(T)/Math.abs(v)<1.1){const I={forw:[_.forw[0]*T+n.forw[0],_.forw[1]*T+n.forw[1]],bakw:[_.bakw[0]*T+n.bakw[0],_.bakw[1]*T+n.bakw[1]]};_.forw[1]<0?y[0].push(I):y[2].push(I)}return y},[[],[],[],[]]);let c=Object.keys(e).reduce((y,g,b,w)=>{const M=e[g],_=M.forw,v=M.bakw,T={forw:[_[0]-n.forw[0],_[1]-n.forw[1]],bakw:[v[0]-n.bakw[0],n.bakw[1]-v[1]]};if(T.forw[0]===0||T.forw[1]===0)return y;let I=0;return T.forw[0]>0&&(I+=1),T.forw[1]>0&&(I+=2),y[I].push([T.forw,T.bakw]),b===w.length-1?y.map(N=>N.reduce((V,W,K,tt)=>{V||(V=[1/0,0,0]);let z=Math.sqrt(Math.pow(W[0][0],2)+Math.pow(W[0][1],2))/Math.sqrt(Math.pow(W[1][0],2)+Math.pow(W[1][1],2));z=z<V[0]?z:V[0];const st=Math.atan2(W[0][0],W[0][1])-Math.atan2(W[1][0],W[1][1]),d=V[1]+Math.cos(st),m=V[2]+Math.sin(st);return K===tt.length-1?[z,Math.atan2(m,d)]:[z,d,m]},null)):y},[[],[],[],[]]);c.length===1&&(c=[c[0],c[0],c[0],c[0]]);const l=c.map((y,g)=>{const b=s[g],w=[b[0]-n.forw[0],b[1]-n.forw[1]],_=Math.sqrt(Math.pow(w[0],2)+Math.pow(w[1],2))/y[0],v=Math.atan2(w[0],w[1])-y[1],T=[n.bakw[0]+_*Math.sin(v),n.bakw[1]-_*Math.cos(v)];return{forw:b,bakw:T}}),p=l[2];return l[2]=l[3],l[3]=p,this.checkAndAdjustVertices(l,h,n),l}calculateBirdeyeVertices(e,n,s,i,r,a,f){return this.calculatePlainVertices(e,n,s,i,r,a,f)}checkAndAdjustVertices(e,n,s){const i=[1,1,1,1];for(let r=0;r<4;r++){const a=(r+1)%4,f=ut.lineString([e[r].bakw,e[a].bakw]);n[r].map(h=>{const u=ut.lineString([s.bakw,h.bakw]),c=tn(f,u);if(c.features.length>0&&c.features[0].geometry){const l=c.features[0],p=Math.sqrt(Math.pow(h.bakw[0]-s.bakw[0],2)+Math.pow(h.bakw[1]-s.bakw[1],2)),y=Math.sqrt(Math.pow(l.geometry.coordinates[0]-s.bakw[0],2)+Math.pow(l.geometry.coordinates[1]-s.bakw[1],2)),g=p/y;g>i[r]&&(i[r]=g),g>i[a]&&(i[a]=g)}})}e.forEach((r,a)=>{const f=i[a],h=[(r.bakw[0]-s.bakw[0])*f+s.bakw[0],(r.bakw[1]-s.bakw[1])*f+s.bakw[1]];r.bakw=h})}calculatePointsWeight(){const e=["forw"];this.strict_status===at.STATUS_LOOSE&&e.push("bakw");const n={};e.forEach(i=>{n[i]={};const r={};this.tins[i].features.map(a=>{const f=["a","b","c"];for(let h=0;h<3;h++){const u=(h+1)%3,c=f[h],l=f[u],p=a.properties[c].index,y=a.properties[l].index,g=[p,y].sort().join("-");if(!r[g]){const b=a.geometry.coordinates[0][h],w=a.geometry.coordinates[0][u],M=a.properties[c].geom,_=a.properties[l].geom;r[g]=1;const v=Math.sqrt(Math.pow(M[0]-_[0],2)+Math.pow(M[1]-_[1],2))/Math.sqrt(Math.pow(b[0]-w[0],2)+Math.pow(b[1]-w[1],2));n[i]||(n[i]={});const T=n[i];T[`${p}:${g}`]=v,T[`${y}:${g}`]=v}}})});const s={};e.map(i=>{s[i]={},this.strict_status===at.STATUS_STRICT&&(s.bakw={});const r=n[i],a={};Object.keys(r).forEach(h=>{const[u]=h.split(":");a[u]||(a[u]=[]),a[u].push(r[h])}),Object.keys(a).forEach(h=>{const u=a[h],c=u.reduce((l,p)=>l+p,0)/u.length;s[i]||(s[i]={}),s[i][h]=c,this.strict_status===at.STATUS_STRICT&&(s.bakw||(s.bakw={}),s.bakw[h]=1/c)});let f=0;for(let h=0;h<4;h++){const u=`b${h}`,c=s[i][u]||0;f+=c}s[i].c=f/4,this.strict_status===at.STATUS_STRICT&&s.bakw&&(s.bakw.c=1/s[i].c)}),this.pointsWeightBuffer=s}}ot.Tin=at,ot.constrainedTin=Gt,ot.counterPoint=Zt,ot.createPoint=Qt,ot.findIntersections=ze,ot.format_version=ie,ot.insertSearchIndex=Qe,ot.vertexCalc=xe,Object.defineProperty(ot,Symbol.toStringTag,{value:"Module"})});
@@ -0,0 +1,24 @@
1
+ import { Feature, Point, Position } from 'geojson';
2
+ import { Tins } from '@maplat/transform';
3
+ /**
4
+ * 座標と属性から点オブジェクトを生成する
5
+ * @param xy 座標値
6
+ * @param geom 変換先での座標値
7
+ * @param index インデックス
8
+ * @returns 生成された点オブジェクト
9
+ */
10
+ declare function createPoint(xy: Position, geom: Position, index: string | number): Feature<Point>;
11
+ /**
12
+ * 点オブジェクトの座標系を反転する
13
+ * @param apoint 元の点オブジェクト
14
+ * @returns 座標系が反転された点オブジェクト
15
+ */
16
+ declare function counterPoint(apoint: Feature<Point>): Feature<Point>;
17
+ /**
18
+ * 頂点リストから頂点パラメータを計算する
19
+ * @param list 頂点リスト
20
+ * @param centroid 重心点
21
+ * @returns [角度リスト, 三角形リスト]
22
+ */
23
+ declare function vertexCalc(list: Feature<Point>[], centroid: Feature<Point>): [number[], Tins[]?];
24
+ export { counterPoint, createPoint, vertexCalc };
package/package.json CHANGED
@@ -1,87 +1,99 @@
1
- {
2
- "name": "@maplat/tin",
3
- "private": false,
4
- "publishConfig": {
5
- "access": "public"
6
- },
7
- "version": "0.11.0",
8
- "description": "JavaScript library which performs homeomorphic conversion mutually between the coordinate systems of two planes based on the control points.",
9
- "type": "module",
10
- "main": "./dist/maplat_tin.cjs",
11
- "module": "./dist/maplat_tin.js",
12
- "browser": "./dist/maplat_tin.umd.js",
13
- "types": "./dist/index.d.ts",
14
- "exports": {
15
- ".": {
16
- "import": "./dist/maplat_tin.js",
17
- "require": "./dist/maplat_tin.cjs",
18
- "browser": "./dist/maplat_tin.umd.js",
19
- "types": "./dist/index.d.ts"
20
- }
21
- },
22
- "files": [
23
- "dist",
24
- "src",
25
- "README.md"
26
- ],
27
- "scripts": {
28
- "dev": "vite",
29
- "build": "tsc && cross-env BUILD_MODE=package vite build",
30
- "deploy": "cp public/*.html ./ && tsc && vite build",
31
- "test": "vitest run",
32
- "test:watch": "vitest",
33
- "coverage": "vitest run --coverage",
34
- "lint": "eslint src tests",
35
- "typecheck": "tsc --noEmit",
36
- "prepublishOnly": "npm run build"
37
- },
38
- "repository": {
39
- "type": "git",
40
- "url": "git+https://github.com/code4history/MaplatTin.git"
41
- },
42
- "author": "Code for History",
43
- "license": "Maplat Limited License 1.1",
44
- "bugs": {
45
- "url": "https://github.com/code4history/MaplatTin/issues"
46
- },
47
- "homepage": "https://github.com/code4history/MaplatTin/wiki",
48
- "keywords": [
49
- "triangulation",
50
- "warp",
51
- "GIS",
52
- "Maplat",
53
- "MaplatTin"
54
- ],
55
- "peerDependencies": {
56
- "delaunator": "^5.0.0"
57
- },
58
- "devDependencies": {
59
- "@eslint/js": "^9.17.0",
60
- "@testing-library/jest-dom": "^6.6.3",
61
- "@types/delaunator": "^5.0.3",
62
- "@types/geojson": "^7946.0.15",
63
- "@types/node": "^22.10.2",
64
- "@typescript-eslint/eslint-plugin": "^8.18.2",
65
- "@typescript-eslint/parser": "^8.18.2",
66
- "@vitest/coverage-v8": "^1.6.0",
67
- "cross-env": "^7.0.3",
68
- "eslint": "^9.17.0",
69
- "eslint-config-prettier": "^9.1.0",
70
- "jest-matcher-deep-close-to": "^3.0.2",
71
- "jsdom": "^25.0.1",
72
- "prettier": "^3.4.2",
73
- "typescript": "^5.7.2",
74
- "vite": "^5.4.11",
75
- "vite-plugin-dts": "^4.4.0",
76
- "vitest": "^1.6.0"
77
- },
78
- "dependencies": {
79
- "@maplat/edgeruler": "^0.1.1",
80
- "@maplat/transform": "^0.1.5",
81
- "@turf/boolean-point-in-polygon": "^7.2.0",
82
- "@turf/centroid": "^7.2.0",
83
- "@turf/convex": "^7.2.0",
84
- "@turf/helpers": "^7.2.0",
85
- "@turf/line-intersect": "^7.2.0"
86
- }
87
- }
1
+ {
2
+ "name": "@maplat/tin",
3
+ "private": false,
4
+ "publishConfig": {
5
+ "access": "public"
6
+ },
7
+ "version": "0.11.2",
8
+ "description": "JavaScript library which performs homeomorphic conversion mutually between the coordinate systems of two planes based on the control points.",
9
+ "type": "module",
10
+ "main": "./dist/maplat_edgebound.cjs",
11
+ "module": "./dist/maplat_tin.js",
12
+ "types": "./dist/index.d.ts",
13
+ "exports": {
14
+ ".": {
15
+ "types": "./dist/index.d.ts",
16
+ "browser": "./dist/maplat_tin.umd.js",
17
+ "import": "./dist/maplat_tin.js",
18
+ "require": "./dist/maplat_tin.cjs"
19
+ }
20
+ },
21
+ "files": [
22
+ "dist",
23
+ "src",
24
+ "README.md",
25
+ "README.ja.md",
26
+ "LICENSE"
27
+ ],
28
+ "scripts": {
29
+ "dev": "vite",
30
+ "build": "npm run typecheck && cross-env BUILD_MODE=package vite build",
31
+ "typecheck": "tsc --noEmit --allowImportingTsExtensions",
32
+ "test": "vitest run",
33
+ "test:watch": "vitest",
34
+ "coverage": "vitest run --coverage",
35
+ "lint": "eslint src tests",
36
+ "prepublishOnly": "npm run lint && npm run typecheck && npm run test && npm run build",
37
+ "version:bump": "node scripts/bump-version.js",
38
+ "version:sync": "node scripts/sync-version.js",
39
+ "publish:npm": "node scripts/publish-npm.js",
40
+ "publish:npm:dry": "node scripts/publish-npm.js --dry-run",
41
+ "publish:deno": "node scripts/publish-deno.js",
42
+ "publish:deno:dry": "node scripts/publish-deno.js --dry-run",
43
+ "publish:all": "node scripts/publish-all.js",
44
+ "publish:all:dry": "node scripts/publish-all.js --dry-run"
45
+ },
46
+ "repository": {
47
+ "type": "git",
48
+ "url": "git+https://github.com/code4history/MaplatTin.git"
49
+ },
50
+ "author": "Code for History",
51
+ "license": "Maplat Limited License 1.1",
52
+ "bugs": {
53
+ "url": "https://github.com/code4history/MaplatTin/issues"
54
+ },
55
+ "homepage": "https://github.com/code4history/MaplatTin/wiki",
56
+ "keywords": [
57
+ "triangulation",
58
+ "warp",
59
+ "GIS",
60
+ "Maplat",
61
+ "MaplatTin",
62
+ "deno"
63
+ ],
64
+ "dependencies": {
65
+ "@maplat/edgebound": "^0.2.2",
66
+ "@maplat/transform": "^0.2.2"
67
+ },
68
+ "peerDependencies": {
69
+ "@turf/boolean-point-in-polygon": "^7.2.0",
70
+ "@turf/centroid": "^7.2.0",
71
+ "@turf/convex": "^7.2.0",
72
+ "@turf/helpers": "^7.2.0",
73
+ "@turf/line-intersect": "^7.2.0",
74
+ "delaunator": "^5.0.0"
75
+ },
76
+ "devDependencies": {
77
+ "@eslint/js": "^9.17.0",
78
+ "@testing-library/jest-dom": "^6.6.3",
79
+ "@types/delaunator": "^5.0.3",
80
+ "@types/geojson": "^7946.0.15",
81
+ "@types/node": "^22.10.2",
82
+ "@typescript-eslint/eslint-plugin": "^8.18.2",
83
+ "@typescript-eslint/parser": "^8.18.2",
84
+ "@vitest/coverage-v8": "^3.2.4",
85
+ "cross-env": "^7.0.3",
86
+ "dotenv": "^16.5.0",
87
+ "dotenv-cli": "^8.0.0",
88
+ "eslint": "^9.17.0",
89
+ "eslint-config-prettier": "^9.1.0",
90
+ "jest-matcher-deep-close-to": "^3.0.2",
91
+ "jsdom": "^25.0.1",
92
+ "prettier": "^3.4.2",
93
+ "typescript": "^5.7.2",
94
+ "typescript-eslint": "^8.34.1",
95
+ "vite": "^6.3.5",
96
+ "vite-plugin-dts": "^4.4.0",
97
+ "vitest": "^3.2.4"
98
+ }
99
+ }
@@ -1,44 +1,50 @@
1
- import { polygon, featureCollection } from "@turf/helpers";
2
- import { FeatureCollection } from "geojson";
1
+ import { featureCollection, polygon } from "@turf/helpers";
2
+ import type { FeatureCollection, Point, Polygon } from "geojson";
3
3
  import Delaunator from "delaunator";
4
- import EdgeRuler from "@maplat/edgeruler"
5
- import { Edge } from "@maplat/transform";
4
+ import { Constrain as EdgeBound } from "@maplat/edgebound";
5
+ import type { Edge } from "@maplat/transform";
6
+ import type { TriangleProperties } from "./types/tin.d.ts";
6
7
 
7
8
  /**
8
9
  * 制約付きTIN(Triangulated Irregular Network)を生成します
9
- *
10
+ *
10
11
  * 点群から三角形分割を行い、指定されたエッジ(制約線)を
11
12
  * 必ず三角形の辺として含むように調整します。
12
- *
13
+ *
13
14
  * @param points - 点群を含むFeatureCollection
14
15
  * 各Featureは座標を持つPointである必要があります
15
16
  * @param edges - 制約として扱うエッジの配列
16
17
  * 各エッジは2つの頂点インデックスの組として指定
17
18
  * @param z - 生成される三角形のプロパティに含める項目の名前
18
19
  * (例: "target")
19
- *
20
+ *
20
21
  * @returns 三角形のFeatureCollectionを返します
21
22
  * 各三角形は以下の情報を持ちます:
22
23
  * - geometry: 三角形の座標
23
24
  * - properties: 頂点に関連付けられた情報(a, b, cプロパティ)
24
- *
25
+ *
25
26
  * @throws {Error} pointsがFeatureCollectionでない場合
26
27
  * @throws {Error} edgesが配列でない場合
27
- *
28
+ *
28
29
  * 処理の流れ:
29
30
  * 1. Delaunay三角分割を実行
30
31
  * 2. 制約エッジに基づいて三角分割を調整
31
32
  * 3. 結果をGeoJSON形式に変換
32
33
  */
33
- export default function (points: FeatureCollection, edges: Edge[], z: string) {
34
+ export default function (
35
+ points: FeatureCollection<Point>,
36
+ edges: Edge[],
37
+ z: string,
38
+ ): FeatureCollection<Polygon> {
34
39
  if (!edges) edges = [];
35
- if (typeof points !== "object" || points.type !== "FeatureCollection")
40
+ if (typeof points !== "object" || points.type !== "FeatureCollection") {
36
41
  throw "Argument points must be FeatureCollection";
42
+ }
37
43
  if (!Array.isArray(edges)) throw "Argument points must be Array of Array";
38
44
 
39
45
  // Delaunay三角分割の実行
40
46
  const del_points = points.features.map(
41
- point => (point.geometry as any).coordinates as number[]
47
+ (point) => point.geometry!.coordinates as number[],
42
48
  );
43
49
  const del = Delaunator.from(del_points);
44
50
 
@@ -46,7 +52,7 @@ export default function (points: FeatureCollection, edges: Edge[], z: string) {
46
52
  let con;
47
53
  const tris = [];
48
54
  if (del.triangles.length !== 0 && edges.length !== 0) {
49
- con = new EdgeRuler(del);
55
+ con = new EdgeBound(del);
50
56
  con.constrainAll(edges);
51
57
  }
52
58
 
@@ -58,11 +64,11 @@ export default function (points: FeatureCollection, edges: Edge[], z: string) {
58
64
  // GeoJSON形式での出力
59
65
  const keys = ["a", "b", "c"] as const;
60
66
  return featureCollection(
61
- tris.map(indices => {
62
- const properties: any = {};
67
+ tris.map((indices) => {
68
+ const properties: TriangleProperties = {};
63
69
  const coords = indices.map((index, i) => {
64
70
  const point = points.features[index];
65
- const xyz = (point.geometry as any).coordinates as number[];
71
+ const xyz = point.geometry!.coordinates as number[];
66
72
  const coord: number[] = [xyz[0], xyz[1]];
67
73
  if (xyz.length === 3) {
68
74
  coord[2] = xyz[2];
@@ -73,6 +79,6 @@ export default function (points: FeatureCollection, edges: Edge[], z: string) {
73
79
  });
74
80
  coords[3] = coords[0];
75
81
  return polygon([coords], properties);
76
- })
82
+ }),
77
83
  );
78
84
  }