@maplat/transform 0.5.0 → 0.5.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.
@@ -1 +1 @@
1
- (function(O,k){typeof exports=="object"&&typeof module<"u"?k(exports):typeof define=="function"&&define.amd?define(["exports"],k):(O=typeof globalThis<"u"?globalThis:O||self,k(O.maplat_transform={}))})(this,(function(O){"use strict";var Wt=Object.defineProperty;var Xt=(O,k,R)=>k in O?Wt(O,k,{enumerable:!0,configurable:!0,writable:!0,value:R}):O[k]=R;var x=(O,k,R)=>Xt(O,typeof k!="symbol"?k+"":k,R);function k(t,e,r={}){const n={type:"Feature"};return(r.id===0||r.id)&&(n.id=r.id),r.bbox&&(n.bbox=r.bbox),n.properties=e||{},n.geometry=t,n}function R(t,e,r={}){if(!t)throw new Error("coordinates is required");if(!Array.isArray(t))throw new Error("coordinates must be an Array");if(t.length<2)throw new Error("coordinates must be at least 2 numbers long");if(!K(t[0])||!K(t[1]))throw new Error("coordinates must contain numbers");return k({type:"Point",coordinates:t},e,r)}function J(t,e,r={}){for(const c of t){if(c.length<4)throw new Error("Each LinearRing of a Polygon must have 4 or more Positions.");if(c[c.length-1].length!==c[0].length)throw new Error("First and last Position are not equivalent.");for(let i=0;i<c[c.length-1].length;i++)if(c[c.length-1][i]!==c[0][i])throw new Error("First and last Position are not equivalent.")}return k({type:"Polygon",coordinates:t},e,r)}function X(t,e={}){const r={type:"FeatureCollection"};return e.id&&(r.id=e.id),e.bbox&&(r.bbox=e.bbox),r.features=t,r}function K(t){return!isNaN(t)&&t!==null&&!Array.isArray(t)}function at(t){if(!t)throw new Error("coord is required");if(!Array.isArray(t)){if(t.type==="Feature"&&t.geometry!==null&&t.geometry.type==="Point")return[...t.geometry.coordinates];if(t.type==="Point")return[...t.coordinates]}if(Array.isArray(t)&&t.length>=2&&!Array.isArray(t[0])&&!Array.isArray(t[1]))return[...t];throw new Error("coord must be GeoJSON Point or an Array of numbers")}function Q(t){if(Array.isArray(t))return t;if(t.type==="Feature"){if(t.geometry!==null)return t.geometry.coordinates}else if(t.coordinates)return t.coordinates;throw new Error("coords must be GeoJSON Feature, Geometry Object or an Array")}function ct(t){return t.type==="Feature"?t.geometry:t}const F=11102230246251565e-32,P=134217729,ft=(3+8*F)*F;function $(t,e,r,n,c){let i,f,g,h,l=e[0],y=n[0],o=0,u=0;y>l==y>-l?(i=l,l=e[++o]):(i=y,y=n[++u]);let b=0;if(o<t&&u<r)for(y>l==y>-l?(f=l+i,g=i-(f-l),l=e[++o]):(f=y+i,g=i-(f-y),y=n[++u]),i=f,g!==0&&(c[b++]=g);o<t&&u<r;)y>l==y>-l?(f=i+l,h=f-i,g=i-(f-h)+(l-h),l=e[++o]):(f=i+y,h=f-i,g=i-(f-h)+(y-h),y=n[++u]),i=f,g!==0&&(c[b++]=g);for(;o<t;)f=i+l,h=f-i,g=i-(f-h)+(l-h),l=e[++o],i=f,g!==0&&(c[b++]=g);for(;u<r;)f=i+y,h=f-i,g=i-(f-h)+(y-h),y=n[++u],i=f,g!==0&&(c[b++]=g);return(i!==0||b===0)&&(c[b++]=i),b}function ut(t,e){let r=e[0];for(let n=1;n<t;n++)r+=e[n];return r}function Y(t){return new Float64Array(t)}const dt=(3+16*F)*F,ht=(2+12*F)*F,gt=(9+64*F)*F*F,V=Y(4),H=Y(8),Z=Y(12),tt=Y(16),T=Y(4);function lt(t,e,r,n,c,i,f){let g,h,l,y,o,u,b,p,d,a,s,m,M,v,_,w,A,S;const I=t-c,N=r-c,B=e-i,C=n-i;v=I*C,u=P*I,b=u-(u-I),p=I-b,u=P*C,d=u-(u-C),a=C-d,_=p*a-(v-b*d-p*d-b*a),w=B*N,u=P*B,b=u-(u-B),p=B-b,u=P*N,d=u-(u-N),a=N-d,A=p*a-(w-b*d-p*d-b*a),s=_-A,o=_-s,V[0]=_-(s+o)+(o-A),m=v+s,o=m-v,M=v-(m-o)+(s-o),s=M-w,o=M-s,V[1]=M-(s+o)+(o-w),S=m+s,o=S-m,V[2]=m-(S-o)+(s-o),V[3]=S;let W=ut(4,V),L=ht*f;if(W>=L||-W>=L||(o=t-I,g=t-(I+o)+(o-c),o=r-N,l=r-(N+o)+(o-c),o=e-B,h=e-(B+o)+(o-i),o=n-C,y=n-(C+o)+(o-i),g===0&&h===0&&l===0&&y===0)||(L=gt*f+ft*Math.abs(W),W+=I*y+C*g-(B*l+N*h),W>=L||-W>=L))return W;v=g*C,u=P*g,b=u-(u-g),p=g-b,u=P*C,d=u-(u-C),a=C-d,_=p*a-(v-b*d-p*d-b*a),w=h*N,u=P*h,b=u-(u-h),p=h-b,u=P*N,d=u-(u-N),a=N-d,A=p*a-(w-b*d-p*d-b*a),s=_-A,o=_-s,T[0]=_-(s+o)+(o-A),m=v+s,o=m-v,M=v-(m-o)+(s-o),s=M-w,o=M-s,T[1]=M-(s+o)+(o-w),S=m+s,o=S-m,T[2]=m-(S-o)+(s-o),T[3]=S;const Rt=$(4,V,4,T,H);v=I*y,u=P*I,b=u-(u-I),p=I-b,u=P*y,d=u-(u-y),a=y-d,_=p*a-(v-b*d-p*d-b*a),w=B*l,u=P*B,b=u-(u-B),p=B-b,u=P*l,d=u-(u-l),a=l-d,A=p*a-(w-b*d-p*d-b*a),s=_-A,o=_-s,T[0]=_-(s+o)+(o-A),m=v+s,o=m-v,M=v-(m-o)+(s-o),s=M-w,o=M-s,T[1]=M-(s+o)+(o-w),S=m+s,o=S-m,T[2]=m-(S-o)+(s-o),T[3]=S;const Ut=$(Rt,H,4,T,Z);v=g*y,u=P*g,b=u-(u-g),p=g-b,u=P*y,d=u-(u-y),a=y-d,_=p*a-(v-b*d-p*d-b*a),w=h*l,u=P*h,b=u-(u-h),p=h-b,u=P*l,d=u-(u-l),a=l-d,A=p*a-(w-b*d-p*d-b*a),s=_-A,o=_-s,T[0]=_-(s+o)+(o-A),m=v+s,o=m-v,M=v-(m-o)+(s-o),s=M-w,o=M-s,T[1]=M-(s+o)+(o-w),S=m+s,o=S-m,T[2]=m-(S-o)+(s-o),T[3]=S;const Ft=$(Ut,Z,4,T,tt);return tt[Ft-1]}function yt(t,e,r,n,c,i){const f=(e-i)*(r-c),g=(t-c)*(n-i),h=f-g,l=Math.abs(f+g);return Math.abs(h)>=dt*l?h:-lt(t,e,r,n,c,i,l)}function bt(t,e){var r,n,c=0,i,f,g,h,l,y,o,u=t[0],b=t[1],p=e.length;for(r=0;r<p;r++){n=0;var d=e[r],a=d.length-1;if(y=d[0],y[0]!==d[a][0]&&y[1]!==d[a][1])throw new Error("First and last coordinates in a ring must be the same");for(f=y[0]-u,g=y[1]-b,n;n<a;n++){if(o=d[n+1],h=o[0]-u,l=o[1]-b,g===0&&l===0){if(h<=0&&f>=0||f<=0&&h>=0)return 0}else if(l>=0&&g<=0||l<=0&&g>=0){if(i=yt(f,h,g,l,0,0),i===0)return 0;(i>0&&l>0&&g<=0||i<0&&l<=0&&g>0)&&c++}y=o,g=l,f=h}}return c%2!==0}function D(t,e,r={}){if(!t)throw new Error("point is required");if(!e)throw new Error("polygon is required");const n=at(t),c=ct(e),i=c.type,f=e.bbox;let g=c.coordinates;if(f&&mt(n,f)===!1)return!1;i==="Polygon"&&(g=[g]);let h=!1;for(var l=0;l<g.length;++l){const y=bt(n,g[l]);if(y===0)return!r.ignoreBoundary;y&&(h=!0)}return h}function mt(t,e){return e[0]<=t[0]&&e[1]<=t[1]&&e[2]>=t[0]&&e[3]>=t[1]}function q(t,e){for(let r=0;r<e.features.length;r++)if(D(t,e.features[r]))return e.features[r]}function et(t,e,r){const n=e.geometry.coordinates[0][0],c=e.geometry.coordinates[0][1],i=e.geometry.coordinates[0][2],f=t.geometry.coordinates,g=e.properties.a.geom,h=e.properties.b.geom,l=e.properties.c.geom,y=[c[0]-n[0],c[1]-n[1]],o=[i[0]-n[0],i[1]-n[1]],u=[f[0]-n[0],f[1]-n[1]],b=[h[0]-g[0],h[1]-g[1]],p=[l[0]-g[0],l[1]-g[1]];let d=(o[1]*u[0]-o[0]*u[1])/(y[0]*o[1]-y[1]*o[0]),a=(y[0]*u[1]-y[1]*u[0])/(y[0]*o[1]-y[1]*o[0]);if(r){const s=r[e.properties.a.index],m=r[e.properties.b.index],M=r[e.properties.c.index];let v;if(d<0||a<0||1-d-a<0){const _=d/(d+a),w=a/(d+a);v=d/m/(_/m+w/M),a=a/M/(_/m+w/M)}else v=d/m/(d/m+a/M+(1-d-a)/s),a=a/M/(d/m+a/M+(1-d-a)/s);d=v}return[d*b[0]+a*p[0]+g[0],d*b[1]+a*p[1]+g[1]]}function wt(t,e,r,n){const c=t.geometry.coordinates,i=r.geometry.coordinates,f=Math.atan2(c[0]-i[0],c[1]-i[1]),g=xt(f,e[0]);if(g===void 0)throw new Error("Unable to determine vertex index");const h=e[1][g];return et(t,h.features[0],n)}function rt(t,e,r,n,c,i,f,g){let h;if(f&&(h=q(t,X([f]))),!h)if(r){const l=t.geometry.coordinates,y=r.gridNum,o=r.xOrigin,u=r.yOrigin,b=r.xUnit,p=r.yUnit,d=r.gridCache,a=U(l[0],o,b,y),s=U(l[1],u,p,y),m=d[a]?d[a][s]?d[a][s]:[]:[],M=X(m.map(v=>e.features[v]));h=q(t,M)}else h=q(t,e);return g&&g(h),h?et(t,h,i):wt(t,n,c,i)}function U(t,e,r,n){let c=Math.floor((t-e)/r);return c<0&&(c=0),c>=n&&(c=n-1),c}function xt(t,e){let r=nt(t-e[0]),n=Math.PI*2,c;for(let i=0;i<e.length;i++){const f=(i+1)%e.length,g=nt(t-e[f]),h=Math.min(Math.abs(r),Math.abs(g));r*g<=0&&h<n&&(n=h,c=i),r=g}return c}function nt(t,e=!1){const r=2*Math.PI,n=t-Math.floor(t/r)*r;return e?n:n>Math.PI?n-r:n}function it(t,e){return e&&e>=2.00703||Array.isArray(t[0])?t:t.map(r=>[r.illstNodes,r.mercNodes,r.startEnd])}function pt(t){const e=t.features;for(let r=0;r<e.length;r++){const n=e[r];`${n.properties.a.index}`.substring(0,1)==="b"&&`${n.properties.b.index}`.substring(0,1)==="b"?e[r]={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"&&(e[r]={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 t}function vt(t){const e=["a","b","c","a"].map(i=>t.properties[i].geom),r=t.geometry.coordinates[0],n=t.properties,c={a:{geom:r[0],index:n.a.index},b:{geom:r[1],index:n.b.index},c:{geom:r[2],index:n.c.index}};return J([e],c)}function Mt(t){const e=[0,1,2,0].map(n=>t[n][0][0]),r={a:{geom:t[0][0][1],index:t[0][1]},b:{geom:t[1][0][1],index:t[1][1]},c:{geom:t[2][0][1],index:t[2][1]}};return J([e],r)}function z(t,e,r,n,c,i=!1,f){const g=t.map(h=>{(!f||f<2.00703)&&(h=st(h));const l=isFinite(h)?e[h]:h==="c"?n:(function(){const y=h.match(/^b(\d+)$/);if(y)return c[parseInt(y[1])];const o=h.match(/^e(\d+)$/);if(o)return r[parseInt(o[1])];throw new Error("Bad index value for indexesToTri")})();return i?[[l[1],l[0]],h]:[[l[0],l[1]],h]});return Mt(g)}function st(t){return typeof t=="number"?t:t.replace(/^(c|e|b)(?:ent|dgeNode|box)(\d+)?$/,"$1$2")}const j=2.00703;function At(t){return!!(t.version!==void 0||!t.tins&&t.points&&t.tins_points)}function _t(t){return{points:t.points,pointsWeightBuffer:Ot(t),strictStatus:Pt(t),verticesParams:St(t),centroid:Tt(t),edges:it(t.edges||[]),edgeNodes:t.edgeNodes||[],tins:kt(t),kinks:It(t.kinks_points),yaxisMode:t.yaxisMode??"invert",strictMode:t.strictMode??"auto",vertexMode:t.vertexMode,bounds:t.bounds,boundsPolygon:t.boundsPolygon,wh:t.wh,xy:t.xy??[0,0]}}function Et(t){const e=Nt(t),r=e.tins;return{compiled:e,tins:r,points:Bt(r),strictStatus:e.strict_status,pointsWeightBuffer:e.weight_buffer,verticesParams:e.vertices_params,centroid:e.centroid,kinks:e.kinks}}function Ot(t){return!t.version||t.version<j?["forw","bakw"].reduce((e,r)=>{const n=t.weight_buffer[r];return n&&(e[r]=Object.keys(n).reduce((c,i)=>{const f=st(i);return c[f]=n[i],c},{})),e},{}):t.weight_buffer}function Pt(t){return t.strict_status?t.strict_status:t.kinks_points?"strict_error":t.tins_points.length===2?"loose":"strict"}function St(t){const e={forw:[t.vertices_params[0]],bakw:[t.vertices_params[1]]};return e.forw[1]=ot(t,!1),e.bakw[1]=ot(t,!0),e}function ot(t,e){const r=t.vertices_points.length;return Array.from({length:r},(n,c)=>{const i=(c+1)%r,f=z(["c",`b${c}`,`b${i}`],t.points,t.edgeNodes||[],t.centroid_point,t.vertices_points,e,j);return X([f])})}function Tt(t){return{forw:R(t.centroid_point[0],{target:{geom:t.centroid_point[1],index:"c"}}),bakw:R(t.centroid_point[1],{target:{geom:t.centroid_point[0],index:"c"}})}}function kt(t){const e=t.tins_points.length===1?0:1;return{forw:X(t.tins_points[0].map(r=>z(r,t.points,t.edgeNodes||[],t.centroid_point,t.vertices_points,!1,t.version))),bakw:X(t.tins_points[e].map(r=>z(r,t.points,t.edgeNodes||[],t.centroid_point,t.vertices_points,!0,t.version)))}}function It(t){if(t)return{bakw:X(t.map(e=>R(e)))}}function Nt(t){return JSON.parse(JSON.stringify(t).replace('"cent"','"c"').replace(/"bbox(\d+)"/g,'"b$1"'))}function Bt(t){const e=[],r=t.forw.features;for(let n=0;n<r.length;n++){const c=r[n];["a","b","c"].forEach((i,f)=>{const g=c.geometry.coordinates[0][f],h=c.properties[i].geom,l=c.properties[i].index;typeof l=="number"&&(e[l]=[g,h])})}return e}const Ct=j,E=class E{constructor(){x(this,"points",[]);x(this,"pointsWeightBuffer");x(this,"strict_status");x(this,"vertices_params");x(this,"centroid");x(this,"edgeNodes");x(this,"edges");x(this,"tins");x(this,"kinks");x(this,"yaxisMode",E.YAXIS_INVERT);x(this,"strictMode",E.MODE_AUTO);x(this,"vertexMode",E.VERTEX_PLAIN);x(this,"bounds");x(this,"boundsPolygon");x(this,"wh");x(this,"xy");x(this,"indexedTins");x(this,"stateFull",!1);x(this,"stateTriangle");x(this,"stateBackward");x(this,"priority");x(this,"importance");x(this,"xyBounds");x(this,"mercBounds")}setCompiled(e){if(At(e)){this.applyModernState(_t(e));return}this.applyLegacyState(Et(e))}applyModernState(e){this.points=e.points,this.pointsWeightBuffer=e.pointsWeightBuffer,this.strict_status=e.strictStatus,this.vertices_params=e.verticesParams,this.centroid=e.centroid,this.edges=e.edges,this.edgeNodes=e.edgeNodes||[],this.tins=e.tins,this.addIndexedTin(),this.kinks=e.kinks,this.yaxisMode=e.yaxisMode??E.YAXIS_INVERT,this.vertexMode=e.vertexMode??E.VERTEX_PLAIN,this.strictMode=e.strictMode??E.MODE_AUTO,e.bounds?(this.bounds=e.bounds,this.boundsPolygon=e.boundsPolygon,this.xy=e.xy,this.wh=e.wh):(this.bounds=void 0,this.boundsPolygon=void 0,this.xy=e.xy??[0,0],e.wh&&(this.wh=e.wh))}applyLegacyState(e){this.tins=e.tins,this.addIndexedTin(),this.strict_status=e.strictStatus,this.pointsWeightBuffer=e.pointsWeightBuffer,this.vertices_params=e.verticesParams,this.centroid=e.centroid,this.kinks=e.kinks,this.points=e.points}addIndexedTin(){const e=this.tins,r=e.forw,n=e.bakw,c=Math.ceil(Math.sqrt(r.features.length));if(c<3){this.indexedTins=void 0;return}let i=[],f=[];const g=r.features.map(d=>{let a=[];return Q(d)[0].map(s=>{i.length===0?i=[Array.from(s),Array.from(s)]:(s[0]<i[0][0]&&(i[0][0]=s[0]),s[0]>i[1][0]&&(i[1][0]=s[0]),s[1]<i[0][1]&&(i[0][1]=s[1]),s[1]>i[1][1]&&(i[1][1]=s[1])),a.length===0?a=[Array.from(s),Array.from(s)]:(s[0]<a[0][0]&&(a[0][0]=s[0]),s[0]>a[1][0]&&(a[1][0]=s[0]),s[1]<a[0][1]&&(a[0][1]=s[1]),s[1]>a[1][1]&&(a[1][1]=s[1]))}),a}),h=(i[1][0]-i[0][0])/c,l=(i[1][1]-i[0][1])/c,y=g.reduce((d,a,s)=>{const m=U(a[0][0],i[0][0],h,c),M=U(a[1][0],i[0][0],h,c),v=U(a[0][1],i[0][1],l,c),_=U(a[1][1],i[0][1],l,c);for(let w=m;w<=M;w++){d[w]||(d[w]=[]);for(let A=v;A<=_;A++)d[w][A]||(d[w][A]=[]),d[w][A].push(s)}return d},[]),o=n.features.map(d=>{let a=[];return Q(d)[0].map(s=>{f.length===0?f=[Array.from(s),Array.from(s)]:(s[0]<f[0][0]&&(f[0][0]=s[0]),s[0]>f[1][0]&&(f[1][0]=s[0]),s[1]<f[0][1]&&(f[0][1]=s[1]),s[1]>f[1][1]&&(f[1][1]=s[1])),a.length===0?a=[Array.from(s),Array.from(s)]:(s[0]<a[0][0]&&(a[0][0]=s[0]),s[0]>a[1][0]&&(a[1][0]=s[0]),s[1]<a[0][1]&&(a[0][1]=s[1]),s[1]>a[1][1]&&(a[1][1]=s[1]))}),a}),u=(f[1][0]-f[0][0])/c,b=(f[1][1]-f[0][1])/c,p=o.reduce((d,a,s)=>{const m=U(a[0][0],f[0][0],u,c),M=U(a[1][0],f[0][0],u,c),v=U(a[0][1],f[0][1],b,c),_=U(a[1][1],f[0][1],b,c);for(let w=m;w<=M;w++){d[w]||(d[w]=[]);for(let A=v;A<=_;A++)d[w][A]||(d[w][A]=[]),d[w][A].push(s)}return d},[]);this.indexedTins={forw:{gridNum:c,xOrigin:i[0][0],yOrigin:i[0][1],xUnit:h,yUnit:l,gridCache:y},bakw:{gridNum:c,xOrigin:f[0][0],yOrigin:f[0][1],xUnit:u,yUnit:b,gridCache:p}}}transform(e,r,n){if(!this.tins)throw new Error("setCompiled() must be called before transform()");if(r&&this.strict_status==E.STATUS_ERROR)throw new Error('Backward transform is not allowed if strict_status == "strict_error"');this.yaxisMode==E.YAXIS_FOLLOW&&r&&(e=[e[0],-1*e[1]]);const c=R(e);if(this.bounds&&!r&&!n&&!D(c,this.boundsPolygon))return!1;const i=r?this.tins.bakw:this.tins.forw,f=r?this.indexedTins.bakw:this.indexedTins.forw,g=r?this.vertices_params.bakw:this.vertices_params.forw,h=r?this.centroid.bakw:this.centroid.forw,l=r?this.pointsWeightBuffer.bakw:this.pointsWeightBuffer.forw;let y,o;this.stateFull&&(this.stateBackward==r?y=this.stateTriangle:(this.stateBackward=r,this.stateTriangle=void 0),o=b=>{this.stateTriangle=b});let u=rt(c,i,f,g,h,l,y,o);if(this.bounds&&r&&!n){const b=R(u);if(!D(b,this.boundsPolygon))return!1}else this.yaxisMode==E.YAXIS_FOLLOW&&!r&&(u=[u[0],-1*u[1]]);return u}};x(E,"VERTEX_PLAIN","plain"),x(E,"VERTEX_BIRDEYE","birdeye"),x(E,"MODE_STRICT","strict"),x(E,"MODE_AUTO","auto"),x(E,"MODE_LOOSE","loose"),x(E,"STATUS_STRICT","strict"),x(E,"STATUS_ERROR","strict_error"),x(E,"STATUS_LOOSE","loose"),x(E,"YAXIS_FOLLOW","follow"),x(E,"YAXIS_INVERT","invert");let G=E;O.Transform=G,O.counterTri=vt,O.format_version=Ct,O.normalizeEdges=it,O.rotateVerticesTriangle=pt,O.transformArr=rt,Object.defineProperty(O,Symbol.toStringTag,{value:"Module"})}));
1
+ (function(T,B){typeof exports=="object"&&typeof module<"u"?B(exports):typeof define=="function"&&define.amd?define(["exports"],B):(T=typeof globalThis<"u"?globalThis:T||self,B(T.maplat_transform={}))})(this,(function(T){"use strict";var Gt=Object.defineProperty;var Zt=(T,B,O)=>B in T?Gt(T,B,{enumerable:!0,configurable:!0,writable:!0,value:O}):T[B]=O;var x=(T,B,O)=>Zt(T,typeof B!="symbol"?B+"":B,O);function B(e,t,r={}){const n={type:"Feature"};return(r.id===0||r.id)&&(n.id=r.id),r.bbox&&(n.bbox=r.bbox),n.properties=t||{},n.geometry=e,n}function O(e,t,r={}){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(!nt(e[0])||!nt(e[1]))throw new Error("coordinates must contain numbers");return B({type:"Point",coordinates:e},t,r)}function q(e,t,r={}){for(const s of e){if(s.length<4)throw new Error("Each LinearRing of a Polygon must have 4 or more Positions.");if(s[s.length-1].length!==s[0].length)throw new Error("First and last Position are not equivalent.");for(let i=0;i<s[s.length-1].length;i++)if(s[s.length-1][i]!==s[0][i])throw new Error("First and last Position are not equivalent.")}return B({type:"Polygon",coordinates:e},t,r)}function U(e,t={}){const r={type:"FeatureCollection"};return t.id&&(r.id=t.id),t.bbox&&(r.bbox=t.bbox),r.features=e,r}function nt(e){return!isNaN(e)&&e!==null&&!Array.isArray(e)}function gt(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 st(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 bt(e){return e.type==="Feature"?e.geometry:e}const V=11102230246251565e-32,S=134217729,pt=(3+8*V)*V;function G(e,t,r,n,s){let i,o,u,l,f=t[0],m=n[0],a=0,d=0;m>f==m>-f?(i=f,f=t[++a]):(i=m,m=n[++d]);let g=0;if(a<e&&d<r)for(m>f==m>-f?(o=f+i,u=i-(o-f),f=t[++a]):(o=m+i,u=i-(o-m),m=n[++d]),i=o,u!==0&&(s[g++]=u);a<e&&d<r;)m>f==m>-f?(o=i+f,l=o-i,u=i-(o-l)+(f-l),f=t[++a]):(o=i+m,l=o-i,u=i-(o-l)+(m-l),m=n[++d]),i=o,u!==0&&(s[g++]=u);for(;a<e;)o=i+f,l=o-i,u=i-(o-l)+(f-l),f=t[++a],i=o,u!==0&&(s[g++]=u);for(;d<r;)o=i+m,l=o-i,u=i-(o-l)+(m-l),m=n[++d],i=o,u!==0&&(s[g++]=u);return(i!==0||g===0)&&(s[g++]=i),g}function wt(e,t){let r=t[0];for(let n=1;n<e;n++)r+=t[n];return r}function Y(e){return new Float64Array(e)}const xt=(3+16*V)*V,Mt=(2+12*V)*V,_t=(9+64*V)*V*V,F=Y(4),ot=Y(8),it=Y(12),at=Y(16),I=Y(4);function Tt(e,t,r,n,s,i,o){let u,l,f,m,a,d,g,b,y,h,c,p,M,_,E,w,v,C;const R=e-s,X=r-s,k=t-i,N=n-i;_=R*N,d=S*R,g=d-(d-R),b=R-g,d=S*N,y=d-(d-N),h=N-y,E=b*h-(_-g*y-b*y-g*h),w=k*X,d=S*k,g=d-(d-k),b=k-g,d=S*X,y=d-(d-X),h=X-y,v=b*h-(w-g*y-b*y-g*h),c=E-v,a=E-c,F[0]=E-(c+a)+(a-v),p=_+c,a=p-_,M=_-(p-a)+(c-a),c=M-w,a=M-c,F[1]=M-(c+a)+(a-w),C=p+c,a=C-p,F[2]=p-(C-a)+(c-a),F[3]=C;let L=wt(4,F),z=Mt*o;if(L>=z||-L>=z||(a=e-R,u=e-(R+a)+(a-s),a=r-X,f=r-(X+a)+(a-s),a=t-k,l=t-(k+a)+(a-i),a=n-N,m=n-(N+a)+(a-i),u===0&&l===0&&f===0&&m===0)||(z=_t*o+pt*Math.abs(L),L+=R*m+N*u-(k*f+X*l),L>=z||-L>=z))return L;_=u*N,d=S*u,g=d-(d-u),b=u-g,d=S*N,y=d-(d-N),h=N-y,E=b*h-(_-g*y-b*y-g*h),w=l*X,d=S*l,g=d-(d-l),b=l-g,d=S*X,y=d-(d-X),h=X-y,v=b*h-(w-g*y-b*y-g*h),c=E-v,a=E-c,I[0]=E-(c+a)+(a-v),p=_+c,a=p-_,M=_-(p-a)+(c-a),c=M-w,a=M-c,I[1]=M-(c+a)+(a-w),C=p+c,a=C-p,I[2]=p-(C-a)+(c-a),I[3]=C;const zt=G(4,F,4,I,ot);_=R*m,d=S*R,g=d-(d-R),b=R-g,d=S*m,y=d-(d-m),h=m-y,E=b*h-(_-g*y-b*y-g*h),w=k*f,d=S*k,g=d-(d-k),b=k-g,d=S*f,y=d-(d-f),h=f-y,v=b*h-(w-g*y-b*y-g*h),c=E-v,a=E-c,I[0]=E-(c+a)+(a-v),p=_+c,a=p-_,M=_-(p-a)+(c-a),c=M-w,a=M-c,I[1]=M-(c+a)+(a-w),C=p+c,a=C-p,I[2]=p-(C-a)+(c-a),I[3]=C;const qt=G(zt,ot,4,I,it);_=u*m,d=S*u,g=d-(d-u),b=u-g,d=S*m,y=d-(d-m),h=m-y,E=b*h-(_-g*y-b*y-g*h),w=l*f,d=S*l,g=d-(d-l),b=l-g,d=S*f,y=d-(d-f),h=f-y,v=b*h-(w-g*y-b*y-g*h),c=E-v,a=E-c,I[0]=E-(c+a)+(a-v),p=_+c,a=p-_,M=_-(p-a)+(c-a),c=M-w,a=M-c,I[1]=M-(c+a)+(a-w),C=p+c,a=C-p,I[2]=p-(C-a)+(c-a),I[3]=C;const jt=G(qt,it,4,I,at);return at[jt-1]}function vt(e,t,r,n,s,i){const o=(t-i)*(r-s),u=(e-s)*(n-i),l=o-u,f=Math.abs(o+u);return Math.abs(l)>=xt*f?l:-Tt(e,t,r,n,s,i,f)}function Et(e,t){var r,n,s=0,i,o,u,l,f,m,a,d=e[0],g=e[1],b=t.length;for(r=0;r<b;r++){n=0;var y=t[r],h=y.length-1;if(m=y[0],m[0]!==y[h][0]&&m[1]!==y[h][1])throw new Error("First and last coordinates in a ring must be the same");for(o=m[0]-d,u=m[1]-g,n;n<h;n++){if(a=y[n+1],l=a[0]-d,f=a[1]-g,u===0&&f===0){if(l<=0&&o>=0||o<=0&&l>=0)return 0}else if(f>=0&&u<=0||f<=0&&u>=0){if(i=vt(o,l,u,f,0,0),i===0)return 0;(i>0&&f>0&&u<=0||i<0&&f<=0&&u>0)&&s++}m=a,u=f,o=l}}return s%2!==0}function D(e,t,r={}){if(!e)throw new Error("point is required");if(!t)throw new Error("polygon is required");const n=gt(e),s=bt(t),i=s.type,o=t.bbox;let u=s.coordinates;if(o&&At(n,o)===!1)return!1;i==="Polygon"&&(u=[u]);let l=!1;for(var f=0;f<u.length;++f){const m=Et(n,u[f]);if(m===0)return!r.ignoreBoundary;m&&(l=!0)}return l}function At(e,t){return t[0]<=e[0]&&t[1]<=e[1]&&t[2]>=e[0]&&t[3]>=e[1]}function Z(e,t){for(let r=0;r<t.features.length;r++)if(D(e,t.features[r]))return t.features[r]}function ct(e,t,r){const n=t.geometry.coordinates[0][0],s=t.geometry.coordinates[0][1],i=t.geometry.coordinates[0][2],o=e.geometry.coordinates,u=t.properties.a.geom,l=t.properties.b.geom,f=t.properties.c.geom,m=[s[0]-n[0],s[1]-n[1]],a=[i[0]-n[0],i[1]-n[1]],d=[o[0]-n[0],o[1]-n[1]],g=[l[0]-u[0],l[1]-u[1]],b=[f[0]-u[0],f[1]-u[1]];let y=(a[1]*d[0]-a[0]*d[1])/(m[0]*a[1]-m[1]*a[0]),h=(m[0]*d[1]-m[1]*d[0])/(m[0]*a[1]-m[1]*a[0]);if(r){const c=r[t.properties.a.index],p=r[t.properties.b.index],M=r[t.properties.c.index];let _;if(y<0||h<0||1-y-h<0){const E=y/(y+h),w=h/(y+h);_=y/p/(E/p+w/M),h=h/M/(E/p+w/M)}else _=y/p/(y/p+h/M+(1-y-h)/c),h=h/M/(y/p+h/M+(1-y-h)/c);y=_}return[y*g[0]+h*b[0]+u[0],y*g[1]+h*b[1]+u[1]]}function St(e,t,r,n){const s=e.geometry.coordinates,i=r.geometry.coordinates,o=Math.atan2(s[0]-i[0],s[1]-i[1]),u=Ct(o,t[0]);if(u===void 0)throw new Error("Unable to determine vertex index");const l=t[1][u];return ct(e,l.features[0],n)}function ut(e,t,r,n,s,i,o,u){let l;if(o&&(l=Z(e,U([o]))),!l)if(r){const f=e.geometry.coordinates,m=r.gridNum,a=r.xOrigin,d=r.yOrigin,g=r.xUnit,b=r.yUnit,y=r.gridCache,h=W(f[0],a,g,m),c=W(f[1],d,b,m),p=y[h]?y[h][c]?y[h][c]:[]:[],M=U(p.map(_=>t.features[_]));l=Z(e,M)}else l=Z(e,t);return u&&u(l),l?ct(e,l,i):St(e,n,s,i)}function W(e,t,r,n){let s=Math.floor((e-t)/r);return s<0&&(s=0),s>=n&&(s=n-1),s}function Ct(e,t){let r=ft(e-t[0]),n=Math.PI*2,s;for(let i=0;i<t.length;i++){const o=(i+1)%t.length,u=ft(e-t[o]),l=Math.min(Math.abs(r),Math.abs(u));r*u<=0&&l<n&&(n=l,s=i),r=u}return s}function ft(e,t=!1){const r=2*Math.PI,n=e-Math.floor(e/r)*r;return t?n:n>Math.PI?n-r:n}function It(e){const t=e.features;for(let r=0;r<t.length;r++){const n=t[r];`${n.properties.a.index}`.substring(0,1)==="b"&&`${n.properties.b.index}`.substring(0,1)==="b"?t[r]={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[r]={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 e}function Bt(e){const t=["a","b","c","a"].map(i=>e.properties[i].geom),r=e.geometry.coordinates[0],n=e.properties,s={a:{geom:r[0],index:n.a.index},b:{geom:r[1],index:n.b.index},c:{geom:r[2],index:n.c.index}};return q([t],s)}function Ot(e){const t=[0,1,2,0].map(n=>e[n][0][0]),r={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 q([t],r)}function J(e,t,r,n,s,i=!1,o){const u=e.map(l=>{(!o||o<2.00703)&&(l=ht(l));const f=isFinite(l)?t[l]:l==="c"?n:(function(){const m=l.match(/^b(\d+)$/);if(m)return s[parseInt(m[1])];const a=l.match(/^e(\d+)$/);if(a)return r[parseInt(a[1])];throw new Error("Bad index value for indexesToTri")})();return i?[[f[1],f[0]],l]:[[f[0],f[1]],l]});return Ot(u)}function ht(e){return typeof e=="number"?e:e.replace(/^(c|e|b)(?:ent|dgeNode|box)(\d+)?$/,"$1$2")}function dt(e,t){return t&&t>=2.00703||Array.isArray(e[0])?e:e.map(r=>[r.illstNodes,r.mercNodes,r.startEnd])}const K=2.00703;function Pt(e){return!!(e.version!==void 0||!e.tins&&e.points&&e.tins_points)}function Rt(e){return{points:e.points,pointsWeightBuffer:kt(e),strictStatus:Nt(e),verticesParams:Wt(e),centroid:Vt(e),edges:dt(e.edges||[]),edgeNodes:e.edgeNodes||[],tins:Lt(e),kinks:Ut(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 Xt(e){const t=Ft(e),r=t.tins;return{compiled:t,tins:r,points:Dt(r),strictStatus:t.strict_status,pointsWeightBuffer:t.weight_buffer,verticesParams:t.vertices_params,centroid:t.centroid,kinks:t.kinks}}function kt(e){return!e.version||e.version<K?["forw","bakw"].reduce((t,r)=>{const n=e.weight_buffer[r];return n&&(t[r]=Object.keys(n).reduce((s,i)=>{const o=ht(i);return s[o]=n[i],s},{})),t},{}):e.weight_buffer}function Nt(e){return e.strict_status?e.strict_status:e.kinks_points?"strict_error":e.tins_points.length===2?"loose":"strict"}function Wt(e){const t={forw:[e.vertices_params[0]],bakw:[e.vertices_params[1]]};return t.forw[1]=lt(e,!1),t.bakw[1]=lt(e,!0),t}function lt(e,t){const r=e.vertices_points.length;return Array.from({length:r},(n,s)=>{const i=(s+1)%r,o=J(["c",`b${s}`,`b${i}`],e.points,e.edgeNodes||[],e.centroid_point,e.vertices_points,t,K);return U([o])})}function Vt(e){return{forw:O(e.centroid_point[0],{target:{geom:e.centroid_point[1],index:"c"}}),bakw:O(e.centroid_point[1],{target:{geom:e.centroid_point[0],index:"c"}})}}function Lt(e){const t=e.tins_points.length===1?0:1;return{forw:U(e.tins_points[0].map(r=>J(r,e.points,e.edgeNodes||[],e.centroid_point,e.vertices_points,!1,e.version))),bakw:U(e.tins_points[t].map(r=>J(r,e.points,e.edgeNodes||[],e.centroid_point,e.vertices_points,!0,e.version)))}}function Ut(e){if(e)return{bakw:U(e.map(t=>O(t)))}}function Ft(e){return JSON.parse(JSON.stringify(e).replace('"cent"','"c"').replace(/"bbox(\d+)"/g,'"b$1"'))}function Dt(e){const t=[],r=e.forw.features;for(let n=0;n<r.length;n++){const s=r[n];["a","b","c"].forEach((i,o)=>{const u=s.geometry.coordinates[0][o],l=s.properties[i].geom,f=s.properties[i].index;typeof f=="number"&&(t[f]=[u,l])})}return t}const Yt=K,A=class A{constructor(){x(this,"points",[]);x(this,"pointsWeightBuffer");x(this,"strict_status");x(this,"vertices_params");x(this,"centroid");x(this,"edgeNodes");x(this,"edges");x(this,"tins");x(this,"kinks");x(this,"yaxisMode",A.YAXIS_INVERT);x(this,"strictMode",A.MODE_AUTO);x(this,"vertexMode",A.VERTEX_PLAIN);x(this,"bounds");x(this,"boundsPolygon");x(this,"wh");x(this,"xy");x(this,"indexedTins");x(this,"stateFull",!1);x(this,"stateTriangle");x(this,"stateBackward");x(this,"priority");x(this,"importance");x(this,"xyBounds");x(this,"mercBounds")}setCompiled(t){if(Pt(t)){this.applyModernState(Rt(t));return}this.applyLegacyState(Xt(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??A.YAXIS_INVERT,this.vertexMode=t.vertexMode??A.VERTEX_PLAIN,this.strictMode=t.strictMode??A.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,r=t.forw,n=t.bakw,s=Math.ceil(Math.sqrt(r.features.length));if(s<3){this.indexedTins=void 0;return}let i=[],o=[];const u=r.features.map(y=>{let h=[];return st(y)[0].map(c=>{i.length===0?i=[Array.from(c),Array.from(c)]:(c[0]<i[0][0]&&(i[0][0]=c[0]),c[0]>i[1][0]&&(i[1][0]=c[0]),c[1]<i[0][1]&&(i[0][1]=c[1]),c[1]>i[1][1]&&(i[1][1]=c[1])),h.length===0?h=[Array.from(c),Array.from(c)]:(c[0]<h[0][0]&&(h[0][0]=c[0]),c[0]>h[1][0]&&(h[1][0]=c[0]),c[1]<h[0][1]&&(h[0][1]=c[1]),c[1]>h[1][1]&&(h[1][1]=c[1]))}),h}),l=(i[1][0]-i[0][0])/s,f=(i[1][1]-i[0][1])/s,m=u.reduce((y,h,c)=>{const p=W(h[0][0],i[0][0],l,s),M=W(h[1][0],i[0][0],l,s),_=W(h[0][1],i[0][1],f,s),E=W(h[1][1],i[0][1],f,s);for(let w=p;w<=M;w++){y[w]||(y[w]=[]);for(let v=_;v<=E;v++)y[w][v]||(y[w][v]=[]),y[w][v].push(c)}return y},[]),a=n.features.map(y=>{let h=[];return st(y)[0].map(c=>{o.length===0?o=[Array.from(c),Array.from(c)]:(c[0]<o[0][0]&&(o[0][0]=c[0]),c[0]>o[1][0]&&(o[1][0]=c[0]),c[1]<o[0][1]&&(o[0][1]=c[1]),c[1]>o[1][1]&&(o[1][1]=c[1])),h.length===0?h=[Array.from(c),Array.from(c)]:(c[0]<h[0][0]&&(h[0][0]=c[0]),c[0]>h[1][0]&&(h[1][0]=c[0]),c[1]<h[0][1]&&(h[0][1]=c[1]),c[1]>h[1][1]&&(h[1][1]=c[1]))}),h}),d=(o[1][0]-o[0][0])/s,g=(o[1][1]-o[0][1])/s,b=a.reduce((y,h,c)=>{const p=W(h[0][0],o[0][0],d,s),M=W(h[1][0],o[0][0],d,s),_=W(h[0][1],o[0][1],g,s),E=W(h[1][1],o[0][1],g,s);for(let w=p;w<=M;w++){y[w]||(y[w]=[]);for(let v=_;v<=E;v++)y[w][v]||(y[w][v]=[]),y[w][v].push(c)}return y},[]);this.indexedTins={forw:{gridNum:s,xOrigin:i[0][0],yOrigin:i[0][1],xUnit:l,yUnit:f,gridCache:m},bakw:{gridNum:s,xOrigin:o[0][0],yOrigin:o[0][1],xUnit:d,yUnit:g,gridCache:b}}}transform(t,r,n){if(!this.tins)throw new Error("setCompiled() must be called before transform()");if(r&&this.strict_status==A.STATUS_ERROR)throw new Error('Backward transform is not allowed if strict_status == "strict_error"');this.yaxisMode==A.YAXIS_FOLLOW&&r&&(t=[t[0],-1*t[1]]);const s=O(t);if(this.bounds&&!r&&!n&&!D(s,this.boundsPolygon))return!1;const i=r?this.tins.bakw:this.tins.forw,o=r?this.indexedTins.bakw:this.indexedTins.forw,u=r?this.vertices_params.bakw:this.vertices_params.forw,l=r?this.centroid.bakw:this.centroid.forw,f=r?this.pointsWeightBuffer.bakw:this.pointsWeightBuffer.forw;let m,a;this.stateFull&&(this.stateBackward==r?m=this.stateTriangle:(this.stateBackward=r,this.stateTriangle=void 0),a=g=>{this.stateTriangle=g});let d=ut(s,i,o,u,l,f,m,a);if(this.bounds&&r&&!n){const g=O(d);if(!D(g,this.boundsPolygon))return!1}else this.yaxisMode==A.YAXIS_FOLLOW&&!r&&(d=[d[0],-1*d[1]]);return d}};x(A,"VERTEX_PLAIN","plain"),x(A,"VERTEX_BIRDEYE","birdeye"),x(A,"MODE_STRICT","strict"),x(A,"MODE_AUTO","auto"),x(A,"MODE_LOOSE","loose"),x(A,"STATUS_STRICT","strict"),x(A,"STATUS_ERROR","strict_error"),x(A,"STATUS_LOOSE","loose"),x(A,"YAXIS_FOLLOW","follow"),x(A,"YAXIS_INVERT","invert");let $=A;const P=20037508342789244e-9,yt=[[0,0],[0,1],[1,0],[0,-1],[-1,0]];function Q(e,t){return Math.floor(Math.min(e[0],e[1])/4)*P/128/Math.pow(2,t)}function mt(e,t){const r=[];for(let n=0;n<e.length;n++){const s=e[n],i=s[0]*Math.cos(t)-s[1]*Math.sin(t),o=s[0]*Math.sin(t)+s[1]*Math.cos(t);r.push([i,o])}return r}function H(e,t,r,n){const s=Q(n,t);return mt(yt,r).map(u=>[u[0]*s+e[0],u[1]*s+e[1]])}function tt(e,t){const r=e[0],s=e.slice(1,5).map(g=>[g[0]-r[0],g[1]-r[1]]),i=[[0,1],[1,0],[0,-1],[-1,0]];let o=0,u=0,l=0;for(let g=0;g<4;g++){const b=s[g],y=i[g],h=Math.sqrt(Math.pow(b[0],2)+Math.pow(b[1],2));o+=h;const c=b[0]*y[1]-b[1]*y[0],p=Math.acos((b[0]*y[0]+b[1]*y[1])/h),M=c>0?-1*p:p;u+=Math.cos(M),l+=Math.sin(M)}const f=o/4,m=Math.atan2(l,u),a=Math.floor(Math.min(t[0],t[1])/4),d=Math.log(a*P/128/f)/Math.log(2);return{center:r,zoom:d,rotation:m}}function j(e,t){const r=e[0]*(2*P)/t-P,n=-1*(e[1]*(2*P)/t-P);return[r,n]}function et(e,t){const r=(e[0]+P)*t/(2*P),n=(-e[1]+P)*t/(2*P);return[r,n]}const rt=256;class $t{constructor(){x(this,"mainTin",null);x(this,"subTins",[]);x(this,"_maxxy",0)}setMapData(t){const r=new $;if(r.setCompiled(t.compiled),this.mainTin=r,t.maxZoom!==void 0)this._maxxy=Math.pow(2,t.maxZoom)*rt;else if(t.compiled.wh){const n=Math.max(t.compiled.wh[0],t.compiled.wh[1]),s=Math.ceil(Math.log2(n/rt));this._maxxy=Math.pow(2,s)*rt}if(this.subTins=[],t.sub_maps)for(const n of t.sub_maps){const s=new $;s.setCompiled(n.compiled);const i=n.bounds??n.compiled.bounds;if(!i)throw new Error("SubMapData must have bounds or compiled.bounds to create xyBounds polygon");const o=[...i,i[0]],u=o.map(l=>{const f=s.transform(l,!1);if(!f)throw new Error("Failed to transform sub-map bounds to mercator");return f});this.subTins.push({tin:s,priority:n.priority,importance:n.importance,xyBounds:q([o]),mercBounds:q([u])})}}xy2Merc(t){const r=this.xy2MercWithLayer(t);return r?r[1]:!1}merc2Xy(t){const r=this.merc2XyWithLayer(t),n=r[0]||r[1];return n?n[1]:!1}xy2MercWithLayer(t){this._assertMapData();const r=this._getTinsSortedByPriority();for(let n=0;n<r.length;n++){const{index:s,isMain:i}=r[n];if(i||D(O(t),this.subTins[s-1].xyBounds)){const o=this._transformByIndex(t,s,!1);if(o===!1)continue;return[s,o]}}return!1}merc2XyWithLayer(t){return this._assertMapData(),this._getAllTinsWithIndex().map(({index:o,tin:u,isMain:l})=>{const f=this._transformByIndex(t,o,!0);return f===!1?[u,o]:l||D(O(f),this.subTins[o-1].xyBounds)?[u,o,f]:[u,o]}).sort((o,u)=>{const l=o[0].priority??0,f=u[0].priority??0;return l<f?1:-1}).reduce((o,u,l,f)=>{const m=u[0],a=u[1],d=u[2];if(!d)return o;for(let g=0;g<l;g++){const b=f[g][1],y=b===0;if(f[g][2]&&(y||D(O(d),this.subTins[b-1].xyBounds)))if(o.length){const h=!o[0],c=h?o[1][2]:o[0][2],p=m.importance??0,M=c.importance??0;return h?p<M?o:[void 0,[a,d,m]]:[...o.filter(w=>w!==void 0),[a,d,m]].sort((w,v)=>(w[2].importance??0)<(v[2].importance??0)?1:-1).slice(0,2)}else return[[a,d,m]]}return!o.length||!o[0]?[[a,d,m]]:(o.push([a,d,m]),o.sort((g,b)=>{const y=g[2].importance??0,h=b[2].importance??0;return y<h?1:-1}).filter((g,b)=>b<2))},[]).map(o=>{if(o)return[o[0],o[1]]})}mercs2SysCoords(t){this._assertMapData();const r=this.merc2XyWithLayer(t[0]);let n=!1;return r.map((s,i)=>{if(!s){n=!0;return}const o=s[0],u=s[1];return i!==0&&!n?[this.xy2SysCoordInternal(u)]:t.map((f,m)=>m===0?u:this._transformByIndex(f,o,!0)).map(f=>this.xy2SysCoordInternal(f))})}viewpoint2Mercs(t,r){this._assertMapData(),this._assertMaxxy();const s=H(t.center,t.zoom,t.rotation,r).map(f=>et(f,this._maxxy)),i=this.xy2MercWithLayer(s[0]);if(!i)throw new Error("viewpoint2Mercs: center point is out of bounds");const o=i[0],u=i[1];return s.map((f,m)=>{if(m===0)return u;const a=this._transformByIndex(f,o,!1);if(a===!1)throw new Error(`viewpoint2Mercs: point ${m} is out of bounds`);return a})}mercs2Viewpoint(t,r){this._assertMapData(),this._assertMaxxy();const n=this.merc2XyWithLayer(t[0]),s=n[0]||n[1];if(!s)throw new Error("mercs2Viewpoint: center point is out of bounds");const i=s[0],o=s[1],l=t.map((f,m)=>{if(m===0)return o;const a=this._transformByIndex(f,i,!0);if(a===!1)throw new Error(`mercs2Viewpoint: point ${m} is out of bounds`);return a}).map(f=>j(f,this._maxxy));return tt(l,r)}static zoom2Radius(t,r){return Q(t,r)}static mercViewpoint2Mercs(t,r,n,s){return H(t,r,n,s)}static mercs2MercViewpoint(t,r){return tt(t,r)}static xy2SysCoord(t,r){return j(t,r)}static sysCoord2Xy(t,r){return et(t,r)}_assertMapData(){if(!this.mainTin)throw new Error("setMapData() must be called before transformation")}_assertMaxxy(){if(this._maxxy===0)throw new Error("MapData.maxZoom or compiled.wh must be set for viewpoint conversion (xy2SysCoord / sysCoord2Xy)")}getLayerTransform(t){if(t===0)return this.mainTin;const r=this.subTins[t-1];return r?r.tin:null}get layerCount(){return 1+this.subTins.length}get maxxy(){return this._maxxy}_getTinsSortedByPriority(){return this._getAllTinsWithIndex().sort((r,n)=>{const s=r.tin.priority??0,i=n.tin.priority??0;return s<i?1:-1})}_getAllTinsWithIndex(){const t=[{index:0,tin:this.mainTin,isMain:!0}];return this.subTins.forEach((r,n)=>{r.tin.priority=r.priority,r.tin.importance=r.importance,t.push({index:n+1,tin:r.tin,isMain:!1})}),t}_transformByIndex(t,r,n){if(r===0)return this.mainTin.transform(t,n);const s=this.subTins[r-1];return s?s.tin.transform(t,n,!0):!1}xy2SysCoordInternal(t){return j(t,this._maxxy)}}T.MERC_CROSSMATRIX=yt,T.MERC_MAX=P,T.MapTransform=$t,T.Transform=$,T.counterTri=Bt,T.format_version=Yt,T.mercViewpoint2Mercs=H,T.mercs2MercViewpoint=tt,T.normalizeEdges=dt,T.rotateMatrix=mt,T.rotateVerticesTriangle=It,T.sysCoord2Xy=et,T.transformArr=ut,T.xy2SysCoord=j,T.zoom2Radius=Q,Object.defineProperty(T,Symbol.toStringTag,{value:"Module"})}));
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
7
- "version": "0.5.0",
7
+ "version": "0.5.1",
8
8
  "description": "A JavaScript library that performs coordinate transformation between two plane coordinate systems using transformation definitions generated by Maplat.",
9
9
  "type": "module",
10
10
  "engines": {
@@ -46,6 +46,7 @@
46
46
  ],
47
47
  "devDependencies": {
48
48
  "@eslint/js": "^9.39.2",
49
+ "@maplat/tin": "^0.14.0",
49
50
  "@types/geojson": "^7946.0.16",
50
51
  "@types/node": "^24.10.4",
51
52
  "@typescript-eslint/eslint-plugin": "^8.50.1",
@@ -66,6 +67,7 @@
66
67
  "@turf/turf": "^7.3.1"
67
68
  },
68
69
  "scripts": {
70
+ "generate:submaps": "node scripts/generate-submaps-compiled.mjs",
69
71
  "dev": "vite --host",
70
72
  "build": "pnpm run typecheck && cross-env BUILD_MODE=package vite build",
71
73
  "typecheck": "tsc --noEmit --allowImportingTsExtensions",
@@ -0,0 +1,8 @@
1
+ export const MERC_MAX = 20037508.342789244;
2
+ export const MERC_CROSSMATRIX: number[][] = [
3
+ [0.0, 0.0],
4
+ [0.0, 1.0],
5
+ [1.0, 0.0],
6
+ [0.0, -1.0],
7
+ [-1.0, 0.0]
8
+ ];
@@ -0,0 +1,27 @@
1
+ import { MERC_MAX } from "./constants.ts";
2
+
3
+ /**
4
+ * ピクセル座標をシステム座標(EPSG:3857相当)に変換する
5
+ *
6
+ * @param xy - ピクセル座標 [x, y]
7
+ * @param maxxy - 最大座標値(2^maxZoom * 256)
8
+ * @returns システム座標 [x, y]
9
+ */
10
+ export function xy2SysCoord(xy: number[], maxxy: number): number[] {
11
+ const sysCoordX = (xy[0] * (2 * MERC_MAX)) / maxxy - MERC_MAX;
12
+ const sysCoordY = -1 * ((xy[1] * (2 * MERC_MAX)) / maxxy - MERC_MAX);
13
+ return [sysCoordX, sysCoordY];
14
+ }
15
+
16
+ /**
17
+ * システム座標(EPSG:3857相当)をピクセル座標に変換する
18
+ *
19
+ * @param sysCoord - システム座標 [x, y]
20
+ * @param maxxy - 最大座標値(2^maxZoom * 256)
21
+ * @returns ピクセル座標 [x, y]
22
+ */
23
+ export function sysCoord2Xy(sysCoord: number[], maxxy: number): number[] {
24
+ const x = ((sysCoord[0] + MERC_MAX) * maxxy) / (2 * MERC_MAX);
25
+ const y = ((-sysCoord[1] + MERC_MAX) * maxxy) / (2 * MERC_MAX);
26
+ return [x, y];
27
+ }
package/src/index.ts CHANGED
@@ -1,31 +1,3 @@
1
- import type { Feature, Polygon, Position } from "geojson";
2
- import { booleanPointInPolygon, point, getCoords } from "@turf/turf";
3
- import { unitCalc, transformArr } from "./geometry.ts";
4
- import type { Tri } from "./geometry.ts";
5
- import {
6
- FORMAT_VERSION,
7
- isModernCompiled,
8
- restoreLegacyState,
9
- restoreModernState
10
- } from "./compiled-state.ts";
11
- import type { EdgeSet } from "./edgeutils.ts";
12
- import type {
13
- Compiled,
14
- CompiledLegacy,
15
- IndexedTinsBD,
16
- KinksBD,
17
- LegacyStatePayload,
18
- ModernStatePayload,
19
- PointSet,
20
- StrictMode,
21
- StrictStatus,
22
- TinsBD,
23
- VertexMode,
24
- VerticesParamsBD,
25
- WeightBufferBD,
26
- YaxisMode,
27
- CentroidBD
28
- } from "./types.ts";
29
1
  export type {
30
2
  PointSet,
31
3
  BiDirectionKey,
@@ -47,354 +19,20 @@ export { transformArr } from "./geometry.ts";
47
19
  export { rotateVerticesTriangle, counterTri } from "./triangulation.ts";
48
20
  export type { Edge, EdgeSet, EdgeSetLegacy } from "./edgeutils.ts";
49
21
  export { normalizeEdges } from "./edgeutils.ts";
50
- export const format_version = FORMAT_VERSION;
51
-
52
- /**
53
- * 座標変換の基本機能を提供するクラス
54
- *
55
- * 2つの座標系間の変換を、TINネットワークを使用して実現します。
56
- * このクラスは基本的な変換機能のみを提供し、
57
- * 設定ファイルの生成などの追加機能はTinクラスで提供されます。
58
- */
59
- export class Transform {
60
- /**
61
- * 各種モードの定数定義
62
- * すべてreadonlyで、型安全性を確保
63
- */
64
- static VERTEX_PLAIN = "plain" as const;
65
- static VERTEX_BIRDEYE = "birdeye" as const;
66
- static MODE_STRICT = "strict" as const;
67
- static MODE_AUTO = "auto" as const;
68
- static MODE_LOOSE = "loose" as const;
69
- static STATUS_STRICT = "strict" as const;
70
- static STATUS_ERROR = "strict_error" as const;
71
- static STATUS_LOOSE = "loose" as const;
72
- static YAXIS_FOLLOW = "follow" as const;
73
- static YAXIS_INVERT = "invert" as const;
74
-
75
- points: PointSet[] = [];
76
- pointsWeightBuffer?: WeightBufferBD;
77
- strict_status?: StrictStatus;
78
- vertices_params?: VerticesParamsBD;
79
- centroid?: CentroidBD;
80
- edgeNodes?: PointSet[];
81
- edges?: EdgeSet[];
82
- tins?: TinsBD;
83
- kinks?: KinksBD;
84
- yaxisMode: YaxisMode = Transform.YAXIS_INVERT;
85
- strictMode: StrictMode = Transform.MODE_AUTO;
86
- vertexMode?: VertexMode = Transform.VERTEX_PLAIN;
87
- bounds?: number[][];
88
- boundsPolygon?: Feature<Polygon>;
89
- wh?: number[];
90
- xy?: number[];
91
- indexedTins?: IndexedTinsBD;
92
- stateFull = false;
93
- stateTriangle?: Tri;
94
- stateBackward?: boolean;
95
-
96
- /**
97
- * Optional properties for MaplatCore extension
98
- * These properties allow consuming applications to extend Transform instances
99
- * with additional metadata without requiring Module Augmentation
100
- */
101
-
102
- /** Layer priority for rendering order */
103
- priority?: number;
104
-
105
- /** Layer importance for display decisions */
106
- importance?: number;
107
-
108
- /** Bounds in XY (source) coordinate system */
109
- xyBounds?: Feature<Polygon>;
110
-
111
- /** Bounds in Mercator (Web Mercator) coordinate system */
112
- mercBounds?: Feature<Polygon>;
113
-
114
- constructor() { }
115
-
116
- /**
117
- * コンパイルされた設定を適用します
118
- *
119
- * @param compiled - コンパイルされた設定オブジェクト
120
- * @returns 変換に必要な主要なオブジェクトのセット
121
- *
122
- * 以下の処理を行います:
123
- * 1. バージョンに応じた設定の解釈
124
- * 2. 各種パラメータの復元
125
- * 3. TINネットワークの再構築
126
- * 4. インデックスの作成
127
- */
128
- setCompiled(compiled: Compiled | CompiledLegacy): void {
129
- if (isModernCompiled(compiled)) {
130
- this.applyModernState(restoreModernState(compiled));
131
- return;
132
- }
133
- this.applyLegacyState(restoreLegacyState(compiled as CompiledLegacy));
134
- }
135
-
136
- private applyModernState(state: ModernStatePayload): void {
137
- this.points = state.points;
138
- this.pointsWeightBuffer = state.pointsWeightBuffer;
139
- this.strict_status = state.strictStatus;
140
- this.vertices_params = state.verticesParams;
141
- this.centroid = state.centroid;
142
- this.edges = state.edges;
143
- this.edgeNodes = state.edgeNodes || [];
144
- this.tins = state.tins;
145
- this.addIndexedTin();
146
- this.kinks = state.kinks;
147
- this.yaxisMode = state.yaxisMode ?? Transform.YAXIS_INVERT;
148
- this.vertexMode = state.vertexMode ?? Transform.VERTEX_PLAIN;
149
- this.strictMode = state.strictMode ?? Transform.MODE_AUTO;
150
- if (state.bounds) {
151
- this.bounds = state.bounds;
152
- this.boundsPolygon = state.boundsPolygon;
153
- this.xy = state.xy;
154
- this.wh = state.wh;
155
- } else {
156
- this.bounds = undefined;
157
- this.boundsPolygon = undefined;
158
- this.xy = state.xy ?? [0, 0];
159
- if (state.wh) this.wh = state.wh;
160
- }
161
- }
162
-
163
- private applyLegacyState(state: LegacyStatePayload): void {
164
- this.tins = state.tins;
165
- this.addIndexedTin();
166
- this.strict_status = state.strictStatus;
167
- this.pointsWeightBuffer = state.pointsWeightBuffer;
168
- this.vertices_params = state.verticesParams;
169
- this.centroid = state.centroid;
170
- this.kinks = state.kinks;
171
- this.points = state.points;
172
- }
173
-
174
- /**
175
- * TINネットワークのインデックスを作成します
176
- *
177
- * インデックスは変換処理を高速化するために使用されます。
178
- * グリッド形式のインデックスを作成し、各グリッドに
179
- * 含まれる三角形を記録します。
180
- */
181
- addIndexedTin() {
182
- const tins = this.tins!;
183
- const forw = tins.forw;
184
- const bakw = tins.bakw;
185
- const gridNum = Math.ceil(Math.sqrt(forw!.features.length));
186
- if (gridNum < 3) {
187
- this.indexedTins = undefined;
188
- return;
189
- }
190
- let forwBound: Position[] = [];
191
- let bakwBound: Position[] = [];
192
- const forwEachBound = forw!.features.map((tri: Tri) => {
193
- let eachBound: Position[] = [];
194
- getCoords(tri)[0].map((point: Position) => {
195
- if (forwBound.length === 0)
196
- forwBound = [Array.from(point), Array.from(point)];
197
- else {
198
- if (point[0] < forwBound[0][0]) forwBound[0][0] = point[0];
199
- if (point[0] > forwBound[1][0]) forwBound[1][0] = point[0];
200
- if (point[1] < forwBound[0][1]) forwBound[0][1] = point[1];
201
- if (point[1] > forwBound[1][1]) forwBound[1][1] = point[1];
202
- }
203
- if (eachBound.length === 0)
204
- eachBound = [Array.from(point), Array.from(point)];
205
- else {
206
- if (point[0] < eachBound[0][0]) eachBound[0][0] = point[0];
207
- if (point[0] > eachBound[1][0]) eachBound[1][0] = point[0];
208
- if (point[1] < eachBound[0][1]) eachBound[0][1] = point[1];
209
- if (point[1] > eachBound[1][1]) eachBound[1][1] = point[1];
210
- }
211
- });
212
- return eachBound;
213
- });
214
- const forwXUnit = (forwBound[1][0] - forwBound[0][0]) / gridNum;
215
- const forwYUnit = (forwBound[1][1] - forwBound[0][1]) / gridNum;
216
- const forwGridCache = forwEachBound.reduce(
217
- (prev: number[][][], bound: Position[], index: number) => {
218
- const normXMin = unitCalc(
219
- bound[0][0],
220
- forwBound[0][0],
221
- forwXUnit,
222
- gridNum
223
- );
224
- const normXMax = unitCalc(
225
- bound[1][0],
226
- forwBound[0][0],
227
- forwXUnit,
228
- gridNum
229
- );
230
- const normYMin = unitCalc(
231
- bound[0][1],
232
- forwBound[0][1],
233
- forwYUnit,
234
- gridNum
235
- );
236
- const normYMax = unitCalc(
237
- bound[1][1],
238
- forwBound[0][1],
239
- forwYUnit,
240
- gridNum
241
- );
242
- for (let cx = normXMin; cx <= normXMax; cx++) {
243
- if (!prev[cx]) prev[cx] = [];
244
- for (let cy = normYMin; cy <= normYMax; cy++) {
245
- if (!prev[cx][cy]) prev[cx][cy] = [];
246
- prev[cx][cy].push(index);
247
- }
248
- }
249
- return prev;
250
- },
251
- []
252
- );
253
- const bakwEachBound = bakw!.features.map((tri: Tri) => {
254
- let eachBound: Position[] = [];
255
- getCoords(tri)[0].map((point: Position) => {
256
- if (bakwBound.length === 0)
257
- bakwBound = [Array.from(point), Array.from(point)];
258
- else {
259
- if (point[0] < bakwBound[0][0]) bakwBound[0][0] = point[0];
260
- if (point[0] > bakwBound[1][0]) bakwBound[1][0] = point[0];
261
- if (point[1] < bakwBound[0][1]) bakwBound[0][1] = point[1];
262
- if (point[1] > bakwBound[1][1]) bakwBound[1][1] = point[1];
263
- }
264
- if (eachBound.length === 0)
265
- eachBound = [Array.from(point), Array.from(point)];
266
- else {
267
- if (point[0] < eachBound[0][0]) eachBound[0][0] = point[0];
268
- if (point[0] > eachBound[1][0]) eachBound[1][0] = point[0];
269
- if (point[1] < eachBound[0][1]) eachBound[0][1] = point[1];
270
- if (point[1] > eachBound[1][1]) eachBound[1][1] = point[1];
271
- }
272
- });
273
- return eachBound;
274
- });
275
- const bakwXUnit = (bakwBound[1][0] - bakwBound[0][0]) / gridNum;
276
- const bakwYUnit = (bakwBound[1][1] - bakwBound[0][1]) / gridNum;
277
- const bakwGridCache = bakwEachBound.reduce(
278
- (prev: number[][][], bound: Position[], index: number) => {
279
- const normXMin = unitCalc(
280
- bound[0][0],
281
- bakwBound[0][0],
282
- bakwXUnit,
283
- gridNum
284
- );
285
- const normXMax = unitCalc(
286
- bound[1][0],
287
- bakwBound[0][0],
288
- bakwXUnit,
289
- gridNum
290
- );
291
- const normYMin = unitCalc(
292
- bound[0][1],
293
- bakwBound[0][1],
294
- bakwYUnit,
295
- gridNum
296
- );
297
- const normYMax = unitCalc(
298
- bound[1][1],
299
- bakwBound[0][1],
300
- bakwYUnit,
301
- gridNum
302
- );
303
- for (let cx = normXMin; cx <= normXMax; cx++) {
304
- if (!prev[cx]) prev[cx] = [];
305
- for (let cy = normYMin; cy <= normYMax; cy++) {
306
- if (!prev[cx][cy]) prev[cx][cy] = [];
307
- prev[cx][cy].push(index);
308
- }
309
- }
310
- return prev;
311
- },
312
- []
313
- );
314
- this.indexedTins = {
315
- forw: {
316
- gridNum,
317
- xOrigin: forwBound[0][0],
318
- yOrigin: forwBound[0][1],
319
- xUnit: forwXUnit,
320
- yUnit: forwYUnit,
321
- gridCache: forwGridCache
322
- },
323
- bakw: {
324
- gridNum,
325
- xOrigin: bakwBound[0][0],
326
- yOrigin: bakwBound[0][1],
327
- xUnit: bakwXUnit,
328
- yUnit: bakwYUnit,
329
- gridCache: bakwGridCache
330
- }
331
- };
332
- }
333
-
334
- /**
335
- * 座標変換を実行します
336
- *
337
- * @param apoint - 変換する座標
338
- * @param backward - 逆方向の変換かどうか
339
- * @param ignoreBounds - 境界チェックを無視するかどうか
340
- * @returns 変換後の座標、または境界外の場合はfalse
341
- *
342
- * @throws {Error} 逆方向変換が許可されていない状態での逆変換時
343
- */
344
- transform(apoint: number[], backward?: boolean, ignoreBounds?: boolean): number[] | false {
345
- if (!this.tins)
346
- throw new Error("setCompiled() must be called before transform()");
347
- if (backward && this.strict_status == Transform.STATUS_ERROR)
348
- throw new Error('Backward transform is not allowed if strict_status == "strict_error"');
349
- // if (!this.tins) this.updateTin();
350
- if (this.yaxisMode == Transform.YAXIS_FOLLOW && backward) {
351
- apoint = [apoint[0], -1 * apoint[1]];
352
- }
353
- const tpoint = point(apoint);
354
- if (this.bounds && !backward && !ignoreBounds) {
355
- if (!booleanPointInPolygon(tpoint, this.boundsPolygon!)) return false;
356
- }
357
- const tins = backward ? this.tins!.bakw : this.tins!.forw;
358
- const indexedTins = backward
359
- ? this.indexedTins!.bakw
360
- : this.indexedTins!.forw;
361
- const verticesParams = backward
362
- ? this.vertices_params!.bakw
363
- : this.vertices_params!.forw;
364
- const centroid = backward ? this.centroid!.bakw : this.centroid!.forw;
365
- const weightBuffer = backward
366
- ? this.pointsWeightBuffer!.bakw
367
- : this.pointsWeightBuffer!.forw;
368
- let stateTriangle = undefined,
369
- stateSetFunc = undefined;
370
- if (this.stateFull) {
371
- if (this.stateBackward == backward) {
372
- stateTriangle = this.stateTriangle;
373
- } else {
374
- this.stateBackward = backward;
375
- this.stateTriangle = undefined;
376
- }
377
- stateSetFunc = (tri?: Tri) => {
378
- this.stateTriangle = tri;
379
- };
380
- }
381
- let ret = transformArr(
382
- tpoint,
383
- tins!,
384
- indexedTins,
385
- verticesParams,
386
- centroid,
387
- weightBuffer,
388
- stateTriangle,
389
- stateSetFunc
390
- );
391
- if (this.bounds && backward && !ignoreBounds) {
392
- const rpoint = point(ret);
393
- if (!booleanPointInPolygon(rpoint, this.boundsPolygon!)) return false;
394
- } else if (this.yaxisMode == Transform.YAXIS_FOLLOW && !backward) {
395
- ret = [ret[0], -1 * ret[1]];
396
- }
397
- return ret;
398
- }
399
-
400
- }
22
+ export { Transform, format_version } from "./transform.ts";
23
+
24
+ // New exports: constants, pure functions, MapTransform
25
+ export { MERC_MAX, MERC_CROSSMATRIX } from "./constants.ts";
26
+ export {
27
+ zoom2Radius,
28
+ rotateMatrix,
29
+ mercViewpoint2Mercs,
30
+ mercs2MercViewpoint
31
+ } from "./viewpoint.ts";
32
+ export { xy2SysCoord, sysCoord2Xy } from "./coord-utils.ts";
33
+ export { MapTransform } from "./map-transform.ts";
34
+ export type {
35
+ Viewpoint,
36
+ SubMapData,
37
+ MapData
38
+ } from "./types.ts";