@maplat/transform 0.1.5 → 0.2.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,64 +1,64 @@
1
1
  var ot = Object.defineProperty;
2
2
  var at = (e, t, s) => t in e ? ot(e, t, { enumerable: !0, configurable: !0, writable: !0, value: s }) : e[t] = s;
3
3
  var _ = (e, t, s) => at(e, typeof t != "symbol" ? t + "" : t, s);
4
- const U = 11102230246251565e-32, k = 134217729, ct = (3 + 8 * U) * U;
4
+ const R = 11102230246251565e-32, I = 134217729, ft = (3 + 8 * R) * R;
5
5
  function V(e, t, s, r, a) {
6
- let n, f, d, g, l = t[0], y = r[0], o = 0, u = 0;
6
+ let n, c, d, g, l = t[0], y = r[0], o = 0, u = 0;
7
7
  y > l == y > -l ? (n = l, l = t[++o]) : (n = y, y = r[++u]);
8
8
  let b = 0;
9
9
  if (o < e && u < s)
10
- for (y > l == y > -l ? (f = l + n, d = n - (f - l), l = t[++o]) : (f = y + n, d = n - (f - y), y = r[++u]), n = f, d !== 0 && (a[b++] = d); o < e && u < s; )
11
- y > l == y > -l ? (f = n + l, g = f - n, d = n - (f - g) + (l - g), l = t[++o]) : (f = n + y, g = f - n, d = n - (f - g) + (y - g), y = r[++u]), n = f, d !== 0 && (a[b++] = d);
10
+ for (y > l == y > -l ? (c = l + n, d = n - (c - l), l = t[++o]) : (c = y + n, d = n - (c - y), y = r[++u]), n = c, d !== 0 && (a[b++] = d); o < e && u < s; )
11
+ y > l == y > -l ? (c = n + l, g = c - n, d = n - (c - g) + (l - g), l = t[++o]) : (c = n + y, g = c - n, d = n - (c - g) + (y - g), y = r[++u]), n = c, d !== 0 && (a[b++] = d);
12
12
  for (; o < e; )
13
- f = n + l, g = f - n, d = n - (f - g) + (l - g), l = t[++o], n = f, d !== 0 && (a[b++] = d);
13
+ c = n + l, g = c - n, d = n - (c - g) + (l - g), l = t[++o], n = c, d !== 0 && (a[b++] = d);
14
14
  for (; u < s; )
15
- f = n + y, g = f - n, d = n - (f - g) + (y - g), y = r[++u], n = f, d !== 0 && (a[b++] = d);
15
+ c = n + y, g = c - n, d = n - (c - g) + (y - g), y = r[++u], n = c, d !== 0 && (a[b++] = d);
16
16
  return (n !== 0 || b === 0) && (a[b++] = n), b;
17
17
  }
