@maplat/transform 0.2.3 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +15 -23
- package/dist/index.html +7 -4
- package/dist/maplat_transform.cjs +1 -1
- package/dist/maplat_transform.js +505 -440
- package/dist/maplat_transform.umd.js +1 -1
- package/package.json +35 -39
- package/src/compiled-state.ts +211 -0
- package/src/index.ts +90 -275
- package/src/types.ts +122 -0
package/dist/index.d.ts
CHANGED
|
@@ -5,21 +5,18 @@ import { Polygon } from 'geojson';
|
|
|
5
5
|
import { Position } from 'geojson';
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
|
-
*
|
|
9
|
-
* - forw: 順方向(ソース → ターゲット)
|
|
10
|
-
* - bakw: 逆方向(ターゲット → ソース)
|
|
8
|
+
* Directional selector shared across the codebase.
|
|
11
9
|
*/
|
|
12
10
|
export declare type BiDirectionKey = "forw" | "bakw";
|
|
13
11
|
|
|
14
|
-
|
|
12
|
+
declare type Centroid = Feature<Point>;
|
|
15
13
|
|
|
16
14
|
export declare type CentroidBD = {
|
|
17
15
|
[key in BiDirectionKey]?: Centroid;
|
|
18
16
|
};
|
|
19
17
|
|
|
20
18
|
/**
|
|
21
|
-
*
|
|
22
|
-
* 変換に必要な全ての情報を含む
|
|
19
|
+
* Serialized structure generated by MaplatTin and consumed by Transform.
|
|
23
20
|
*/
|
|
24
21
|
export declare interface Compiled {
|
|
25
22
|
version?: number;
|
|
@@ -42,6 +39,9 @@ export declare interface Compiled {
|
|
|
42
39
|
xy?: number[];
|
|
43
40
|
}
|
|
44
41
|
|
|
42
|
+
/**
|
|
43
|
+
* Historical serialization format prior to 2.00703.
|
|
44
|
+
*/
|
|
45
45
|
export declare interface CompiledLegacy extends Compiled {
|
|
46
46
|
tins?: TinsBD;
|
|
47
47
|
centroid?: CentroidBD;
|
|
@@ -96,7 +96,7 @@ export declare type IndexedTinsBD = {
|
|
|
96
96
|
[key in BiDirectionKey]?: IndexedTins;
|
|
97
97
|
};
|
|
98
98
|
|
|
99
|
-
|
|
99
|
+
declare type Kinks = FeatureCollection<Point>;
|
|
100
100
|
|
|
101
101
|
export declare type KinksBD = {
|
|
102
102
|
[key in BiDirectionKey]?: Kinks;
|
|
@@ -113,7 +113,7 @@ export declare type KinksBD = {
|
|
|
113
113
|
export declare function normalizeEdges(edges: EdgeSet[] | EdgeSetLegacy[], version?: number): EdgeSet[];
|
|
114
114
|
|
|
115
115
|
/**
|
|
116
|
-
*
|
|
116
|
+
* Two-way coordinate pair: [source, target].
|
|
117
117
|
*/
|
|
118
118
|
export declare type PointSet = [Position, Position];
|
|
119
119
|
|
|
@@ -137,18 +137,12 @@ export declare type PropertyTriKey = "a" | "b" | "c";
|
|
|
137
137
|
export declare function rotateVerticesTriangle(tins: Tins): Tins;
|
|
138
138
|
|
|
139
139
|
/**
|
|
140
|
-
*
|
|
141
|
-
* - strict: 厳密モード(交差なしを保証)
|
|
142
|
-
* - auto: 自動モード(可能な限り厳密に)
|
|
143
|
-
* - loose: 緩和モード(交差を許容)
|
|
140
|
+
* Strictness flags supported during transformation.
|
|
144
141
|
*/
|
|
145
142
|
export declare type StrictMode = "strict" | "auto" | "loose";
|
|
146
143
|
|
|
147
144
|
/**
|
|
148
|
-
*
|
|
149
|
-
* - strict: 厳密モード生成成功
|
|
150
|
-
* - auto: 厳密モードでエラー
|
|
151
|
-
* - loose: 緩和モード
|
|
145
|
+
* Result of strictness evaluation.
|
|
152
146
|
*/
|
|
153
147
|
export declare type StrictStatus = "strict" | "strict_error" | "loose";
|
|
154
148
|
|
|
@@ -214,6 +208,8 @@ export declare class Transform {
|
|
|
214
208
|
* 4. インデックスの作成
|
|
215
209
|
*/
|
|
216
210
|
setCompiled(compiled: Compiled | CompiledLegacy): void;
|
|
211
|
+
private applyModernState;
|
|
212
|
+
private applyLegacyState;
|
|
217
213
|
/**
|
|
218
214
|
* TINネットワークのインデックスを作成します
|
|
219
215
|
*
|
|
@@ -254,9 +250,7 @@ export declare function transformArr(point: Feature<Point>, tins: Tins, indexedT
|
|
|
254
250
|
export declare type Tri = Feature<Polygon, PropertiesTri>;
|
|
255
251
|
|
|
256
252
|
/**
|
|
257
|
-
*
|
|
258
|
-
* - plain: 通常モード
|
|
259
|
-
* - birdeye: 鳥瞰図モード
|
|
253
|
+
* Vertex interpolation modes.
|
|
260
254
|
*/
|
|
261
255
|
export declare type VertexMode = "plain" | "birdeye";
|
|
262
256
|
|
|
@@ -271,16 +265,14 @@ declare type WeightBuffer = {
|
|
|
271
265
|
};
|
|
272
266
|
|
|
273
267
|
/**
|
|
274
|
-
*
|
|
268
|
+
* Weight buffers indexed by node id for both directions.
|
|
275
269
|
*/
|
|
276
270
|
export declare type WeightBufferBD = {
|
|
277
271
|
[key in BiDirectionKey]?: WeightBuffer;
|
|
278
272
|
};
|
|
279
273
|
|
|
280
274
|
/**
|
|
281
|
-
* Y
|
|
282
|
-
* - follow: Y軸の向きを維持
|
|
283
|
-
* - invert: Y軸の向きを反転
|
|
275
|
+
* Y-axis handling directive.
|
|
284
276
|
*/
|
|
285
277
|
export declare type YaxisMode = "follow" | "invert";
|
|
286
278
|
|
package/dist/index.html
CHANGED
|
@@ -23,17 +23,20 @@
|
|
|
23
23
|
[[70, 150], [140, -150]]
|
|
24
24
|
]);
|
|
25
25
|
|
|
26
|
-
|
|
26
|
+
const render = async () => {
|
|
27
|
+
await tin.updateTinAsync();
|
|
27
28
|
const output = document.getElementById('output');
|
|
28
29
|
const result1 = tin.transform([140, 150]);
|
|
29
30
|
const result2 = tin.transform(result1, true);
|
|
30
|
-
|
|
31
|
+
|
|
31
32
|
output.innerHTML = `
|
|
32
33
|
<h2>Test Results:</h2>
|
|
33
34
|
<p>Forward transform [140, 150] => [${result1.join(', ')}]</p>
|
|
34
35
|
<p>Backward transform [${result1.join(', ')}] => [${result2.join(', ')}]</p>
|
|
35
36
|
`;
|
|
36
|
-
}
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
render();
|
|
37
40
|
</script>
|
|
38
41
|
</body>
|
|
39
|
-
</html>
|
|
42
|
+
</html>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var ft=Object.defineProperty;var ct=(e,t,s)=>t in e?ft(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s;var _=(e,t,s)=>ct(e,typeof t!="symbol"?t+"":t,s);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const R=11102230246251565e-32,S=134217729,ut=(3+8*R)*R;function V(e,t,s,r,a){let n,c,l,g,d=t[0],y=r[0],o=0,u=0;y>d==y>-d?(n=d,d=t[++o]):(n=y,y=r[++u]);let b=0;if(o<e&&u<s)for(y>d==y>-d?(c=d+n,l=n-(c-d),d=t[++o]):(c=y+n,l=n-(c-y),y=r[++u]),n=c,l!==0&&(a[b++]=l);o<e&&u<s;)y>d==y>-d?(c=n+d,g=c-n,l=n-(c-g)+(d-g),d=t[++o]):(c=n+y,g=c-n,l=n-(c-g)+(y-g),y=r[++u]),n=c,l!==0&&(a[b++]=l);for(;o<e;)c=n+d,g=c-n,l=n-(c-g)+(d-g),d=t[++o],n=c,l!==0&&(a[b++]=l);for(;u<s;)c=n+y,g=c-n,l=n-(c-g)+(y-g),y=r[++u],n=c,l!==0&&(a[b++]=l);return(n!==0||b===0)&&(a[b++]=n),b}function ht(e,t){let s=t[0];for(let r=1;r<e;r++)s+=t[r];return s}function $(e){return new Float64Array(e)}const gt=(3+16*R)*R,lt=(2+12*R)*R,dt=(9+64*R)*R*R,F=$(4),G=$(8),j=$(12),z=$(16),P=$(4);function yt(e,t,s,r,a,n,c){let l,g,d,y,o,u,b,x,h,f,i,w,v,A,E,m,M,O;const I=e-a,p=s-a,k=t-n,N=r-n;A=I*N,u=S*I,b=u-(u-I),x=I-b,u=S*N,h=u-(u-N),f=N-h,E=x*f-(A-b*h-x*h-b*f),m=k*p,u=S*k,b=u-(u-k),x=k-b,u=S*p,h=u-(u-p),f=p-h,M=x*f-(m-b*h-x*h-b*f),i=E-M,o=E-i,F[0]=E-(i+o)+(o-M),w=A+i,o=w-A,v=A-(w-o)+(i-o),i=v-m,o=v-i,F[1]=v-(i+o)+(o-m),O=w+i,o=O-w,F[2]=w-(O-o)+(i-o),F[3]=O;let U=ht(4,F),X=lt*c;if(U>=X||-U>=X||(o=e-I,l=e-(I+o)+(o-a),o=s-p,d=s-(p+o)+(o-a),o=t-k,g=t-(k+o)+(o-n),o=r-N,y=r-(N+o)+(o-n),l===0&&g===0&&d===0&&y===0)||(X=dt*c+ut*Math.abs(U),U+=I*y+N*l-(k*d+p*g),U>=X||-U>=X))return U;A=l*N,u=S*l,b=u-(u-l),x=l-b,u=S*N,h=u-(u-N),f=N-h,E=x*f-(A-b*h-x*h-b*f),m=g*p,u=S*g,b=u-(u-g),x=g-b,u=S*p,h=u-(u-p),f=p-h,M=x*f-(m-b*h-x*h-b*f),i=E-M,o=E-i,P[0]=E-(i+o)+(o-M),w=A+i,o=w-A,v=A-(w-o)+(i-o),i=v-m,o=v-i,P[1]=v-(i+o)+(o-m),O=w+i,o=O-w,P[2]=w-(O-o)+(i-o),P[3]=O;const it=V(4,F,4,P,G);A=I*y,u=S*I,b=u-(u-I),x=I-b,u=S*y,h=u-(u-y),f=y-h,E=x*f-(A-b*h-x*h-b*f),m=k*d,u=S*k,b=u-(u-k),x=k-b,u=S*d,h=u-(u-d),f=d-h,M=x*f-(m-b*h-x*h-b*f),i=E-M,o=E-i,P[0]=E-(i+o)+(o-M),w=A+i,o=w-A,v=A-(w-o)+(i-o),i=v-m,o=v-i,P[1]=v-(i+o)+(o-m),O=w+i,o=O-w,P[2]=w-(O-o)+(i-o),P[3]=O;const ot=V(it,G,4,P,j);A=l*y,u=S*l,b=u-(u-l),x=l-b,u=S*y,h=u-(u-y),f=y-h,E=x*f-(A-b*h-x*h-b*f),m=g*d,u=S*g,b=u-(u-g),x=g-b,u=S*d,h=u-(u-d),f=d-h,M=x*f-(m-b*h-x*h-b*f),i=E-M,o=E-i,P[0]=E-(i+o)+(o-M),w=A+i,o=w-A,v=A-(w-o)+(i-o),i=v-m,o=v-i,P[1]=v-(i+o)+(o-m),O=w+i,o=O-w,P[2]=w-(O-o)+(i-o),P[3]=O;const at=V(ot,j,4,P,z);return z[at-1]}function bt(e,t,s,r,a,n){const c=(t-n)*(s-a),l=(e-a)*(r-n),g=c-l,d=Math.abs(c+l);return Math.abs(g)>=gt*d?g:-yt(e,t,s,r,a,n,d)}function wt(e,t){var s,r,a=0,n,c,l,g,d,y,o,u=e[0],b=e[1],x=t.length;for(s=0;s<x;s++){r=0;var h=t[s],f=h.length-1;if(y=h[0],y[0]!==h[f][0]&&y[1]!==h[f][1])throw new Error("First and last coordinates in a ring must be the same");for(c=y[0]-u,l=y[1]-b,r;r<f;r++){if(o=h[r+1],g=o[0]-u,d=o[1]-b,l===0&&d===0){if(g<=0&&c>=0||c<=0&&g>=0)return 0}else if(d>=0&&l<=0||d<=0&&l>=0){if(n=bt(c,g,l,d,0,0),n===0)return 0;(n>0&&d>0&&l<=0||n<0&&d<=0&&l>0)&&a++}y=o,l=d,c=g}}return a%2!==0}function Z(e,t,s={}){const r={type:"Feature"};return(s.id===0||s.id)&&(r.id=s.id),s.bbox&&(r.bbox=s.bbox),r.properties=t||{},r.geometry=e,r}function Y(e,t,s={}){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(!J(e[0])||!J(e[1]))throw new Error("coordinates must contain numbers");return Z({type:"Point",coordinates:e},t,s)}function tt(e,t,s={}){for(const a of e){if(a.length<4)throw new Error("Each LinearRing of a Polygon must have 4 or more Positions.");if(a[a.length-1].length!==a[0].length)throw new Error("First and last Position are not equivalent.");for(let n=0;n<a[a.length-1].length;n++)if(a[a.length-1][n]!==a[0][n])throw new Error("First and last Position are not equivalent.")}return Z({type:"Polygon",coordinates:e},t,s)}function B(e,t={}){const s={type:"FeatureCollection"};return t.id&&(s.id=t.id),t.bbox&&(s.bbox=t.bbox),s.features=e,s}function J(e){return!isNaN(e)&&e!==null&&!Array.isArray(e)}function mt(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 K(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 xt(e){return e.type==="Feature"?e.geometry:e}function _t(e,t,s={}){if(!e)throw new Error("point is required");if(!t)throw new Error("polygon is required");const r=mt(e),a=xt(t),n=a.type,c=t.bbox;let l=a.coordinates;if(c&&vt(r,c)===!1)return!1;n==="Polygon"&&(l=[l]);let g=!1;for(var d=0;d<l.length;++d){const y=wt(r,l[d]);if(y===0)return!s.ignoreBoundary;y&&(g=!0)}return g}function vt(e,t){return t[0]<=e[0]&&t[1]<=e[1]&&t[2]>=e[0]&&t[3]>=e[1]}var D=_t;function At(e){const t=e.features;for(let s=0;s<t.length;s++){const r=t[s];`${r.properties.a.index}`.substring(0,1)==="b"&&`${r.properties.b.index}`.substring(0,1)==="b"?t[s]={geometry:{type:"Polygon",coordinates:[[r.geometry.coordinates[0][2],r.geometry.coordinates[0][0],r.geometry.coordinates[0][1],r.geometry.coordinates[0][2]]]},properties:{a:{geom:r.properties.c.geom,index:r.properties.c.index},b:{geom:r.properties.a.geom,index:r.properties.a.index},c:{geom:r.properties.b.geom,index:r.properties.b.index}},type:"Feature"}:`${r.properties.c.index}`.substring(0,1)==="b"&&`${r.properties.a.index}`.substring(0,1)==="b"&&(t[s]={geometry:{type:"Polygon",coordinates:[[r.geometry.coordinates[0][1],r.geometry.coordinates[0][2],r.geometry.coordinates[0][0],r.geometry.coordinates[0][1]]]},properties:{a:{geom:r.properties.b.geom,index:r.properties.b.index},b:{geom:r.properties.c.geom,index:r.properties.c.index},c:{geom:r.properties.a.geom,index:r.properties.a.index}},type:"Feature"})}return e}function Mt(e){const t=["a","b","c","a"].map(n=>e.properties[n].geom),s=e.geometry.coordinates[0],r=e.properties,a={a:{geom:s[0],index:r.a.index},b:{geom:s[1],index:r.b.index},c:{geom:s[2],index:r.c.index}};return tt([t],a)}function Et(e){const t=[0,1,2,0].map(r=>e[r][0][0]),s={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 tt([t],s)}function W(e,t,s,r,a,n=!1,c){const l=e.map(g=>{(!c||c<2.00703)&&(g=et(g));const d=isFinite(g)?t[g]:g==="c"?r:g==="b0"?a[0]:g==="b1"?a[1]:g==="b2"?a[2]:g==="b3"?a[3]:function(){const y=g.match(/e(\d+)/);if(y){const o=parseInt(y[1]);return s[o]}throw"Bad index value for indexesToTri"}();return n?[[d[1],d[0]],g]:[[d[0],d[1]],g]});return Et(l)}function et(e){return typeof e=="number"?e:e.replace(/^(c|e|b)(?:ent|dgeNode|box)(\d+)?$/,"$1$2")}function rt(e,t){return t&&t>=2.00703||Array.isArray(e[0])?e:e.map(s=>[s.illstNodes,s.mercNodes,s.startEnd])}function Q(e,t){for(let s=0;s<t.features.length;s++)if(D(e,t.features[s]))return t.features[s]}function st(e,t,s){const r=t.geometry.coordinates[0][0],a=t.geometry.coordinates[0][1],n=t.geometry.coordinates[0][2],c=e.geometry.coordinates,l=t.properties.a.geom,g=t.properties.b.geom,d=t.properties.c.geom,y=[a[0]-r[0],a[1]-r[1]],o=[n[0]-r[0],n[1]-r[1]],u=[c[0]-r[0],c[1]-r[1]],b=[g[0]-l[0],g[1]-l[1]],x=[d[0]-l[0],d[1]-l[1]];let h=(o[1]*u[0]-o[0]*u[1])/(y[0]*o[1]-y[1]*o[0]),f=(y[0]*u[1]-y[1]*u[0])/(y[0]*o[1]-y[1]*o[0]);if(s){const i=s[t.properties.a.index],w=s[t.properties.b.index],v=s[t.properties.c.index];let A;if(h<0||f<0||1-h-f<0){const E=h/(h+f),m=f/(h+f);A=h/w/(E/w+m/v),f=f/v/(E/w+m/v)}else A=h/w/(h/w+f/v+(1-h-f)/i),f=f/v/(h/w+f/v+(1-h-f)/i);h=A}return[h*b[0]+f*x[0]+l[0],h*b[1]+f*x[1]+l[1]]}function Tt(e,t,s,r){const a=e.geometry.coordinates,n=s.geometry.coordinates,c=Math.atan2(a[0]-n[0],a[1]-n[1]),l=Ot(c,t[0]);if(l===void 0)throw new Error("Unable to determine vertex index");const g=t[1][l];return st(e,g.features[0],r)}function nt(e,t,s,r,a,n,c,l){let g;if(c&&(g=Q(e,B([c]))),!g){if(s){const d=e.geometry.coordinates,y=s.gridNum,o=s.xOrigin,u=s.yOrigin,b=s.xUnit,x=s.yUnit,h=s.gridCache,f=C(d[0],o,b,y),i=C(d[1],u,x,y),w=h[f]?h[f][i]?h[f][i]:[]:[];t=B(w.map(v=>t.features[v]))}g=Q(e,t)}return l&&l(g),g?st(e,g,n):Tt(e,r,a,n)}function C(e,t,s,r){let a=Math.floor((e-t)/s);return a>=r&&(a=r-1),a}function Ot(e,t){let s=H(e-t[0]),r=Math.PI*2,a;for(let n=0;n<t.length;n++){const c=(n+1)%t.length,l=H(e-t[c]),g=Math.min(Math.abs(s),Math.abs(l));s*l<=0&&g<r&&(r=g,a=n),s=l}return a}function H(e,t=!1){const s=t?function(r){return!(r>=0&&r<Math.PI*2)}:function(r){return!(r>-1*Math.PI&&r<=Math.PI)};for(;s(e);)e=e+2*Math.PI*(e>0?-1:1);return e}const q=2.00703,T=class T{constructor(){_(this,"points",[]);_(this,"pointsWeightBuffer");_(this,"strict_status");_(this,"vertices_params");_(this,"centroid");_(this,"edgeNodes");_(this,"edges");_(this,"tins");_(this,"kinks");_(this,"yaxisMode",T.YAXIS_INVERT);_(this,"strictMode",T.MODE_AUTO);_(this,"vertexMode",T.VERTEX_PLAIN);_(this,"bounds");_(this,"boundsPolygon");_(this,"wh");_(this,"xy");_(this,"indexedTins");_(this,"stateFull",!1);_(this,"stateTriangle");_(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((r,a)=>{const n=t.weight_buffer[a];return n&&(r[a]=Object.keys(n).reduce((c,l)=>{const g=et(l);return c[g]=n[l],c},{})),r},{}):t.weight_buffer,t.strict_status?this.strict_status=t.strict_status:t.kinks_points?this.strict_status=T.STATUS_ERROR:t.tins_points.length==2?this.strict_status=T.STATUS_LOOSE:this.strict_status=T.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(r=>{const a=(r+1)%4,n=W(["c",`b${r}`,`b${a}`],t.points,t.edgeNodes||[],t.centroid_point,t.vertices_points,!1,q);return B([n])}),this.vertices_params.bakw[1]=[0,1,2,3].map(r=>{const a=(r+1)%4,n=W(["c",`b${r}`,`b${a}`],t.points,t.edgeNodes||[],t.centroid_point,t.vertices_points,!0,q);return B([n])}),this.centroid={forw:Y(t.centroid_point[0],{target:{geom:t.centroid_point[1],index:"c"}}),bakw:Y(t.centroid_point[1],{target:{geom:t.centroid_point[0],index:"c"}})},this.edges=rt(t.edges||[]),this.edgeNodes=t.edgeNodes||[];const s=t.tins_points.length==1?0:1;this.tins={forw:B(t.tins_points[0].map(r=>W(r,t.points,t.edgeNodes||[],t.centroid_point,t.vertices_points,!1,t.version))),bakw:B(t.tins_points[s].map(r=>W(r,t.points,t.edgeNodes||[],t.centroid_point,t.vertices_points,!0,t.version)))},this.addIndexedTin(),t.kinks_points&&(this.kinks={bakw:B(t.kinks_points.map(r=>Y(r)))}),t.yaxisMode?this.yaxisMode=t.yaxisMode:this.yaxisMode=T.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 s=[];for(let r=0;r<this.tins.forw.features.length;r++){const a=this.tins.forw.features[r];["a","b","c"].map((n,c)=>{const l=a.geometry.coordinates[0][c],g=a.properties[n].geom,d=a.properties[n].index;typeof d=="number"&&(s[d]=[l,g])})}this.points=s}}addIndexedTin(){const t=this.tins,s=t.forw,r=t.bakw,a=Math.ceil(Math.sqrt(s.features.length));if(a<3){this.indexedTins=void 0;return}let n=[],c=[];const l=s.features.map(h=>{let f=[];return K(h)[0].map(i=>{n.length===0?n=[Array.from(i),Array.from(i)]:(i[0]<n[0][0]&&(n[0][0]=i[0]),i[0]>n[1][0]&&(n[1][0]=i[0]),i[1]<n[0][1]&&(n[0][1]=i[1]),i[1]>n[1][1]&&(n[1][1]=i[1])),f.length===0?f=[Array.from(i),Array.from(i)]:(i[0]<f[0][0]&&(f[0][0]=i[0]),i[0]>f[1][0]&&(f[1][0]=i[0]),i[1]<f[0][1]&&(f[0][1]=i[1]),i[1]>f[1][1]&&(f[1][1]=i[1]))}),f}),g=(n[1][0]-n[0][0])/a,d=(n[1][1]-n[0][1])/a,y=l.reduce((h,f,i)=>{const w=C(f[0][0],n[0][0],g,a),v=C(f[1][0],n[0][0],g,a),A=C(f[0][1],n[0][1],d,a),E=C(f[1][1],n[0][1],d,a);for(let m=w;m<=v;m++){h[m]||(h[m]=[]);for(let M=A;M<=E;M++)h[m][M]||(h[m][M]=[]),h[m][M].push(i)}return h},[]),o=r.features.map(h=>{let f=[];return K(h)[0].map(i=>{c.length===0?c=[Array.from(i),Array.from(i)]:(i[0]<c[0][0]&&(c[0][0]=i[0]),i[0]>c[1][0]&&(c[1][0]=i[0]),i[1]<c[0][1]&&(c[0][1]=i[1]),i[1]>c[1][1]&&(c[1][1]=i[1])),f.length===0?f=[Array.from(i),Array.from(i)]:(i[0]<f[0][0]&&(f[0][0]=i[0]),i[0]>f[1][0]&&(f[1][0]=i[0]),i[1]<f[0][1]&&(f[0][1]=i[1]),i[1]>f[1][1]&&(f[1][1]=i[1]))}),f}),u=(c[1][0]-c[0][0])/a,b=(c[1][1]-c[0][1])/a,x=o.reduce((h,f,i)=>{const w=C(f[0][0],c[0][0],u,a),v=C(f[1][0],c[0][0],u,a),A=C(f[0][1],c[0][1],b,a),E=C(f[1][1],c[0][1],b,a);for(let m=w;m<=v;m++){h[m]||(h[m]=[]);for(let M=A;M<=E;M++)h[m][M]||(h[m][M]=[]),h[m][M].push(i)}return h},[]);this.indexedTins={forw:{gridNum:a,xOrigin:n[0][0],yOrigin:n[0][1],xUnit:g,yUnit:d,gridCache:y},bakw:{gridNum:a,xOrigin:c[0][0],yOrigin:c[0][1],xUnit:u,yUnit:b,gridCache:x}}}transform(t,s,r){if(s&&this.strict_status==T.STATUS_ERROR)throw'Backward transform is not allowed if strict_status == "strict_error"';this.yaxisMode==T.YAXIS_FOLLOW&&s&&(t=[t[0],-1*t[1]]);const a=Y(t);if(this.bounds&&!s&&!r&&!D(a,this.boundsPolygon))return!1;const n=s?this.tins.bakw:this.tins.forw,c=s?this.indexedTins.bakw:this.indexedTins.forw,l=s?this.vertices_params.bakw:this.vertices_params.forw,g=s?this.centroid.bakw:this.centroid.forw,d=s?this.pointsWeightBuffer.bakw:this.pointsWeightBuffer.forw;let y,o;this.stateFull&&(this.stateBackward==s?y=this.stateTriangle:(this.stateBackward=s,this.stateTriangle=void 0),o=b=>{this.stateTriangle=b});let u=nt(a,n,c,l,g,d,y,o);if(this.bounds&&s&&!r){const b=Y(u);if(!D(b,this.boundsPolygon))return!1}else this.yaxisMode==T.YAXIS_FOLLOW&&!s&&(u=[u[0],-1*u[1]]);return u}};_(T,"VERTEX_PLAIN","plain"),_(T,"VERTEX_BIRDEYE","birdeye"),_(T,"MODE_STRICT","strict"),_(T,"MODE_AUTO","auto"),_(T,"MODE_LOOSE","loose"),_(T,"STATUS_STRICT","strict"),_(T,"STATUS_ERROR","strict_error"),_(T,"STATUS_LOOSE","loose"),_(T,"YAXIS_FOLLOW","follow"),_(T,"YAXIS_INVERT","invert");let L=T;exports.Transform=L;exports.counterTri=Mt;exports.format_version=q;exports.normalizeEdges=rt;exports.rotateVerticesTriangle=At;exports.transformArr=nt;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const C=11102230246251565e-32,E=134217729,at=(3+8*C)*C;function V(t,e,r,n,c){let i,f,h,g,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,h=i-(f-l),l=e[++o]):(f=y+i,h=i-(f-y),y=n[++u]),i=f,h!==0&&(c[b++]=h);o<t&&u<r;)y>l==y>-l?(f=i+l,g=f-i,h=i-(f-g)+(l-g),l=e[++o]):(f=i+y,g=f-i,h=i-(f-g)+(y-g),y=n[++u]),i=f,h!==0&&(c[b++]=h);for(;o<t;)f=i+l,g=f-i,h=i-(f-g)+(l-g),l=e[++o],i=f,h!==0&&(c[b++]=h);for(;u<r;)f=i+y,g=f-i,h=i-(f-g)+(y-g),y=n[++u],i=f,h!==0&&(c[b++]=h);return(i!==0||b===0)&&(c[b++]=i),b}function ct(t,e){let r=e[0];for(let n=1;n<t;n++)r+=e[n];return r}function W(t){return new Float64Array(t)}const ut=(3+16*C)*C,ft=(2+12*C)*C,dt=(9+64*C)*C*C,R=W(4),D=W(8),q=W(12),z=W(16),P=W(4);function gt(t,e,r,n,c,i,f){let h,g,l,y,o,u,b,x,d,a,s,m,_,p,M,w,v,A;const S=t-c,O=r-c,T=e-i,k=n-i;p=S*k,u=E*S,b=u-(u-S),x=S-b,u=E*k,d=u-(u-k),a=k-d,M=x*a-(p-b*d-x*d-b*a),w=T*O,u=E*T,b=u-(u-T),x=T-b,u=E*O,d=u-(u-O),a=O-d,v=x*a-(w-b*d-x*d-b*a),s=M-v,o=M-s,R[0]=M-(s+o)+(o-v),m=p+s,o=m-p,_=p-(m-o)+(s-o),s=_-w,o=_-s,R[1]=_-(s+o)+(o-w),A=m+s,o=A-m,R[2]=m-(A-o)+(s-o),R[3]=A;let B=ct(4,R),F=ft*f;if(B>=F||-B>=F||(o=t-S,h=t-(S+o)+(o-c),o=r-O,l=r-(O+o)+(o-c),o=e-T,g=e-(T+o)+(o-i),o=n-k,y=n-(k+o)+(o-i),h===0&&g===0&&l===0&&y===0)||(F=dt*f+at*Math.abs(B),B+=S*y+k*h-(T*l+O*g),B>=F||-B>=F))return B;p=h*k,u=E*h,b=u-(u-h),x=h-b,u=E*k,d=u-(u-k),a=k-d,M=x*a-(p-b*d-x*d-b*a),w=g*O,u=E*g,b=u-(u-g),x=g-b,u=E*O,d=u-(u-O),a=O-d,v=x*a-(w-b*d-x*d-b*a),s=M-v,o=M-s,P[0]=M-(s+o)+(o-v),m=p+s,o=m-p,_=p-(m-o)+(s-o),s=_-w,o=_-s,P[1]=_-(s+o)+(o-w),A=m+s,o=A-m,P[2]=m-(A-o)+(s-o),P[3]=A;const it=V(4,R,4,P,D);p=S*y,u=E*S,b=u-(u-S),x=S-b,u=E*y,d=u-(u-y),a=y-d,M=x*a-(p-b*d-x*d-b*a),w=T*l,u=E*T,b=u-(u-T),x=T-b,u=E*l,d=u-(u-l),a=l-d,v=x*a-(w-b*d-x*d-b*a),s=M-v,o=M-s,P[0]=M-(s+o)+(o-v),m=p+s,o=m-p,_=p-(m-o)+(s-o),s=_-w,o=_-s,P[1]=_-(s+o)+(o-w),A=m+s,o=A-m,P[2]=m-(A-o)+(s-o),P[3]=A;const st=V(it,D,4,P,q);p=h*y,u=E*h,b=u-(u-h),x=h-b,u=E*y,d=u-(u-y),a=y-d,M=x*a-(p-b*d-x*d-b*a),w=g*l,u=E*g,b=u-(u-g),x=g-b,u=E*l,d=u-(u-l),a=l-d,v=x*a-(w-b*d-x*d-b*a),s=M-v,o=M-s,P[0]=M-(s+o)+(o-v),m=p+s,o=m-p,_=p-(m-o)+(s-o),s=_-w,o=_-s,P[1]=_-(s+o)+(o-w),A=m+s,o=A-m,P[2]=m-(A-o)+(s-o),P[3]=A;const ot=V(st,q,4,P,z);return z[ot-1]}function ht(t,e,r,n,c,i){const f=(e-i)*(r-c),h=(t-c)*(n-i),g=f-h,l=Math.abs(f+h);return Math.abs(g)>=ut*l?g:-gt(t,e,r,n,c,i,l)}function lt(t,e){var r,n,c=0,i,f,h,g,l,y,o,u=t[0],b=t[1],x=e.length;for(r=0;r<x;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,h=y[1]-b,n;n<a;n++){if(o=d[n+1],g=o[0]-u,l=o[1]-b,h===0&&l===0){if(g<=0&&f>=0||f<=0&&g>=0)return 0}else if(l>=0&&h<=0||l<=0&&h>=0){if(i=ht(f,g,h,l,0,0),i===0)return 0;(i>0&&l>0&&h<=0||i<0&&l<=0&&h>0)&&c++}y=o,h=l,f=g}}return c%2!==0}function H(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 X(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(!G(t[0])||!G(t[1]))throw new Error("coordinates must contain numbers");return H({type:"Point",coordinates:t},e,r)}function Z(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 H({type:"Polygon",coordinates:t},e,r)}function U(t,e={}){const r={type:"FeatureCollection"};return e.id&&(r.id=e.id),e.bbox&&(r.bbox=e.bbox),r.features=t,r}function G(t){return!isNaN(t)&&t!==null&&!Array.isArray(t)}function yt(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 j(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 bt(t){return t.type==="Feature"?t.geometry:t}function mt(t,e,r={}){if(!t)throw new Error("point is required");if(!e)throw new Error("polygon is required");const n=yt(t),c=bt(e),i=c.type,f=e.bbox;let h=c.coordinates;if(f&&wt(n,f)===!1)return!1;i==="Polygon"&&(h=[h]);let g=!1;for(var l=0;l<h.length;++l){const y=lt(n,h[l]);if(y===0)return!r.ignoreBoundary;y&&(g=!0)}return g}function wt(t,e){return e[0]<=t[0]&&e[1]<=t[1]&&e[2]>=t[0]&&e[3]>=t[1]}var Y=mt;function J(t,e){for(let r=0;r<e.features.length;r++)if(Y(t,e.features[r]))return e.features[r]}function tt(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,h=e.properties.a.geom,g=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=[g[0]-h[0],g[1]-h[1]],x=[l[0]-h[0],l[1]-h[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],_=r[e.properties.c.index];let p;if(d<0||a<0||1-d-a<0){const M=d/(d+a),w=a/(d+a);p=d/m/(M/m+w/_),a=a/_/(M/m+w/_)}else p=d/m/(d/m+a/_+(1-d-a)/s),a=a/_/(d/m+a/_+(1-d-a)/s);d=p}return[d*b[0]+a*x[0]+h[0],d*b[1]+a*x[1]+h[1]]}function xt(t,e,r,n){const c=t.geometry.coordinates,i=r.geometry.coordinates,f=Math.atan2(c[0]-i[0],c[1]-i[1]),h=_t(f,e[0]);if(h===void 0)throw new Error("Unable to determine vertex index");const g=e[1][h];return tt(t,g.features[0],n)}function et(t,e,r,n,c,i,f,h){let g;if(f&&(g=J(t,U([f]))),!g){if(r){const l=t.geometry.coordinates,y=r.gridNum,o=r.xOrigin,u=r.yOrigin,b=r.xUnit,x=r.yUnit,d=r.gridCache,a=N(l[0],o,b,y),s=N(l[1],u,x,y),m=d[a]?d[a][s]?d[a][s]:[]:[];e=U(m.map(_=>e.features[_]))}g=J(t,e)}return h&&h(g),g?tt(t,g,i):xt(t,n,c,i)}function N(t,e,r,n){let c=Math.floor((t-e)/r);return c>=n&&(c=n-1),c}function _t(t,e){let r=K(t-e[0]),n=Math.PI*2,c;for(let i=0;i<e.length;i++){const f=(i+1)%e.length,h=K(t-e[f]),g=Math.min(Math.abs(r),Math.abs(h));r*h<=0&&g<n&&(n=g,c=i),r=h}return c}function K(t,e=!1){const r=e?function(n){return!(n>=0&&n<Math.PI*2)}:function(n){return!(n>-1*Math.PI&&n<=Math.PI)};for(;r(t);)t=t+2*Math.PI*(t>0?-1:1);return t}function rt(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 Z([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 Z([e],r)}function L(t,e,r,n,c,i=!1,f){const h=t.map(g=>{(!f||f<2.00703)&&(g=nt(g));const l=isFinite(g)?e[g]:g==="c"?n:g==="b0"?c[0]:g==="b1"?c[1]:g==="b2"?c[2]:g==="b3"?c[3]:function(){const y=g.match(/e(\d+)/);if(y){const o=parseInt(y[1]);return r[o]}throw"Bad index value for indexesToTri"}();return i?[[l[1],l[0]],g]:[[l[0],l[1]],g]});return Mt(h)}function nt(t){return typeof t=="number"?t:t.replace(/^(c|e|b)(?:ent|dgeNode|box)(\d+)?$/,"$1$2")}const $=2.00703;function At(t){return!!(t.version||!t.tins&&t.points&&t.tins_points)}function Et(t){return{points:t.points,pointsWeightBuffer:St(t),strictStatus:Ot(t),verticesParams:Tt(t),centroid:kt(t),edges:rt(t.edges||[]),edgeNodes:t.edgeNodes||[],tins:It(t),kinks:Nt(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.bounds?t.xy:[0,0]}}function Pt(t){const e=Bt(t),r=e.tins;return{compiled:e,tins:r,points:Ct(r),strictStatus:e.strict_status,pointsWeightBuffer:e.weight_buffer,verticesParams:e.vertices_params,centroid:e.centroid,kinks:e.kinks}}function St(t){return!t.version||t.version<$?["forw","bakw"].reduce((e,r)=>{const n=t.weight_buffer[r];return n&&(e[r]=Object.keys(n).reduce((c,i)=>{const f=nt(i);return c[f]=n[i],c},{})),e},{}):t.weight_buffer}function Ot(t){return t.strict_status?t.strict_status:t.kinks_points?"strict_error":t.tins_points.length===2?"loose":"strict"}function Tt(t){const e={forw:[t.vertices_params[0]],bakw:[t.vertices_params[1]]};return e.forw[1]=Q(t,!1),e.bakw[1]=Q(t,!0),e}function Q(t,e){return[0,1,2,3].map(r=>{const n=(r+1)%4,c=L(["c",`b${r}`,`b${n}`],t.points,t.edgeNodes||[],t.centroid_point,t.vertices_points,e,$);return U([c])})}function kt(t){return{forw:X(t.centroid_point[0],{target:{geom:t.centroid_point[1],index:"c"}}),bakw:X(t.centroid_point[1],{target:{geom:t.centroid_point[0],index:"c"}})}}function It(t){const e=t.tins_points.length===1?0:1;return{forw:U(t.tins_points[0].map(r=>L(r,t.points,t.edgeNodes||[],t.centroid_point,t.vertices_points,!1,t.version))),bakw:U(t.tins_points[e].map(r=>L(r,t.points,t.edgeNodes||[],t.centroid_point,t.vertices_points,!0,t.version)))}}function Nt(t){if(t)return{bakw:U(t.map(e=>X(e)))}}function Bt(t){return JSON.parse(JSON.stringify(t).replace('"cent"','"c"').replace(/"bbox(\d+)"/g,'"b$1"'))}function Ct(t){const e=[],r=t.forw.features;for(let n=0;n<r.length;n++){const c=r[n];["a","b","c"].map((i,f)=>{const h=c.geometry.coordinates[0][f],g=c.properties[i].geom,l=c.properties[i].index;typeof l=="number"&&(e[l]=[h,g])})}return e}const Rt=$;class I{static VERTEX_PLAIN="plain";static VERTEX_BIRDEYE="birdeye";static MODE_STRICT="strict";static MODE_AUTO="auto";static MODE_LOOSE="loose";static STATUS_STRICT="strict";static STATUS_ERROR="strict_error";static STATUS_LOOSE="loose";static YAXIS_FOLLOW="follow";static YAXIS_INVERT="invert";points=[];pointsWeightBuffer;strict_status;vertices_params;centroid;edgeNodes;edges;tins;kinks;yaxisMode=I.YAXIS_INVERT;strictMode=I.MODE_AUTO;vertexMode=I.VERTEX_PLAIN;bounds;boundsPolygon;wh;xy;indexedTins;stateFull=!1;stateTriangle;stateBackward;constructor(){}setCompiled(e){if(At(e)){this.applyModernState(Et(e));return}this.applyLegacyState(Pt(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??I.YAXIS_INVERT,this.vertexMode=e.vertexMode??I.VERTEX_PLAIN,this.strictMode=e.strictMode??I.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 h=r.features.map(d=>{let a=[];return j(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}),g=(i[1][0]-i[0][0])/c,l=(i[1][1]-i[0][1])/c,y=h.reduce((d,a,s)=>{const m=N(a[0][0],i[0][0],g,c),_=N(a[1][0],i[0][0],g,c),p=N(a[0][1],i[0][1],l,c),M=N(a[1][1],i[0][1],l,c);for(let w=m;w<=_;w++){d[w]||(d[w]=[]);for(let v=p;v<=M;v++)d[w][v]||(d[w][v]=[]),d[w][v].push(s)}return d},[]),o=n.features.map(d=>{let a=[];return j(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,x=o.reduce((d,a,s)=>{const m=N(a[0][0],f[0][0],u,c),_=N(a[1][0],f[0][0],u,c),p=N(a[0][1],f[0][1],b,c),M=N(a[1][1],f[0][1],b,c);for(let w=m;w<=_;w++){d[w]||(d[w]=[]);for(let v=p;v<=M;v++)d[w][v]||(d[w][v]=[]),d[w][v].push(s)}return d},[]);this.indexedTins={forw:{gridNum:c,xOrigin:i[0][0],yOrigin:i[0][1],xUnit:g,yUnit:l,gridCache:y},bakw:{gridNum:c,xOrigin:f[0][0],yOrigin:f[0][1],xUnit:u,yUnit:b,gridCache:x}}}transform(e,r,n){if(r&&this.strict_status==I.STATUS_ERROR)throw'Backward transform is not allowed if strict_status == "strict_error"';this.yaxisMode==I.YAXIS_FOLLOW&&r&&(e=[e[0],-1*e[1]]);const c=X(e);if(this.bounds&&!r&&!n&&!Y(c,this.boundsPolygon))return!1;const i=r?this.tins.bakw:this.tins.forw,f=r?this.indexedTins.bakw:this.indexedTins.forw,h=r?this.vertices_params.bakw:this.vertices_params.forw,g=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=et(c,i,f,h,g,l,y,o);if(this.bounds&&r&&!n){const b=X(u);if(!Y(b,this.boundsPolygon))return!1}else this.yaxisMode==I.YAXIS_FOLLOW&&!r&&(u=[u[0],-1*u[1]]);return u}}exports.Transform=I;exports.counterTri=vt;exports.format_version=Rt;exports.normalizeEdges=rt;exports.rotateVerticesTriangle=pt;exports.transformArr=et;
|