18
- function ft(e, t) {
18
+ function ct(e, t) {
19
19
  let s = t[0];
20
20
  for (let r = 1; r < e; r++) s += t[r];
21
21
  return s;
22
22
  }
23
- function W(e) {
23
+ function $(e) {
24
24
  return new Float64Array(e);
25
25
  }
26
- const ut = (3 + 16 * U) * U, ht = (2 + 12 * U) * U, gt = (9 + 64 * U) * U * U, F = W(4), q = W(8), L = W(12), G = W(16), p = W(4);
27
- function dt(e, t, s, r, a, n, f) {
28
- let d, g, l, y, o, u, b, x, h, c, i, w, A, v, E, m, M, T;
29
- const I = e - a, P = s - a, S = t - n, N = r - n;
30
- v = I * N, u = k * I, b = u - (u - I), x = I - b, u = k * N, h = u - (u - N), c = N - h, E = x * c - (v - b * h - x * h - b * c), m = S * P, u = k * S, b = u - (u - S), x = S - b, u = k * P, h = u - (u - P), c = P - h, M = x * c - (m - b * h - x * h - b * c), i = E - M, o = E - i, F[0] = E - (i + o) + (o - M), w = v + i, o = w - v, A = v - (w - o) + (i - o), i = A - m, o = A - i, F[1] = A - (i + o) + (o - m), T = w + i, o = T - w, F[2] = w - (T - o) + (i - o), F[3] = T;
31
- let R = ft(4, F), X = ht * f;
32
- if (R >= X || -R >= X || (o = e - I, d = e - (I + o) + (o - a), o = s - P, l = s - (P + o) + (o - a), o = t - S, g = t - (S + o) + (o - n), o = r - N, y = r - (N + o) + (o - n), d === 0 && g === 0 && l === 0 && y === 0) || (X = gt * f + ct * Math.abs(R), R += I * y + N * d - (S * l + P * g), R >= X || -R >= X)) return R;
33
- v = d * N, u = k * d, b = u - (u - d), x = d - b, u = k * N, h = u - (u - N), c = N - h, E = x * c - (v - b * h - x * h - b * c), m = g * P, u = k * g, b = u - (u - g), x = g - b, u = k * P, h = u - (u - P), c = P - h, M = x * c - (m - b * h - x * h - b * c), i = E - M, o = E - i, p[0] = E - (i + o) + (o - M), w = v + i, o = w - v, A = v - (w - o) + (i - o), i = A - m, o = A - i, p[1] = A - (i + o) + (o - m), T = w + i, o = T - w, p[2] = w - (T - o) + (i - o), p[3] = T;
34
- const st = V(4, F, 4, p, q);
35
- v = I * y, u = k * I, b = u - (u - I), x = I - b, u = k * y, h = u - (u - y), c = y - h, E = x * c - (v - b * h - x * h - b * c), m = S * l, u = k * S, b = u - (u - S), x = S - b, u = k * l, h = u - (u - l), c = l - h, M = x * c - (m - b * h - x * h - b * c), i = E - M, o = E - i, p[0] = E - (i + o) + (o - M), w = v + i, o = w - v, A = v - (w - o) + (i - o), i = A - m, o = A - i, p[1] = A - (i + o) + (o - m), T = w + i, o = T - w, p[2] = w - (T - o) + (i - o), p[3] = T;
36
- const nt = V(st, q, 4, p, L);
37
- v = d * y, u = k * d, b = u - (u - d), x = d - b, u = k * y, h = u - (u - y), c = y - h, E = x * c - (v - b * h - x * h - b * c), m = g * l, u = k * g, b = u - (u - g), x = g - b, u = k * l, h = u - (u - l), c = l - h, M = x * c - (m - b * h - x * h - b * c), i = E - M, o = E - i, p[0] = E - (i + o) + (o - M), w = v + i, o = w - v, A = v - (w - o) + (i - o), i = A - m, o = A - i, p[1] = A - (i + o) + (o - m), T = w + i, o = T - w, p[2] = w - (T - o) + (i - o), p[3] = T;
38
- const it = V(nt, L, 4, p, G);
26
+ const ut = (3 + 16 * R) * R, ht = (2 + 12 * R) * R, gt = (9 + 64 * R) * R * R, F = $(4), q = $(8), L = $(12), G = $(16), P = $(4);
27
+ function dt(e, t, s, r, a, n, c) {
28
+ let d, g, l, y, o, u, b, x, h, f, i, w, A, v, E, m, M, T;
29
+ const S = e - a, p = s - a, k = t - n, N = r - n;
30
+ v = S * N, u = I * S, b = u - (u - S), x = S - b, u = I * N, h = u - (u - N), f = N - h, E = x * f - (v - b * h - x * h - b * f), m = k * p, u = I * k, b = u - (u - k), x = k - b, u = I * 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 = v + i, o = w - v, A = v - (w - o) + (i - o), i = A - m, o = A - i, F[1] = A - (i + o) + (o - m), T = w + i, o = T - w, F[2] = w - (T - o) + (i - o), F[3] = T;
31
+ let U = ct(4, F), X = ht * c;
32
+ if (U >= X || -U >= X || (o = e - S, d = e - (S + o) + (o - a), o = s - p, l = s - (p + o) + (o - a), o = t - k, g = t - (k + o) + (o - n), o = r - N, y = r - (N + o) + (o - n), d === 0 && g === 0 && l === 0 && y === 0) || (X = gt * c + ft * Math.abs(U), U += S * y + N * d - (k * l + p * g), U >= X || -U >= X)) return U;
33
+ v = d * N, u = I * d, b = u - (u - d), x = d - b, u = I * N, h = u - (u - N), f = N - h, E = x * f - (v - b * h - x * h - b * f), m = g * p, u = I * g, b = u - (u - g), x = g - b, u = I * 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 = v + i, o = w - v, A = v - (w - o) + (i - o), i = A - m, o = A - i, P[1] = A - (i + o) + (o - m), T = w + i, o = T - w, P[2] = w - (T - o) + (i - o), P[3] = T;
34
+ const st = V(4, F, 4, P, q);
35
+ v = S * y, u = I * S, b = u - (u - S), x = S - b, u = I * y, h = u - (u - y), f = y - h, E = x * f - (v - b * h - x * h - b * f), m = k * l, u = I * k, b = u - (u - k), x = k - b, u = I * l, h = u - (u - l), f = l - 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 = v + i, o = w - v, A = v - (w - o) + (i - o), i = A - m, o = A - i, P[1] = A - (i + o) + (o - m), T = w + i, o = T - w, P[2] = w - (T - o) + (i - o), P[3] = T;
36
+ const nt = V(st, q, 4, P, L);
37
+ v = d * y, u = I * d, b = u - (u - d), x = d - b, u = I * y, h = u - (u - y), f = y - h, E = x * f - (v - b * h - x * h - b * f), m = g * l, u = I * g, b = u - (u - g), x = g - b, u = I * l, h = u - (u - l), f = l - 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 = v + i, o = w - v, A = v - (w - o) + (i - o), i = A - m, o = A - i, P[1] = A - (i + o) + (o - m), T = w + i, o = T - w, P[2] = w - (T - o) + (i - o), P[3] = T;
38
+ const it = V(nt, L, 4, P, G);
39
39
  return G[it - 1];
40
40
  }
41
41
  function lt(e, t, s, r, a, n) {
42
- const f = (t - n) * (s - a), d = (e - a) * (r - n), g = f - d, l = Math.abs(f + d);
42
+ const c = (t - n) * (s - a), d = (e - a) * (r - n), g = c - d, l = Math.abs(c + d);
43
43
  return Math.abs(g) >= ut * l ? g : -dt(e, t, s, r, a, n, l);
44
44
  }
45
45
  function yt(e, t) {
46
- var s, r, a = 0, n, f, d, g, l, y, o, u = e[0], b = e[1], x = t.length;
46
+ var s, r, a = 0, n, c, d, g, l, y, o, u = e[0], b = e[1], x = t.length;
47
47
  for (s = 0; s < x; s++) {
48
48
  r = 0;
49
- var h = t[s], c = h.length - 1;
50
- if (y = h[0], y[0] !== h[c][0] && y[1] !== h[c][1])
49
+ var h = t[s], f = h.length - 1;
50
+ if (y = h[0], y[0] !== h[f][0] && y[1] !== h[f][1])
51
51
  throw new Error("First and last coordinates in a ring must be the same");
52
- for (f = y[0] - u, d = y[1] - b, r; r < c; r++) {
52
+ for (c = y[0] - u, d = y[1] - b, r; r < f; r++) {
53
53
  if (o = h[r + 1], g = o[0] - u, l = o[1] - b, d === 0 && l === 0) {
54
- if (g <= 0 && f >= 0 || f <= 0 && g >= 0)
54
+ if (g <= 0 && c >= 0 || c <= 0 && g >= 0)
55
55
  return 0;
56
56
  } else if (l >= 0 && d <= 0 || l <= 0 && d >= 0) {
57
- if (n = lt(f, g, d, l, 0, 0), n === 0)
57
+ if (n = lt(c, g, d, l, 0, 0), n === 0)
58
58
  return 0;
59
59
  (n > 0 && l > 0 && d <= 0 || n < 0 && l <= 0 && d > 0) && a++;
60
60
  }
61
- y = o, d = l, f = g;
61
+ y = o, d = l, c = g;
62
62
  }
63
63
  }
64
64
  return a % 2 !== 0;
@@ -138,9 +138,9 @@ function mt(e, t, s = {}) {
138
138
  throw new Error("point is required");
139
139
  if (!t)
140
140
  throw new Error("polygon is required");
141
- const r = bt(e), a = wt(t), n = a.type, f = t.bbox;
141
+ const r = bt(e), a = wt(t), n = a.type, c = t.bbox;
142
142
  let d = a.coordinates;
143
- if (f && xt(r, f) === !1)
143
+ if (c && xt(r, c) === !1)
144
144
  return !1;
145
145
  n === "Polygon" && (d = [d]);
146
146
  let g = !1;
@@ -217,7 +217,7 @@ function Tt(e) {
217
217
  }
218
218
  return e;
219
219
  }
220
- function kt(e) {
220
+ function It(e) {
221
221
  const t = ["a", "b", "c", "a"].map(
222
222
  (n) => e.properties[n].geom
223
223
  ), s = e.geometry.coordinates[0], r = e.properties, a = {
@@ -235,10 +235,10 @@ function _t(e) {
235
235
  };
236
236
  return tt([t], s);
237
237
  }
238
- function $(e, t, s, r, a, n = !1, f) {
238
+ function W(e, t, s, r, a, n = !1, c) {
239
239
  const d = e.map(
240
240
  (g) => {
241
- (!f || f < 2.00703) && (g = et(g));
241
+ (!c || c < 2.00703) && (g = et(g));
242
242
  const l = isFinite(g) ? t[g] : g === "c" ? r : g === "b0" ? a[0] : g === "b1" ? a[1] : g === "b2" ? a[2] : g === "b3" ? a[3] : function() {
243
243
  const y = g.match(/e(\d+)/);
244
244
  if (y) {
@@ -268,32 +268,35 @@ function z(e, t) {
268
268
  return t.features[s];
269
269
  }
270
270
  function rt(e, t, s) {
271
- const r = t.geometry.coordinates[0][0], a = t.geometry.coordinates[0][1], n = t.geometry.coordinates[0][2], f = e.geometry.coordinates, d = t.properties.a.geom, g = t.properties.b.geom, l = t.properties.c.geom, y = [a[0] - r[0], a[1] - r[1]], o = [n[0] - r[0], n[1] - r[1]], u = [f[0] - r[0], f[1] - r[1]], b = [g[0] - d[0], g[1] - d[1]], x = [l[0] - d[0], l[1] - d[1]];
272
- let h = (o[1] * u[0] - o[0] * u[1]) / (y[0] * o[1] - y[1] * o[0]), c = (y[0] * u[1] - y[1] * u[0]) / (y[0] * o[1] - y[1] * o[0]);
271
+ const r = t.geometry.coordinates[0][0], a = t.geometry.coordinates[0][1], n = t.geometry.coordinates[0][2], c = e.geometry.coordinates, d = t.properties.a.geom, g = t.properties.b.geom, l = 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] - d[0], g[1] - d[1]], x = [l[0] - d[0], l[1] - d[1]];
272
+ 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]);
273
273
  if (s) {
274
274
  const i = s[t.properties.a.index], w = s[t.properties.b.index], A = s[t.properties.c.index];
275
275
  let v;
276
- if (h < 0 || c < 0 || 1 - h - c < 0) {
277
- const E = h / (h + c), m = c / (h + c);
278
- v = h / w / (E / w + m / A), c = c / A / (E / w + m / A);
276
+ if (h < 0 || f < 0 || 1 - h - f < 0) {
277
+ const E = h / (h + f), m = f / (h + f);
278
+ v = h / w / (E / w + m / A), f = f / A / (E / w + m / A);
279
279
  } else
280
- v = h / w / (h / w + c / A + (1 - h - c) / i), c = c / A / (h / w + c / A + (1 - h - c) / i);
280
+ v = h / w / (h / w + f / A + (1 - h - f) / i), f = f / A / (h / w + f / A + (1 - h - f) / i);
281
281
  h = v;
282
282
  }
283
283
  return [
284
- h * b[0] + c * x[0] + d[0],
285
- h * b[1] + c * x[1] + d[1]
284
+ h * b[0] + f * x[0] + d[0],
285
+ h * b[1] + f * x[1] + d[1]
286
286
  ];
287
287
  }
288
288
  function vt(e, t, s, r) {
289
- const a = e.geometry.coordinates, n = s.geometry.coordinates, f = Math.atan2(a[0] - n[0], a[1] - n[1]), d = Et(f, t[0]), g = t[1][d];
289
+ const a = e.geometry.coordinates, n = s.geometry.coordinates, c = Math.atan2(a[0] - n[0], a[1] - n[1]), d = Et(c, t[0]);
290
+ if (d === void 0)
291
+ throw new Error("Unable to determine vertex index");
292
+ const g = t[1][d];
290
293
  return rt(e, g.features[0], r);
291
294
  }
292
- function Mt(e, t, s, r, a, n, f, d) {
295
+ function Mt(e, t, s, r, a, n, c, d) {
293
296
  let g;
294
- if (f && (g = z(e, B([f]))), !g) {
297
+ if (c && (g = z(e, B([c]))), !g) {
295
298
  if (s) {
296
- const l = e.geometry.coordinates, y = s.gridNum, o = s.xOrigin, u = s.yOrigin, b = s.xUnit, x = s.yUnit, h = s.gridCache, c = C(l[0], o, b, y), i = C(l[1], u, x, y), w = h[c] ? h[c][i] ? h[c][i] : [] : [];
299
+ const l = e.geometry.coordinates, y = s.gridNum, o = s.xOrigin, u = s.yOrigin, b = s.xUnit, x = s.yUnit, h = s.gridCache, f = C(l[0], o, b, y), i = C(l[1], u, x, y), w = h[f] ? h[f][i] ? h[f][i] : [] : [];
297
300
  t = B(w.map((A) => t.features[A]));
298
301
  }
299
302
  g = z(e, t);
@@ -307,7 +310,7 @@ function C(e, t, s, r) {
307
310
  function Et(e, t) {
308
311
  let s = K(e - t[0]), r = Math.PI * 2, a;
309
312
  for (let n = 0; n < t.length; n++) {
310
- const f = (n + 1) % t.length, d = K(e - t[f]), g = Math.min(Math.abs(s), Math.abs(d));
313
+ const c = (n + 1) % t.length, d = K(e - t[c]), g = Math.min(Math.abs(s), Math.abs(d));
311
314
  s * d <= 0 && g < r && (r = g, a = n), s = d;
312
315
  }
313
316
  return a;
@@ -361,15 +364,15 @@ const Q = 2.00703, O = class O {
361
364
  if (t.version || !t.tins && t.points && t.tins_points) {
362
365
  this.points = t.points, this.pointsWeightBuffer = !t.version || t.version < 2.00703 ? ["forw", "bakw"].reduce((r, a) => {
363
366
  const n = t.weight_buffer[a];
364
- return n && (r[a] = Object.keys(n).reduce((f, d) => {
367
+ return n && (r[a] = Object.keys(n).reduce((c, d) => {
365
368
  const g = et(d);
366
- return f[g] = n[d], f;
369
+ return c[g] = n[d], c;
367
370
  }, {})), r;
368
371
  }, {}) : t.weight_buffer, t.strict_status ? this.strict_status = t.strict_status : t.kinks_points ? this.strict_status = O.STATUS_ERROR : t.tins_points.length == 2 ? this.strict_status = O.STATUS_LOOSE : this.strict_status = O.STATUS_STRICT, this.vertices_params = {
369
372
  forw: [t.vertices_params[0]],
370
373
  bakw: [t.vertices_params[1]]
371
374
  }, this.vertices_params.forw[1] = [0, 1, 2, 3].map((r) => {
372
- const a = (r + 1) % 4, n = $(
375
+ const a = (r + 1) % 4, n = W(
373
376
  ["c", `b${r}`, `b${a}`],
374
377
  t.points,
375
378
  t.edgeNodes || [],
@@ -380,7 +383,7 @@ const Q = 2.00703, O = class O {
380
383
  );
381
384
  return B([n]);
382
385
  }), this.vertices_params.bakw[1] = [0, 1, 2, 3].map((r) => {
383
- const a = (r + 1) % 4, n = $(
386
+ const a = (r + 1) % 4, n = W(
384
387
  ["c", `b${r}`, `b${a}`],
385
388
  t.points,
386
389
  t.edgeNodes || [],
@@ -408,7 +411,7 @@ const Q = 2.00703, O = class O {
408
411
  this.tins = {
409
412
  forw: B(
410
413
  t.tins_points[0].map(
411
- (r) => $(
414
+ (r) => W(
412
415
  r,
413
416
  t.points,
414
417
  t.edgeNodes || [],
@@ -421,7 +424,7 @@ const Q = 2.00703, O = class O {
421
424
  ),
422
425
  bakw: B(
423
426
  t.tins_points[s].map(
424
- (r) => $(
427
+ (r) => W(
425
428
  r,
426
429
  t.points,
427
430
  t.edgeNodes || [],
@@ -444,21 +447,13 @@ const Q = 2.00703, O = class O {
444
447
  const s = [];
445
448
  for (let r = 0; r < this.tins.forw.features.length; r++) {
446
449
  const a = this.tins.forw.features[r];
447
- ["a", "b", "c"].map((n, f) => {
448
- const d = a.geometry.coordinates[0][f], g = a.properties[n].geom, l = a.properties[n].index;
449
- s[l] = [d, g];
450
+ ["a", "b", "c"].map((n, c) => {
451
+ const d = a.geometry.coordinates[0][c], g = a.properties[n].geom, l = a.properties[n].index;
452
+ typeof l == "number" && (s[l] = [d, g]);
450
453
  });
451
454
  }
452
455
  this.points = s;
453
456
  }
454
- return {
455
- tins: this.tins,
456
- strict_status: this.strict_status,
457
- weight_buffer: this.pointsWeightBuffer,
458
- vertices_params: this.vertices_params,
459
- centroid: this.centroid,
460
- kinks: this.kinks
461
- };
462
457
  }
463
458
  /**
464
459
  * TINネットワークのインデックスを作成します
@@ -473,31 +468,31 @@ const Q = 2.00703, O = class O {
473
468
  this.indexedTins = void 0;
474
469
  return;
475
470
  }
476
- let n = [], f = [];
471
+ let n = [], c = [];
477
472
  const d = s.features.map((h) => {
478
- let c = [];
473
+ let f = [];
479
474
  return J(h)[0].map((i) => {
480
- 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])), 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]));
481
- }), c;
475
+ 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]));
476
+ }), f;
482
477
  }), g = (n[1][0] - n[0][0]) / a, l = (n[1][1] - n[0][1]) / a, y = d.reduce(
483
- (h, c, i) => {
478
+ (h, f, i) => {
484
479
  const w = C(
485
- c[0][0],
480
+ f[0][0],
486
481
  n[0][0],
487
482
  g,
488
483
  a
489
484
  ), A = C(
490
- c[1][0],
485
+ f[1][0],
491
486
  n[0][0],
492
487
  g,
493
488
  a
494
489
  ), v = C(
495
- c[0][1],
490
+ f[0][1],
496
491
  n[0][1],
497
492
  l,
498
493
  a
499
494
  ), E = C(
500
- c[1][1],
495
+ f[1][1],
501
496
  n[0][1],
502
497
  l,
503
498
  a
@@ -511,30 +506,30 @@ const Q = 2.00703, O = class O {
511
506
  },
512
507
  []
513
508
  ), o = r.features.map((h) => {
514
- let c = [];
509
+ let f = [];
515
510
  return J(h)[0].map((i) => {
516
- 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])), 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]));
517
- }), c;
518
- }), u = (f[1][0] - f[0][0]) / a, b = (f[1][1] - f[0][1]) / a, x = o.reduce(
519
- (h, c, i) => {
511
+ 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]));
512
+ }), f;
513
+ }), u = (c[1][0] - c[0][0]) / a, b = (c[1][1] - c[0][1]) / a, x = o.reduce(
514
+ (h, f, i) => {
520
515
  const w = C(
521
- c[0][0],
522
516
  f[0][0],
517
+ c[0][0],
523
518
  u,
524
519
  a
525
520
  ), A = C(
526
- c[1][0],
527
- f[0][0],
521
+ f[1][0],
522
+ c[0][0],
528
523
  u,
529
524
  a
530
525
  ), v = C(
531
- c[0][1],
532
526
  f[0][1],
527
+ c[0][1],
533
528
  b,
534
529
  a
535
530
  ), E = C(
536
- c[1][1],
537
- f[0][1],
531
+ f[1][1],
532
+ c[0][1],
538
533
  b,
539
534
  a
540
535
  );
@@ -558,8 +553,8 @@ const Q = 2.00703, O = class O {
558
553
  },
559
554
  bakw: {
560
555
  gridNum: a,
561
- xOrigin: f[0][0],
562
- yOrigin: f[0][1],
556
+ xOrigin: c[0][0],
557
+ yOrigin: c[0][1],
563
558
  xUnit: u,
564
559
  yUnit: b,
565
560
  gridCache: x
@@ -583,7 +578,7 @@ const Q = 2.00703, O = class O {
583
578
  const a = Y(t);
584
579
  if (this.bounds && !s && !r && !D(a, this.boundsPolygon))
585
580
  return !1;
586
- const n = s ? this.tins.bakw : this.tins.forw, f = s ? this.indexedTins.bakw : this.indexedTins.forw, d = s ? this.vertices_params.bakw : this.vertices_params.forw, g = s ? this.centroid.bakw : this.centroid.forw, l = s ? this.pointsWeightBuffer.bakw : this.pointsWeightBuffer.forw;
581
+ const n = s ? this.tins.bakw : this.tins.forw, c = s ? this.indexedTins.bakw : this.indexedTins.forw, d = s ? this.vertices_params.bakw : this.vertices_params.forw, g = s ? this.centroid.bakw : this.centroid.forw, l = s ? this.pointsWeightBuffer.bakw : this.pointsWeightBuffer.forw;
587
582
  let y, o;
588
583
  this.stateFull && (this.stateBackward == s ? y = this.stateTriangle : (this.stateBackward = s, this.stateTriangle = void 0), o = (b) => {
589
584
  this.stateTriangle = b;
@@ -591,7 +586,7 @@ const Q = 2.00703, O = class O {
591
586
  let u = Mt(
592
587
  a,
593
588
  n,
594
- f,
589
+ c,
595
590
  d,
596
591
  g,
597
592
  l,
@@ -613,7 +608,7 @@ _(O, "VERTEX_PLAIN", "plain"), _(O, "VERTEX_BIRDEYE", "birdeye"), _(O, "MODE_STR
613
608
  let H = O;
614
609
  export {
615
610
  H as Transform,
616
- kt as counterTri,
611
+ It as counterTri,
617
612
  Q as format_version,
618
613
  At as normalizeEdges,
619
614
  Tt as rotateVerticesTriangle,
@@ -1 +1 @@
1
- (function(k,O){typeof exports=="object"&&typeof module<"u"?O(exports):typeof define=="function"&&define.amd?define(["exports"],O):(k=typeof globalThis<"u"?globalThis:k||self,O(k.maplat_transform={}))})(this,function(k){"use strict";var Ot=Object.defineProperty;var pt=(k,O,p)=>O in k?Ot(k,O,{enumerable:!0,configurable:!0,writable:!0,value:p}):k[O]=p;var x=(k,O,p)=>pt(k,typeof O!="symbol"?O+"":O,p);const O=11102230246251565e-32,p=134217729,ot=(3+8*O)*O;function D(e,t,s,r,a){let n,c,d,g,l=t[0],y=r[0],o=0,u=0;y>l==y>-l?(n=l,l=t[++o]):(n=y,y=r[++u]);let b=0;if(o<e&&u<s)for(y>l==y>-l?(c=l+n,d=n-(c-l),l=t[++o]):(c=y+n,d=n-(c-y),y=r[++u]),n=c,d!==0&&(a[b++]=d);o<e&&u<s;)y>l==y>-l?(c=n+l,g=c-n,d=n-(c-g)+(l-g),l=t[++o]):(c=n+y,g=c-n,d=n-(c-g)+(y-g),y=r[++u]),n=c,d!==0&&(a[b++]=d);for(;o<e;)c=n+l,g=c-n,d=n-(c-g)+(l-g),l=t[++o],n=c,d!==0&&(a[b++]=d);for(;u<s;)c=n+y,g=c-n,d=n-(c-g)+(y-g),y=r[++u],n=c,d!==0&&(a[b++]=d);return(n!==0||b===0)&&(a[b++]=n),b}function at(e,t){let s=t[0];for(let r=1;r<e;r++)s+=t[r];return s}function Y(e){return new Float64Array(e)}const ft=(3+16*O)*O,ct=(2+12*O)*O,ut=(9+64*O)*O*O,X=Y(4),G=Y(8),z=Y(12),J=Y(16),P=Y(4);function ht(e,t,s,r,a,n,c){let d,g,l,y,o,u,b,_,h,f,i,w,v,A,E,m,M,S;const I=e-a,N=s-a,C=t-n,R=r-n;A=I*R,u=p*I,b=u-(u-I),_=I-b,u=p*R,h=u-(u-R),f=R-h,E=_*f-(A-b*h-_*h-b*f),m=C*N,u=p*C,b=u-(u-C),_=C-b,u=p*N,h=u-(u-N),f=N-h,M=_*f-(m-b*h-_*h-b*f),i=E-M,o=E-i,X[0]=E-(i+o)+(o-M),w=A+i,o=w-A,v=A-(w-o)+(i-o),i=v-m,o=v-i,X[1]=v-(i+o)+(o-m),S=w+i,o=S-w,X[2]=w-(S-o)+(i-o),X[3]=S;let B=at(4,X),$=ct*c;if(B>=$||-B>=$||(o=e-I,d=e-(I+o)+(o-a),o=s-N,l=s-(N+o)+(o-a),o=t-C,g=t-(C+o)+(o-n),o=r-R,y=r-(R+o)+(o-n),d===0&&g===0&&l===0&&y===0)||($=ut*c+ot*Math.abs(B),B+=I*y+R*d-(C*l+N*g),B>=$||-B>=$))return B;A=d*R,u=p*d,b=u-(u-d),_=d-b,u=p*R,h=u-(u-R),f=R-h,E=_*f-(A-b*h-_*h-b*f),m=g*N,u=p*g,b=u-(u-g),_=g-b,u=p*N,h=u-(u-N),f=N-h,M=_*f-(m-b*h-_*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),S=w+i,o=S-w,P[2]=w-(S-o)+(i-o),P[3]=S;const Mt=D(4,X,4,P,G);A=I*y,u=p*I,b=u-(u-I),_=I-b,u=p*y,h=u-(u-y),f=y-h,E=_*f-(A-b*h-_*h-b*f),m=C*l,u=p*C,b=u-(u-C),_=C-b,u=p*l,h=u-(u-l),f=l-h,M=_*f-(m-b*h-_*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),S=w+i,o=S-w,P[2]=w-(S-o)+(i-o),P[3]=S;const Et=D(Mt,G,4,P,z);A=d*y,u=p*d,b=u-(u-d),_=d-b,u=p*y,h=u-(u-y),f=y-h,E=_*f-(A-b*h-_*h-b*f),m=g*l,u=p*g,b=u-(u-g),_=g-b,u=p*l,h=u-(u-l),f=l-h,M=_*f-(m-b*h-_*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),S=w+i,o=S-w,P[2]=w-(S-o)+(i-o),P[3]=S;const Tt=D(Et,z,4,P,J);return J[Tt-1]}function gt(e,t,s,r,a,n){const c=(t-n)*(s-a),d=(e-a)*(r-n),g=c-d,l=Math.abs(c+d);return Math.abs(g)>=ft*l?g:-ht(e,t,s,r,a,n,l)}function dt(e,t){var s,r,a=0,n,c,d,g,l,y,o,u=e[0],b=e[1],_=t.length;for(s=0;s<_;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,d=y[1]-b,r;r<f;r++){if(o=h[r+1],g=o[0]-u,l=o[1]-b,d===0&&l===0){if(g<=0&&c>=0||c<=0&&g>=0)return 0}else if(l>=0&&d<=0||l<=0&&d>=0){if(n=gt(c,g,d,l,0,0),n===0)return 0;(n>0&&l>0&&d<=0||n<0&&l<=0&&d>0)&&a++}y=o,d=l,c=g}}return a%2!==0}function K(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 W(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(!H(e[0])||!H(e[1]))throw new Error("coordinates must contain numbers");return K({type:"Point",coordinates:e},t,s)}function Q(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 K({type:"Polygon",coordinates:e},t,s)}function F(e,t={}){const s={type:"FeatureCollection"};return t.id&&(s.id=t.id),t.bbox&&(s.bbox=t.bbox),s.features=e,s}function H(e){return!isNaN(e)&&e!==null&&!Array.isArray(e)}function lt(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 Z(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 yt(e){return e.type==="Feature"?e.geometry:e}function bt(e,t,s={}){if(!e)throw new Error("point is required");if(!t)throw new Error("polygon is required");const r=lt(e),a=yt(t),n=a.type,c=t.bbox;let d=a.coordinates;if(c&&wt(r,c)===!1)return!1;n==="Polygon"&&(d=[d]);let g=!1;for(var l=0;l<d.length;++l){const y=dt(r,d[l]);if(y===0)return!s.ignoreBoundary;y&&(g=!0)}return g}function wt(e,t){return t[0]<=e[0]&&t[1]<=e[1]&&t[2]>=e[0]&&t[3]>=e[1]}var q=bt;function mt(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 _t(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 Q([t],a)}function xt(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 Q([t],s)}function V(e,t,s,r,a,n=!1,c){const d=e.map(g=>{(!c||c<2.00703)&&(g=tt(g));const l=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?[[l[1],l[0]],g]:[[l[0],l[1]],g]});return xt(d)}function tt(e){return typeof e=="number"?e:e.replace(/^(c|e|b)(?:ent|dgeNode|box)(\d+)?$/,"$1$2")}function et(e,t){return t&&t>=2.00703||Array.isArray(e[0])?e:e.map(s=>[s.illstNodes,s.mercNodes,s.startEnd])}function rt(e,t){for(let s=0;s<t.features.length;s++)if(q(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,d=t.properties.a.geom,g=t.properties.b.geom,l=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]-d[0],g[1]-d[1]],_=[l[0]-d[0],l[1]-d[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*_[0]+d[0],h*b[1]+f*_[1]+d[1]]}function vt(e,t,s,r){const a=e.geometry.coordinates,n=s.geometry.coordinates,c=Math.atan2(a[0]-n[0],a[1]-n[1]),d=At(c,t[0]),g=t[1][d];return st(e,g.features[0],r)}function nt(e,t,s,r,a,n,c,d){let g;if(c&&(g=rt(e,F([c]))),!g){if(s){const l=e.geometry.coordinates,y=s.gridNum,o=s.xOrigin,u=s.yOrigin,b=s.xUnit,_=s.yUnit,h=s.gridCache,f=U(l[0],o,b,y),i=U(l[1],u,_,y),w=h[f]?h[f][i]?h[f][i]:[]:[];t=F(w.map(v=>t.features[v]))}g=rt(e,t)}return d&&d(g),g?st(e,g,n):vt(e,r,a,n)}function U(e,t,s,r){let a=Math.floor((e-t)/s);return a>=r&&(a=r-1),a}function At(e,t){let s=it(e-t[0]),r=Math.PI*2,a;for(let n=0;n<t.length;n++){const c=(n+1)%t.length,d=it(e-t[c]),g=Math.min(Math.abs(s),Math.abs(d));s*d<=0&&g<r&&(r=g,a=n),s=d}return a}function it(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 L=2.00703,T=class T{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",T.YAXIS_INVERT);x(this,"strictMode",T.MODE_AUTO);x(this,"vertexMode",T.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")}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,d)=>{const g=tt(d);return c[g]=n[d],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=V(["c",`b${r}`,`b${a}`],t.points,t.edgeNodes||[],t.centroid_point,t.vertices_points,!1,L);return F([n])}),this.vertices_params.bakw[1]=[0,1,2,3].map(r=>{const a=(r+1)%4,n=V(["c",`b${r}`,`b${a}`],t.points,t.edgeNodes||[],t.centroid_point,t.vertices_points,!0,L);return F([n])}),this.centroid={forw:W(t.centroid_point[0],{target:{geom:t.centroid_point[1],index:"c"}}),bakw:W(t.centroid_point[1],{target:{geom:t.centroid_point[0],index:"c"}})},this.edges=et(t.edges||[]),this.edgeNodes=t.edgeNodes||[];const s=t.tins_points.length==1?0:1;this.tins={forw:F(t.tins_points[0].map(r=>V(r,t.points,t.edgeNodes||[],t.centroid_point,t.vertices_points,!1,t.version))),bakw:F(t.tins_points[s].map(r=>V(r,t.points,t.edgeNodes||[],t.centroid_point,t.vertices_points,!0,t.version)))},this.addIndexedTin(),t.kinks_points&&(this.kinks={bakw:F(t.kinks_points.map(r=>W(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 d=a.geometry.coordinates[0][c],g=a.properties[n].geom,l=a.properties[n].index;s[l]=[d,g]})}this.points=s}return{tins:this.tins,strict_status:this.strict_status,weight_buffer:this.pointsWeightBuffer,vertices_params:this.vertices_params,centroid:this.centroid,kinks:this.kinks}}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 d=s.features.map(h=>{let f=[];return Z(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,l=(n[1][1]-n[0][1])/a,y=d.reduce((h,f,i)=>{const w=U(f[0][0],n[0][0],g,a),v=U(f[1][0],n[0][0],g,a),A=U(f[0][1],n[0][1],l,a),E=U(f[1][1],n[0][1],l,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 Z(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,_=o.reduce((h,f,i)=>{const w=U(f[0][0],c[0][0],u,a),v=U(f[1][0],c[0][0],u,a),A=U(f[0][1],c[0][1],b,a),E=U(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:l,gridCache:y},bakw:{gridNum:a,xOrigin:c[0][0],yOrigin:c[0][1],xUnit:u,yUnit:b,gridCache:_}}}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=W(t);if(this.bounds&&!s&&!r&&!q(a,this.boundsPolygon))return!1;const n=s?this.tins.bakw:this.tins.forw,c=s?this.indexedTins.bakw:this.indexedTins.forw,d=s?this.vertices_params.bakw:this.vertices_params.forw,g=s?this.centroid.bakw:this.centroid.forw,l=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,d,g,l,y,o);if(this.bounds&&s&&!r){const b=W(u);if(!q(b,this.boundsPolygon))return!1}else this.yaxisMode==T.YAXIS_FOLLOW&&!s&&(u=[u[0],-1*u[1]]);return u}};x(T,"VERTEX_PLAIN","plain"),x(T,"VERTEX_BIRDEYE","birdeye"),x(T,"MODE_STRICT","strict"),x(T,"MODE_AUTO","auto"),x(T,"MODE_LOOSE","loose"),x(T,"STATUS_STRICT","strict"),x(T,"STATUS_ERROR","strict_error"),x(T,"STATUS_LOOSE","loose"),x(T,"YAXIS_FOLLOW","follow"),x(T,"YAXIS_INVERT","invert");let j=T;k.Transform=j,k.counterTri=_t,k.format_version=L,k.normalizeEdges=et,k.rotateVerticesTriangle=mt,k.transformArr=nt,Object.defineProperty(k,Symbol.toStringTag,{value:"Module"})});
1
+ (function(p,O){typeof exports=="object"&&typeof module<"u"?O(exports):typeof define=="function"&&define.amd?define(["exports"],O):(p=typeof globalThis<"u"?globalThis:p||self,O(p.maplat_transform={}))})(this,function(p){"use strict";var Ot=Object.defineProperty;var St=(p,O,S)=>O in p?Ot(p,O,{enumerable:!0,configurable:!0,writable:!0,value:S}):p[O]=S;var _=(p,O,S)=>St(p,typeof O!="symbol"?O+"":O,S);const O=11102230246251565e-32,S=134217729,ot=(3+8*O)*O;function D(e,t,n,r,a){let s,c,d,g,l=t[0],y=r[0],o=0,u=0;y>l==y>-l?(s=l,l=t[++o]):(s=y,y=r[++u]);let b=0;if(o<e&&u<n)for(y>l==y>-l?(c=l+s,d=s-(c-l),l=t[++o]):(c=y+s,d=s-(c-y),y=r[++u]),s=c,d!==0&&(a[b++]=d);o<e&&u<n;)y>l==y>-l?(c=s+l,g=c-s,d=s-(c-g)+(l-g),l=t[++o]):(c=s+y,g=c-s,d=s-(c-g)+(y-g),y=r[++u]),s=c,d!==0&&(a[b++]=d);for(;o<e;)c=s+l,g=c-s,d=s-(c-g)+(l-g),l=t[++o],s=c,d!==0&&(a[b++]=d);for(;u<n;)c=s+y,g=c-s,d=s-(c-g)+(y-g),y=r[++u],s=c,d!==0&&(a[b++]=d);return(s!==0||b===0)&&(a[b++]=s),b}function at(e,t){let n=t[0];for(let r=1;r<e;r++)n+=t[r];return n}function Y(e){return new Float64Array(e)}const ft=(3+16*O)*O,ct=(2+12*O)*O,ut=(9+64*O)*O*O,X=Y(4),G=Y(8),z=Y(12),J=Y(16),I=Y(4);function ht(e,t,n,r,a,s,c){let d,g,l,y,o,u,b,x,h,f,i,w,v,A,E,m,M,P;const k=e-a,N=n-a,C=t-s,U=r-s;A=k*U,u=S*k,b=u-(u-k),x=k-b,u=S*U,h=u-(u-U),f=U-h,E=x*f-(A-b*h-x*h-b*f),m=C*N,u=S*C,b=u-(u-C),x=C-b,u=S*N,h=u-(u-N),f=N-h,M=x*f-(m-b*h-x*h-b*f),i=E-M,o=E-i,X[0]=E-(i+o)+(o-M),w=A+i,o=w-A,v=A-(w-o)+(i-o),i=v-m,o=v-i,X[1]=v-(i+o)+(o-m),P=w+i,o=P-w,X[2]=w-(P-o)+(i-o),X[3]=P;let B=at(4,X),W=ct*c;if(B>=W||-B>=W||(o=e-k,d=e-(k+o)+(o-a),o=n-N,l=n-(N+o)+(o-a),o=t-C,g=t-(C+o)+(o-s),o=r-U,y=r-(U+o)+(o-s),d===0&&g===0&&l===0&&y===0)||(W=ut*c+ot*Math.abs(B),B+=k*y+U*d-(C*l+N*g),B>=W||-B>=W))return B;A=d*U,u=S*d,b=u-(u-d),x=d-b,u=S*U,h=u-(u-U),f=U-h,E=x*f-(A-b*h-x*h-b*f),m=g*N,u=S*g,b=u-(u-g),x=g-b,u=S*N,h=u-(u-N),f=N-h,M=x*f-(m-b*h-x*h-b*f),i=E-M,o=E-i,I[0]=E-(i+o)+(o-M),w=A+i,o=w-A,v=A-(w-o)+(i-o),i=v-m,o=v-i,I[1]=v-(i+o)+(o-m),P=w+i,o=P-w,I[2]=w-(P-o)+(i-o),I[3]=P;const Mt=D(4,X,4,I,G);A=k*y,u=S*k,b=u-(u-k),x=k-b,u=S*y,h=u-(u-y),f=y-h,E=x*f-(A-b*h-x*h-b*f),m=C*l,u=S*C,b=u-(u-C),x=C-b,u=S*l,h=u-(u-l),f=l-h,M=x*f-(m-b*h-x*h-b*f),i=E-M,o=E-i,I[0]=E-(i+o)+(o-M),w=A+i,o=w-A,v=A-(w-o)+(i-o),i=v-m,o=v-i,I[1]=v-(i+o)+(o-m),P=w+i,o=P-w,I[2]=w-(P-o)+(i-o),I[3]=P;const Et=D(Mt,G,4,I,z);A=d*y,u=S*d,b=u-(u-d),x=d-b,u=S*y,h=u-(u-y),f=y-h,E=x*f-(A-b*h-x*h-b*f),m=g*l,u=S*g,b=u-(u-g),x=g-b,u=S*l,h=u-(u-l),f=l-h,M=x*f-(m-b*h-x*h-b*f),i=E-M,o=E-i,I[0]=E-(i+o)+(o-M),w=A+i,o=w-A,v=A-(w-o)+(i-o),i=v-m,o=v-i,I[1]=v-(i+o)+(o-m),P=w+i,o=P-w,I[2]=w-(P-o)+(i-o),I[3]=P;const Tt=D(Et,z,4,I,J);return J[Tt-1]}function gt(e,t,n,r,a,s){const c=(t-s)*(n-a),d=(e-a)*(r-s),g=c-d,l=Math.abs(c+d);return Math.abs(g)>=ft*l?g:-ht(e,t,n,r,a,s,l)}function dt(e,t){var n,r,a=0,s,c,d,g,l,y,o,u=e[0],b=e[1],x=t.length;for(n=0;n<x;n++){r=0;var h=t[n],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,d=y[1]-b,r;r<f;r++){if(o=h[r+1],g=o[0]-u,l=o[1]-b,d===0&&l===0){if(g<=0&&c>=0||c<=0&&g>=0)return 0}else if(l>=0&&d<=0||l<=0&&d>=0){if(s=gt(c,g,d,l,0,0),s===0)return 0;(s>0&&l>0&&d<=0||s<0&&l<=0&&d>0)&&a++}y=o,d=l,c=g}}return a%2!==0}function K(e,t,n={}){const r={type:"Feature"};return(n.id===0||n.id)&&(r.id=n.id),n.bbox&&(r.bbox=n.bbox),r.properties=t||{},r.geometry=e,r}function $(e,t,n={}){if(!e)throw new Error("coordinates is required");if(!Array.isArray(e))throw new Error("coordinates must be an Array");if(e.length<2)throw new Error("coordinates must be at least 2 numbers long");if(!H(e[0])||!H(e[1]))throw new Error("coordinates must contain numbers");return K({type:"Point",coordinates:e},t,n)}function Q(e,t,n={}){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 s=0;s<a[a.length-1].length;s++)if(a[a.length-1][s]!==a[0][s])throw new Error("First and last Position are not equivalent.")}return K({type:"Polygon",coordinates:e},t,n)}function F(e,t={}){const n={type:"FeatureCollection"};return t.id&&(n.id=t.id),t.bbox&&(n.bbox=t.bbox),n.features=e,n}function H(e){return!isNaN(e)&&e!==null&&!Array.isArray(e)}function lt(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 Z(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 yt(e){return e.type==="Feature"?e.geometry:e}function bt(e,t,n={}){if(!e)throw new Error("point is required");if(!t)throw new Error("polygon is required");const r=lt(e),a=yt(t),s=a.type,c=t.bbox;let d=a.coordinates;if(c&&wt(r,c)===!1)return!1;s==="Polygon"&&(d=[d]);let g=!1;for(var l=0;l<d.length;++l){const y=dt(r,d[l]);if(y===0)return!n.ignoreBoundary;y&&(g=!0)}return g}function wt(e,t){return t[0]<=e[0]&&t[1]<=e[1]&&t[2]>=e[0]&&t[3]>=e[1]}var q=bt;function mt(e){const t=e.features;for(let n=0;n<t.length;n++){const r=t[n];`${r.properties.a.index}`.substring(0,1)==="b"&&`${r.properties.b.index}`.substring(0,1)==="b"?t[n]={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[n]={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 xt(e){const t=["a","b","c","a"].map(s=>e.properties[s].geom),n=e.geometry.coordinates[0],r=e.properties,a={a:{geom:n[0],index:r.a.index},b:{geom:n[1],index:r.b.index},c:{geom:n[2],index:r.c.index}};return Q([t],a)}function _t(e){const t=[0,1,2,0].map(r=>e[r][0][0]),n={a:{geom:e[0][0][1],index:e[0][1]},b:{geom:e[1][0][1],index:e[1][1]},c:{geom:e[2][0][1],index:e[2][1]}};return Q([t],n)}function V(e,t,n,r,a,s=!1,c){const d=e.map(g=>{(!c||c<2.00703)&&(g=tt(g));const l=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 n[o]}throw"Bad index value for indexesToTri"}();return s?[[l[1],l[0]],g]:[[l[0],l[1]],g]});return _t(d)}function tt(e){return typeof e=="number"?e:e.replace(/^(c|e|b)(?:ent|dgeNode|box)(\d+)?$/,"$1$2")}function et(e,t){return t&&t>=2.00703||Array.isArray(e[0])?e:e.map(n=>[n.illstNodes,n.mercNodes,n.startEnd])}function rt(e,t){for(let n=0;n<t.features.length;n++)if(q(e,t.features[n]))return t.features[n]}function nt(e,t,n){const r=t.geometry.coordinates[0][0],a=t.geometry.coordinates[0][1],s=t.geometry.coordinates[0][2],c=e.geometry.coordinates,d=t.properties.a.geom,g=t.properties.b.geom,l=t.properties.c.geom,y=[a[0]-r[0],a[1]-r[1]],o=[s[0]-r[0],s[1]-r[1]],u=[c[0]-r[0],c[1]-r[1]],b=[g[0]-d[0],g[1]-d[1]],x=[l[0]-d[0],l[1]-d[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(n){const i=n[t.properties.a.index],w=n[t.properties.b.index],v=n[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]+d[0],h*b[1]+f*x[1]+d[1]]}function vt(e,t,n,r){const a=e.geometry.coordinates,s=n.geometry.coordinates,c=Math.atan2(a[0]-s[0],a[1]-s[1]),d=At(c,t[0]);if(d===void 0)throw new Error("Unable to determine vertex index");const g=t[1][d];return nt(e,g.features[0],r)}function st(e,t,n,r,a,s,c,d){let g;if(c&&(g=rt(e,F([c]))),!g){if(n){const l=e.geometry.coordinates,y=n.gridNum,o=n.xOrigin,u=n.yOrigin,b=n.xUnit,x=n.yUnit,h=n.gridCache,f=R(l[0],o,b,y),i=R(l[1],u,x,y),w=h[f]?h[f][i]?h[f][i]:[]:[];t=F(w.map(v=>t.features[v]))}g=rt(e,t)}return d&&d(g),g?nt(e,g,s):vt(e,r,a,s)}function R(e,t,n,r){let a=Math.floor((e-t)/n);return a>=r&&(a=r-1),a}function At(e,t){let n=it(e-t[0]),r=Math.PI*2,a;for(let s=0;s<t.length;s++){const c=(s+1)%t.length,d=it(e-t[c]),g=Math.min(Math.abs(n),Math.abs(d));n*d<=0&&g<r&&(r=g,a=s),n=d}return a}function it(e,t=!1){const n=t?function(r){return!(r>=0&&r<Math.PI*2)}:function(r){return!(r>-1*Math.PI&&r<=Math.PI)};for(;n(e);)e=e+2*Math.PI*(e>0?-1:1);return e}const L=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 s=t.weight_buffer[a];return s&&(r[a]=Object.keys(s).reduce((c,d)=>{const g=tt(d);return c[g]=s[d],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,s=V(["c",`b${r}`,`b${a}`],t.points,t.edgeNodes||[],t.centroid_point,t.vertices_points,!1,L);return F([s])}),this.vertices_params.bakw[1]=[0,1,2,3].map(r=>{const a=(r+1)%4,s=V(["c",`b${r}`,`b${a}`],t.points,t.edgeNodes||[],t.centroid_point,t.vertices_points,!0,L);return F([s])}),this.centroid={forw:$(t.centroid_point[0],{target:{geom:t.centroid_point[1],index:"c"}}),bakw:$(t.centroid_point[1],{target:{geom:t.centroid_point[0],index:"c"}})},this.edges=et(t.edges||[]),this.edgeNodes=t.edgeNodes||[];const n=t.tins_points.length==1?0:1;this.tins={forw:F(t.tins_points[0].map(r=>V(r,t.points,t.edgeNodes||[],t.centroid_point,t.vertices_points,!1,t.version))),bakw:F(t.tins_points[n].map(r=>V(r,t.points,t.edgeNodes||[],t.centroid_point,t.vertices_points,!0,t.version)))},this.addIndexedTin(),t.kinks_points&&(this.kinks={bakw:F(t.kinks_points.map(r=>$(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 n=[];for(let r=0;r<this.tins.forw.features.length;r++){const a=this.tins.forw.features[r];["a","b","c"].map((s,c)=>{const d=a.geometry.coordinates[0][c],g=a.properties[s].geom,l=a.properties[s].index;typeof l=="number"&&(n[l]=[d,g])})}this.points=n}}addIndexedTin(){const t=this.tins,n=t.forw,r=t.bakw,a=Math.ceil(Math.sqrt(n.features.length));if(a<3){this.indexedTins=void 0;return}let s=[],c=[];const d=n.features.map(h=>{let f=[];return Z(h)[0].map(i=>{s.length===0?s=[Array.from(i),Array.from(i)]:(i[0]<s[0][0]&&(s[0][0]=i[0]),i[0]>s[1][0]&&(s[1][0]=i[0]),i[1]<s[0][1]&&(s[0][1]=i[1]),i[1]>s[1][1]&&(s[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=(s[1][0]-s[0][0])/a,l=(s[1][1]-s[0][1])/a,y=d.reduce((h,f,i)=>{const w=R(f[0][0],s[0][0],g,a),v=R(f[1][0],s[0][0],g,a),A=R(f[0][1],s[0][1],l,a),E=R(f[1][1],s[0][1],l,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 Z(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=R(f[0][0],c[0][0],u,a),v=R(f[1][0],c[0][0],u,a),A=R(f[0][1],c[0][1],b,a),E=R(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:s[0][0],yOrigin:s[0][1],xUnit:g,yUnit:l,gridCache:y},bakw:{gridNum:a,xOrigin:c[0][0],yOrigin:c[0][1],xUnit:u,yUnit:b,gridCache:x}}}transform(t,n,r){if(n&&this.strict_status==T.STATUS_ERROR)throw'Backward transform is not allowed if strict_status == "strict_error"';this.yaxisMode==T.YAXIS_FOLLOW&&n&&(t=[t[0],-1*t[1]]);const a=$(t);if(this.bounds&&!n&&!r&&!q(a,this.boundsPolygon))return!1;const s=n?this.tins.bakw:this.tins.forw,c=n?this.indexedTins.bakw:this.indexedTins.forw,d=n?this.vertices_params.bakw:this.vertices_params.forw,g=n?this.centroid.bakw:this.centroid.forw,l=n?this.pointsWeightBuffer.bakw:this.pointsWeightBuffer.forw;let y,o;this.stateFull&&(this.stateBackward==n?y=this.stateTriangle:(this.stateBackward=n,this.stateTriangle=void 0),o=b=>{this.stateTriangle=b});let u=st(a,s,c,d,g,l,y,o);if(this.bounds&&n&&!r){const b=$(u);if(!q(b,this.boundsPolygon))return!1}else this.yaxisMode==T.YAXIS_FOLLOW&&!n&&(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 j=T;p.Transform=j,p.counterTri=xt,p.format_version=L,p.normalizeEdges=et,p.rotateVerticesTriangle=mt,p.transformArr=st,Object.defineProperty(p,Symbol.toStringTag,{value:"Module"})});
package/package.json CHANGED
@@ -1,79 +1,87 @@
1
- {
2
- "name": "@maplat/transform",
3
- "private": false,
4
- "publishConfig": {
5
- "access": "public"
6
- },
7
- "version": "0.1.5",
8
- "description": "A JavaScript library that performs coordinate transformation between two plane coordinate systems using transformation definitions generated by Maplat.",
9
- "type": "module",
10
- "main": "./dist/maplat_transform.cjs",
11
- "module": "./dist/maplat_transform.js",
12
- "browser": "./dist/maplat_transform.umd.js",
13
- "types": "./dist/index.d.ts",
14
- "exports": {
15
- ".": {
16
- "import": "./dist/maplat_transform.js",
17
- "require": "./dist/maplat_transform.cjs",
18
- "browser": "./dist/maplat_transform.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/MaplatTransform.git"
41
- },
42
- "author": "Code for History",
43
- "license": "Maplat Limited License 1.1",
44
- "bugs": {
45
- "url": "https://github.com/code4history/MaplatTransform/issues"
46
- },
47
- "homepage": "https://github.com/code4history/MaplatTransform/wiki",
48
- "keywords": [
49
- "projection",
50
- "GIS",
51
- "Maplat",
52
- "MaplatTransform"
53
- ],
54
- "peerDependencies": {},
55
- "devDependencies": {
56
- "@eslint/js": "^9.17.0",
57
- "@testing-library/jest-dom": "^6.6.3",
58
- "@types/geojson": "^7946.0.15",
59
- "@types/node": "^22.10.2",
60
- "@typescript-eslint/eslint-plugin": "^8.18.2",
61
- "@typescript-eslint/parser": "^8.18.2",
62
- "@vitest/coverage-v8": "^1.6.0",
63
- "cross-env": "^7.0.3",
64
- "eslint": "^9.17.0",
65
- "eslint-config-prettier": "^9.1.0",
66
- "jest-matcher-deep-close-to": "^3.0.2",
67
- "jsdom": "^25.0.1",
68
- "prettier": "^3.4.2",
69
- "typescript": "^5.7.2",
70
- "vite": "^5.4.11",
71
- "vite-plugin-dts": "^4.4.0",
72
- "vitest": "^1.6.0"
73
- },
74
- "dependencies": {
75
- "@turf/boolean-point-in-polygon": "^7.2.0",
76
- "@turf/helpers": "7.2.0",
77
- "@turf/invariant": "^7.2.0"
78
- }
79
- }
1
+ {
2
+ "name": "@maplat/transform",
3
+ "private": false,
4
+ "publishConfig": {
5
+ "access": "public"
6
+ },
7
+ "version": "0.2.1",
8
+ "description": "A JavaScript library that performs coordinate transformation between two plane coordinate systems using transformation definitions generated by Maplat.",
9
+ "type": "module",
10
+ "main": "./dist/maplat_transform.cjs",
11
+ "module": "./dist/maplat_transform.js",
12
+ "browser": "./dist/maplat_transform.umd.js",
13
+ "types": "./dist/index.d.ts",
14
+ "exports": {
15
+ ".": {
16
+ "import": "./dist/maplat_transform.js",
17
+ "require": "./dist/maplat_transform.cjs",
18
+ "browser": "./dist/maplat_transform.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": "npm run typecheck && cross-env BUILD_MODE=package vite build",
30
+ "typecheck": "tsc --noEmit --allowImportingTsExtensions",
31
+ "deploy": "cp public/*.html ./ && tsc && vite build",
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/MaplatTransform.git"
49
+ },
50
+ "author": "Code for History",
51
+ "license": "Maplat Limited License 1.1",
52
+ "bugs": {
53
+ "url": "https://github.com/code4history/MaplatTransform/issues"
54
+ },
55
+ "homepage": "https://github.com/code4history/MaplatTransform/wiki",
56
+ "keywords": [
57
+ "projection",
58
+ "GIS",
59
+ "Maplat",
60
+ "MaplatTransform"
61
+ ],
62
+ "peerDependencies": {},
63
+ "devDependencies": {
64
+ "@eslint/js": "^9.17.0",
65
+ "@testing-library/jest-dom": "^6.6.3",
66
+ "@types/geojson": "^7946.0.15",
67
+ "@types/node": "^22.10.2",
68
+ "@typescript-eslint/eslint-plugin": "^8.18.2",
69
+ "@typescript-eslint/parser": "^8.18.2",
70
+ "@vitest/coverage-v8": "^1.6.0",
71
+ "cross-env": "^7.0.3",
72
+ "eslint": "^9.17.0",
73
+ "eslint-config-prettier": "^9.1.0",
74
+ "jest-matcher-deep-close-to": "^3.0.2",
75
+ "jsdom": "^25.0.1",
76
+ "prettier": "^3.4.2",
77
+ "typescript": "^5.7.2",
78
+ "vite": "^5.4.11",
79
+ "vite-plugin-dts": "^4.4.0",
80
+ "vitest": "^1.6.0"
81
+ },
82
+ "dependencies": {
83
+ "@turf/boolean-point-in-polygon": "^7.2.0",
84
+ "@turf/helpers": "7.2.0",
85
+ "@turf/invariant": "^7.2.0"
86
+ }
87
+ }