@basemaps/cli-vector 8.2.0 → 8.4.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.
Files changed (50) hide show
  1. package/build/cli/cli.analyse.js +1 -1
  2. package/build/cli/cli.create.js +7 -3
  3. package/build/cli/cli.create.js.map +1 -1
  4. package/build/cli/cli.extract.js +1 -1
  5. package/build/cli/cli.extract.js.map +1 -1
  6. package/build/cli/cli.join.js +3 -3
  7. package/build/cli/cli.join.js.map +1 -1
  8. package/build/generalization/generalization.d.ts +2 -1
  9. package/build/generalization/generalization.js +31 -22
  10. package/build/generalization/generalization.js.map +1 -1
  11. package/build/modify/layers/place_labels.d.ts +5 -4
  12. package/build/modify/layers/place_labels.js +41 -57
  13. package/build/modify/layers/place_labels.js.map +1 -1
  14. package/build/modify/layers/pois.js +5 -3
  15. package/build/modify/layers/pois.js.map +1 -1
  16. package/build/modify/layers/public_transport.js +2 -20
  17. package/build/modify/layers/public_transport.js.map +1 -1
  18. package/build/modify/layers/{water_polygons.d.ts → water.d.ts} +2 -2
  19. package/build/modify/layers/{water_polygons.js → water.js} +12 -15
  20. package/build/modify/layers/water.js.map +1 -0
  21. package/build/modify/modify.js +3 -2
  22. package/build/modify/modify.js.map +1 -1
  23. package/build/modify/parser.d.ts +15 -32
  24. package/build/modify/parser.js +15 -15
  25. package/build/modify/parser.js.map +1 -1
  26. package/build/modify/schema.d.ts +5 -7
  27. package/build/modify/shared.d.ts +4 -0
  28. package/build/modify/shared.js +25 -5
  29. package/build/modify/shared.js.map +1 -1
  30. package/build/schema-loader/parser.d.ts +8 -0
  31. package/build/schema-loader/parser.js +1 -0
  32. package/build/schema-loader/parser.js.map +1 -1
  33. package/build/schema-loader/schema.d.ts +2 -0
  34. package/build/schema-loader/schema.loader.d.ts +3 -1
  35. package/build/schema-loader/schema.loader.js +9 -2
  36. package/build/schema-loader/schema.loader.js.map +1 -1
  37. package/build/stac.js +3 -2
  38. package/build/stac.js.map +1 -1
  39. package/build/transform/nztm.d.ts +4 -0
  40. package/build/transform/nztm.js +13 -0
  41. package/build/transform/nztm.js.map +1 -0
  42. package/build/transform/ogr2ogr.d.ts +3 -1
  43. package/build/transform/ogr2ogr.js +24 -1
  44. package/build/transform/ogr2ogr.js.map +1 -1
  45. package/build/transform/tippecanoe.d.ts +2 -1
  46. package/build/transform/tippecanoe.js +6 -5
  47. package/build/transform/tippecanoe.js.map +1 -1
  48. package/dist/index.cjs +736 -656
  49. package/package.json +7 -7
  50. package/build/modify/layers/water_polygons.js.map +0 -1
package/dist/index.cjs CHANGED
@@ -65691,14 +65691,14 @@ var require_polygon_clipping_cjs = __commonJS({
65691
65691
  if (windingsAfter[_i] === 0)
65692
65692
  continue;
65693
65693
  var _ring = ringsAfter[_i];
65694
- var poly = _ring.poly;
65695
- if (polysExclude.indexOf(poly) !== -1)
65694
+ var poly2 = _ring.poly;
65695
+ if (polysExclude.indexOf(poly2) !== -1)
65696
65696
  continue;
65697
65697
  if (_ring.isExterior)
65698
- polysAfter.push(poly);
65698
+ polysAfter.push(poly2);
65699
65699
  else {
65700
- if (polysExclude.indexOf(poly) === -1)
65701
- polysExclude.push(poly);
65700
+ if (polysExclude.indexOf(poly2) === -1)
65701
+ polysExclude.push(poly2);
65702
65702
  var _index = polysAfter.indexOf(_ring.poly);
65703
65703
  if (_index !== -1)
65704
65704
  polysAfter.splice(_index, 1);
@@ -65781,12 +65781,12 @@ var require_polygon_clipping_cjs = __commonJS({
65781
65781
  return Segment2;
65782
65782
  }();
65783
65783
  var RingIn = /* @__PURE__ */ function() {
65784
- function RingIn2(geomRing, poly, isExterior) {
65784
+ function RingIn2(geomRing, poly2, isExterior) {
65785
65785
  _classCallCheck(this, RingIn2);
65786
65786
  if (!Array.isArray(geomRing) || geomRing.length === 0) {
65787
65787
  throw new Error("Input geometry is not a valid Polygon or MultiPolygon");
65788
65788
  }
65789
- this.poly = poly;
65789
+ this.poly = poly2;
65790
65790
  this.isExterior = isExterior;
65791
65791
  this.segments = [];
65792
65792
  if (typeof geomRing[0][0] !== "number" || typeof geomRing[0][1] !== "number") {
@@ -65910,16 +65910,16 @@ var require_polygon_clipping_cjs = __commonJS({
65910
65910
  }
65911
65911
  };
65912
65912
  for (var i = 0, iMax = geom.length; i < iMax; i++) {
65913
- var poly = new PolyIn(geom[i], this);
65914
- if (poly.bbox.ll.x < this.bbox.ll.x)
65915
- this.bbox.ll.x = poly.bbox.ll.x;
65916
- if (poly.bbox.ll.y < this.bbox.ll.y)
65917
- this.bbox.ll.y = poly.bbox.ll.y;
65918
- if (poly.bbox.ur.x > this.bbox.ur.x)
65919
- this.bbox.ur.x = poly.bbox.ur.x;
65920
- if (poly.bbox.ur.y > this.bbox.ur.y)
65921
- this.bbox.ur.y = poly.bbox.ur.y;
65922
- this.polys.push(poly);
65913
+ var poly2 = new PolyIn(geom[i], this);
65914
+ if (poly2.bbox.ll.x < this.bbox.ll.x)
65915
+ this.bbox.ll.x = poly2.bbox.ll.x;
65916
+ if (poly2.bbox.ll.y < this.bbox.ll.y)
65917
+ this.bbox.ll.y = poly2.bbox.ll.y;
65918
+ if (poly2.bbox.ur.x > this.bbox.ur.x)
65919
+ this.bbox.ur.x = poly2.bbox.ur.x;
65920
+ if (poly2.bbox.ur.y > this.bbox.ur.y)
65921
+ this.bbox.ur.y = poly2.bbox.ur.y;
65922
+ this.polys.push(poly2);
65923
65923
  }
65924
65924
  this.isSubject = isSubject;
65925
65925
  }
@@ -70677,7 +70677,7 @@ var require_proj4_src = __commonJS({
70677
70677
  return p;
70678
70678
  }
70679
70679
  var names$19 = ["Polyconic", "poly"];
70680
- var poly = {
70680
+ var poly2 = {
70681
70681
  init: init$18,
70682
70682
  forward: forward$17,
70683
70683
  inverse: inverse$17,
@@ -72157,7 +72157,7 @@ var require_proj4_src = __commonJS({
72157
72157
  proj4.Proj.projections.add(gnom);
72158
72158
  proj4.Proj.projections.add(cea);
72159
72159
  proj4.Proj.projections.add(eqc);
72160
- proj4.Proj.projections.add(poly);
72160
+ proj4.Proj.projections.add(poly2);
72161
72161
  proj4.Proj.projections.add(nzmg);
72162
72162
  proj4.Proj.projections.add(mill);
72163
72163
  proj4.Proj.projections.add(sinu);
@@ -72643,6 +72643,225 @@ var require_src3 = __commonJS({
72643
72643
  }
72644
72644
  });
72645
72645
 
72646
+ // node_modules/tinyqueue/tinyqueue.js
72647
+ var require_tinyqueue = __commonJS({
72648
+ "node_modules/tinyqueue/tinyqueue.js"(exports, module2) {
72649
+ (function(global2, factory) {
72650
+ typeof exports === "object" && typeof module2 !== "undefined" ? module2.exports = factory() : typeof define === "function" && define.amd ? define(factory) : (global2 = global2 || self, global2.TinyQueue = factory());
72651
+ })(exports, function() {
72652
+ "use strict";
72653
+ var TinyQueue = function TinyQueue2(data, compare) {
72654
+ if (data === void 0)
72655
+ data = [];
72656
+ if (compare === void 0)
72657
+ compare = defaultCompare;
72658
+ this.data = data;
72659
+ this.length = this.data.length;
72660
+ this.compare = compare;
72661
+ if (this.length > 0) {
72662
+ for (var i = (this.length >> 1) - 1; i >= 0; i--) {
72663
+ this._down(i);
72664
+ }
72665
+ }
72666
+ };
72667
+ TinyQueue.prototype.push = function push2(item) {
72668
+ this.data.push(item);
72669
+ this.length++;
72670
+ this._up(this.length - 1);
72671
+ };
72672
+ TinyQueue.prototype.pop = function pop() {
72673
+ if (this.length === 0) {
72674
+ return void 0;
72675
+ }
72676
+ var top = this.data[0];
72677
+ var bottom = this.data.pop();
72678
+ this.length--;
72679
+ if (this.length > 0) {
72680
+ this.data[0] = bottom;
72681
+ this._down(0);
72682
+ }
72683
+ return top;
72684
+ };
72685
+ TinyQueue.prototype.peek = function peek() {
72686
+ return this.data[0];
72687
+ };
72688
+ TinyQueue.prototype._up = function _up(pos) {
72689
+ var ref = this;
72690
+ var data = ref.data;
72691
+ var compare = ref.compare;
72692
+ var item = data[pos];
72693
+ while (pos > 0) {
72694
+ var parent = pos - 1 >> 1;
72695
+ var current = data[parent];
72696
+ if (compare(item, current) >= 0) {
72697
+ break;
72698
+ }
72699
+ data[pos] = current;
72700
+ pos = parent;
72701
+ }
72702
+ data[pos] = item;
72703
+ };
72704
+ TinyQueue.prototype._down = function _down(pos) {
72705
+ var ref = this;
72706
+ var data = ref.data;
72707
+ var compare = ref.compare;
72708
+ var halfLength = this.length >> 1;
72709
+ var item = data[pos];
72710
+ while (pos < halfLength) {
72711
+ var left = (pos << 1) + 1;
72712
+ var best = data[left];
72713
+ var right = left + 1;
72714
+ if (right < this.length && compare(data[right], best) < 0) {
72715
+ left = right;
72716
+ best = data[right];
72717
+ }
72718
+ if (compare(best, item) >= 0) {
72719
+ break;
72720
+ }
72721
+ data[pos] = best;
72722
+ pos = left;
72723
+ }
72724
+ data[pos] = item;
72725
+ };
72726
+ function defaultCompare(a, b) {
72727
+ return a < b ? -1 : a > b ? 1 : 0;
72728
+ }
72729
+ return TinyQueue;
72730
+ });
72731
+ }
72732
+ });
72733
+
72734
+ // node_modules/polylabel/polylabel.js
72735
+ var require_polylabel = __commonJS({
72736
+ "node_modules/polylabel/polylabel.js"(exports, module2) {
72737
+ "use strict";
72738
+ var Queue2 = require_tinyqueue();
72739
+ if (Queue2.default)
72740
+ Queue2 = Queue2.default;
72741
+ module2.exports = polylabel2;
72742
+ module2.exports.default = polylabel2;
72743
+ function polylabel2(polygon, precision, debug) {
72744
+ precision = precision || 1;
72745
+ var minX, minY, maxX, maxY;
72746
+ for (var i = 0; i < polygon[0].length; i++) {
72747
+ var p = polygon[0][i];
72748
+ if (!i || p[0] < minX)
72749
+ minX = p[0];
72750
+ if (!i || p[1] < minY)
72751
+ minY = p[1];
72752
+ if (!i || p[0] > maxX)
72753
+ maxX = p[0];
72754
+ if (!i || p[1] > maxY)
72755
+ maxY = p[1];
72756
+ }
72757
+ var width = maxX - minX;
72758
+ var height = maxY - minY;
72759
+ var cellSize = Math.min(width, height);
72760
+ var h = cellSize / 2;
72761
+ if (cellSize === 0) {
72762
+ var degeneratePoleOfInaccessibility = [minX, minY];
72763
+ degeneratePoleOfInaccessibility.distance = 0;
72764
+ return degeneratePoleOfInaccessibility;
72765
+ }
72766
+ var cellQueue = new Queue2(void 0, compareMax);
72767
+ for (var x = minX; x < maxX; x += cellSize) {
72768
+ for (var y = minY; y < maxY; y += cellSize) {
72769
+ cellQueue.push(new Cell(x + h, y + h, h, polygon));
72770
+ }
72771
+ }
72772
+ var bestCell = getCentroidCell(polygon);
72773
+ var bboxCell = new Cell(minX + width / 2, minY + height / 2, 0, polygon);
72774
+ if (bboxCell.d > bestCell.d)
72775
+ bestCell = bboxCell;
72776
+ var numProbes = cellQueue.length;
72777
+ while (cellQueue.length) {
72778
+ var cell = cellQueue.pop();
72779
+ if (cell.d > bestCell.d) {
72780
+ bestCell = cell;
72781
+ if (debug)
72782
+ console.log("found best %d after %d probes", Math.round(1e4 * cell.d) / 1e4, numProbes);
72783
+ }
72784
+ if (cell.max - bestCell.d <= precision)
72785
+ continue;
72786
+ h = cell.h / 2;
72787
+ cellQueue.push(new Cell(cell.x - h, cell.y - h, h, polygon));
72788
+ cellQueue.push(new Cell(cell.x + h, cell.y - h, h, polygon));
72789
+ cellQueue.push(new Cell(cell.x - h, cell.y + h, h, polygon));
72790
+ cellQueue.push(new Cell(cell.x + h, cell.y + h, h, polygon));
72791
+ numProbes += 4;
72792
+ }
72793
+ if (debug) {
72794
+ console.log("num probes: " + numProbes);
72795
+ console.log("best distance: " + bestCell.d);
72796
+ }
72797
+ var poleOfInaccessibility = [bestCell.x, bestCell.y];
72798
+ poleOfInaccessibility.distance = bestCell.d;
72799
+ return poleOfInaccessibility;
72800
+ }
72801
+ function compareMax(a, b) {
72802
+ return b.max - a.max;
72803
+ }
72804
+ function Cell(x, y, h, polygon) {
72805
+ this.x = x;
72806
+ this.y = y;
72807
+ this.h = h;
72808
+ this.d = pointToPolygonDist(x, y, polygon);
72809
+ this.max = this.d + this.h * Math.SQRT2;
72810
+ }
72811
+ function pointToPolygonDist(x, y, polygon) {
72812
+ var inside = false;
72813
+ var minDistSq = Infinity;
72814
+ for (var k = 0; k < polygon.length; k++) {
72815
+ var ring = polygon[k];
72816
+ for (var i = 0, len = ring.length, j = len - 1; i < len; j = i++) {
72817
+ var a = ring[i];
72818
+ var b = ring[j];
72819
+ if (a[1] > y !== b[1] > y && x < (b[0] - a[0]) * (y - a[1]) / (b[1] - a[1]) + a[0])
72820
+ inside = !inside;
72821
+ minDistSq = Math.min(minDistSq, getSegDistSq(x, y, a, b));
72822
+ }
72823
+ }
72824
+ return minDistSq === 0 ? 0 : (inside ? 1 : -1) * Math.sqrt(minDistSq);
72825
+ }
72826
+ function getCentroidCell(polygon) {
72827
+ var area = 0;
72828
+ var x = 0;
72829
+ var y = 0;
72830
+ var points = polygon[0];
72831
+ for (var i = 0, len = points.length, j = len - 1; i < len; j = i++) {
72832
+ var a = points[i];
72833
+ var b = points[j];
72834
+ var f = a[0] * b[1] - b[0] * a[1];
72835
+ x += (a[0] + b[0]) * f;
72836
+ y += (a[1] + b[1]) * f;
72837
+ area += f * 3;
72838
+ }
72839
+ if (area === 0)
72840
+ return new Cell(points[0][0], points[0][1], 0, polygon);
72841
+ return new Cell(x / area, y / area, 0, polygon);
72842
+ }
72843
+ function getSegDistSq(px, py, a, b) {
72844
+ var x = a[0];
72845
+ var y = a[1];
72846
+ var dx = b[0] - x;
72847
+ var dy = b[1] - y;
72848
+ if (dx !== 0 || dy !== 0) {
72849
+ var t = ((px - x) * dx + (py - y) * dy) / (dx * dx + dy * dy);
72850
+ if (t > 1) {
72851
+ x = b[0];
72852
+ y = b[1];
72853
+ } else if (t > 0) {
72854
+ x += dx * t;
72855
+ y += dy * t;
72856
+ }
72857
+ }
72858
+ dx = px - x;
72859
+ dy = py - y;
72860
+ return dx * dx + dy * dy;
72861
+ }
72862
+ }
72863
+ });
72864
+
72646
72865
  // ../../node_modules/readable-stream/lib/internal/streams/stream.js
72647
72866
  var require_stream2 = __commonJS({
72648
72867
  "../../node_modules/readable-stream/lib/internal/streams/stream.js"(exports, module2) {
@@ -80329,9 +80548,9 @@ var ulid2 = __toESM(require_index_umd(), 1);
80329
80548
  var CliInfo = {
80330
80549
  // Detect unlinked packages looks for this string since its a package name, slightly work around it
80331
80550
  package: "@basemaps/cli",
80332
- version: "v8.2.0",
80333
- hash: "69195be692efa914369fa854d3bae16355dc0dc8",
80334
- buildId: "15601557572-1"
80551
+ version: "v8.4.0",
80552
+ hash: "f30c12a7491ec5556f62b3f35d985d2e89a15c39",
80553
+ buildId: "15866391498-1"
80335
80554
  };
80336
80555
  var CliDate = (/* @__PURE__ */ new Date()).toISOString();
80337
80556
  var CliId = ulid2.ulid();
@@ -86582,8 +86801,8 @@ var Bounds = class _Bounds {
86582
86801
  let minY = multipoly[0][0][0][1];
86583
86802
  let maxX = minX;
86584
86803
  let maxY = minY;
86585
- for (const [poly] of multipoly) {
86586
- for (const [x, y] of poly) {
86804
+ for (const [poly2] of multipoly) {
86805
+ for (const [x, y] of poly2) {
86587
86806
  if (x < minX)
86588
86807
  minX = x;
86589
86808
  else if (x > maxX)
@@ -86795,57 +87014,6 @@ function toFeatureMultiPolygon(coordinates, properties = {}) {
86795
87014
  };
86796
87015
  }
86797
87016
 
86798
- // ../linzjs-geojson/build/multipolygon/area.js
86799
- var Area = {
86800
- /**
86801
- * Calculate the cartesian area of a ring using the shoelace formula.
86802
- * Assumes the ring is well-formed and simple (i.e. not self-intersecting).
86803
- * @param ring The ring to calculate the area of.
86804
- * @returns The area of the ring.
86805
- */
86806
- ring(ring) {
86807
- let total = 0;
86808
- for (let i = 0; i < ring.length - 1; i++)
86809
- total += ring[i][0] * ring[i + 1][1] - ring[i][1] * ring[i + 1][0];
86810
- return total / 2;
86811
- },
86812
- /**
86813
- * Calculate the cartesian area of a polygon using the shoelace formula.
86814
- * Assumes the polygon is well-formed and simple (i.e. not self-intersecting).
86815
- *
86816
- * [GeoJSON Polygons][1] are an array of rings, where the first ring is the
86817
- * exterior, and any subsequent rings are interior rings (holes).
86818
- * The coordinates of the exterior ring are ordered counterclockwise,
86819
- * while the coordinates of interior rings are ordered clockwise.
86820
- * Area.ring() gives a negative area value for these clockwise interior rings,
86821
- * hence adding the area of all rings together gives the valid area of the
86822
- * polygon, as adding the negative area of the interior rings subtracts it
86823
- * from the positive area of the exterior ring.
86824
- *
86825
- * [1]: https://datatracker.ietf.org/doc/html/rfc7946#section-3.1.6
86826
- * @param poly The polygon to calculate the area of.
86827
- * @returns The area of the polygon.
86828
- */
86829
- polygon(poly) {
86830
- let total = 0;
86831
- for (const ring of poly)
86832
- total += Area.ring(ring);
86833
- return total;
86834
- },
86835
- /**
86836
- * Calculate the cartesian area of a multipolygon using the shoelace formula.
86837
- * Assumes the multipolygon is well-formed and simple (i.e. not self-intersecting).
86838
- * @param multipoly The polygon to calculate the area of.
86839
- * @returns The area of the polygon.
86840
- */
86841
- multiPolygon(multipoly) {
86842
- let total = 0;
86843
- for (const poly of multipoly)
86844
- total += Area.polygon(poly);
86845
- return total;
86846
- }
86847
- };
86848
-
86849
87017
  // ../linzjs-geojson/build/multipolygon/clipped.js
86850
87018
  var import_lineclip = __toESM(require_lineclip(), 1);
86851
87019
  var import_polygon_clipping = __toESM(require_polygon_clipping_cjs(), 1);
@@ -86858,8 +87026,8 @@ function removeDegenerateEdges(polygons, bbox) {
86858
87026
  }
86859
87027
  function clipMultipolygon(polygons, bbox) {
86860
87028
  const result = [];
86861
- for (const poly of polygons) {
86862
- const clipped = import_lineclip.default.polygon(poly[0], bbox);
87029
+ for (const poly2 of polygons) {
87030
+ const clipped = import_lineclip.default.polygon(poly2[0], bbox);
86863
87031
  if (clipped.length !== 0) {
86864
87032
  if (!samePoint(clipped[0], clipped[clipped.length - 1]))
86865
87033
  clipped.push(clipped[0]);
@@ -87016,10 +87184,10 @@ var Wgs84 = {
87016
87184
  */
87017
87185
  multiPolygonToBbox(multipolygon) {
87018
87186
  let ans = null;
87019
- for (const poly of multipolygon) {
87020
- if (poly.length === 0)
87187
+ for (const poly2 of multipolygon) {
87188
+ if (poly2.length === 0)
87021
87189
  continue;
87022
- const ring = poly[0];
87190
+ const ring = poly2[0];
87023
87191
  if (ring.length < 3)
87024
87192
  continue;
87025
87193
  const bbox = this.ringToBbox(ring);
@@ -87055,11 +87223,11 @@ function pointAtFrac(frac, a, b) {
87055
87223
  }
87056
87224
  function splitWgs84MultiPolygon(multipoly) {
87057
87225
  const result = [];
87058
- for (const poly of clipMultipolygon(multipoly, WorldBounds)) {
87059
- result.push(poly);
87226
+ for (const poly2 of clipMultipolygon(multipoly, WorldBounds)) {
87227
+ result.push(poly2);
87060
87228
  }
87061
- for (const poly of clipMultipolygon(multipoly, NextWorldBounds)) {
87062
- result.push(poly.map((ring) => ring.map((point) => [point[0] - 360, point[1]])));
87229
+ for (const poly2 of clipMultipolygon(multipoly, NextWorldBounds)) {
87230
+ result.push(poly2.map((ring) => ring.map((point) => [point[0] - 360, point[1]])));
87063
87231
  }
87064
87232
  return result;
87065
87233
  }
@@ -87250,7 +87418,7 @@ var Projection = class _Projection {
87250
87418
  return multipoly;
87251
87419
  const { toWgs84 } = this;
87252
87420
  const { fromWgs84 } = targetProjection;
87253
- return multipoly.map((poly) => poly.map((ring) => ring.map((p) => fromWgs84(toWgs84(p)))));
87421
+ return multipoly.map((poly2) => poly2.map((ring) => ring.map((p) => fromWgs84(toWgs84(p)))));
87254
87422
  }
87255
87423
  /**
87256
87424
  * Convert source `[x, y]` coordinates to `[lon, lat]`
@@ -87399,48 +87567,6 @@ Object.defineProperty(Projection, "AllowedFloatingError", {
87399
87567
  value: 1e-8
87400
87568
  });
87401
87569
 
87402
- // ../geo/build/proj/projection.loader.js
87403
- var ProjectionLoader = class {
87404
- /**
87405
- * Ensure that a projection EPSG code is avialable for use in Proj4js
87406
- *
87407
- * If its not already loaded, lookup definition from spatialreference.org
87408
- * @param code
87409
- */
87410
- static async load(code) {
87411
- if (Projection.tryGet(code) != null)
87412
- return Epsg.get(code);
87413
- const url = `https://spatialreference.org/ref/epsg/${code}/ogcwkt/`;
87414
- const res = await this._fetch(url);
87415
- if (!res.ok)
87416
- throw new Error("Failed to load projection information for:" + code);
87417
- let epsg = Epsg.tryGet(code);
87418
- if (epsg == null)
87419
- epsg = new Epsg(code);
87420
- const text = await res.text();
87421
- Projection.define(epsg, text);
87422
- return epsg;
87423
- }
87424
- };
87425
- Object.defineProperty(ProjectionLoader, "_fetch", {
87426
- enumerable: true,
87427
- configurable: true,
87428
- writable: true,
87429
- value: fetch
87430
- });
87431
-
87432
- // ../geo/build/proj/tile.set.name.js
87433
- var TileSetName;
87434
- (function(TileSetName2) {
87435
- TileSetName2["aerial"] = "aerial";
87436
- })(TileSetName || (TileSetName = {}));
87437
-
87438
- // ../geo/build/quad.key.js
87439
- var CHAR_0 = "0".charCodeAt(0);
87440
- var CHAR_1 = "1".charCodeAt(0);
87441
- var CHAR_2 = "2".charCodeAt(0);
87442
- var CHAR_3 = "3".charCodeAt(0);
87443
-
87444
87570
  // ../geo/build/xy.order.js
87445
87571
  function getXyOrder(epsg) {
87446
87572
  const code = typeof epsg === "number" ? epsg : epsg.code;
@@ -87726,25 +87852,25 @@ var TileMatrixSet = class {
87726
87852
  }
87727
87853
  };
87728
87854
 
87729
- // ../geo/build/tms/citm2000.js
87730
- var Citm2000Tmst = {
87855
+ // ../geo/build/tms/google.js
87856
+ var GoogleTmst = {
87731
87857
  type: "TileMatrixSetType",
87732
- title: "Debug tile matrix for EPSG:3793",
87733
- abstract: "",
87734
- identifier: "CITM2000Quad",
87735
- supportedCRS: "https://www.opengis.net/def/crs/EPSG/0/3793",
87858
+ title: "Google Maps Compatible for the World",
87859
+ identifier: "WebMercatorQuad",
87736
87860
  boundingBox: {
87737
87861
  type: "BoundingBoxType",
87738
- crs: "https://www.opengis.net/def/crs/EPSG/0/3793",
87739
- lowerCorner: [5051234111622438e-9, 3.4301543757978342e6],
87740
- upperCorner: [5207777145550478e-9, 3.5866974097258747e6]
87862
+ crs: "http://www.opengis.net/def/crs/EPSG/0/3857",
87863
+ lowerCorner: [-200375083427892e-7, -200375083427892e-7],
87864
+ upperCorner: [200375083427892e-7, 200375083427892e-7]
87741
87865
  },
87866
+ supportedCRS: "https://www.opengis.net/def/crs/EPSG/0/3857",
87867
+ wellKnownScaleSet: "https://www.opengis.net/def/wkss/OGC/1.0/GoogleMapsCompatible",
87742
87868
  tileMatrix: [
87743
87869
  {
87744
87870
  type: "TileMatrixType",
87745
87871
  identifier: "0",
87746
- scaleDenominator: 218391509386217e-8,
87747
- topLeftCorner: [5207777145550478e-9, 3.4301543757978342e6],
87872
+ scaleDenominator: 559082264028717e-6,
87873
+ topLeftCorner: [-200375083427892e-7, 200375083427892e-7],
87748
87874
  tileWidth: 256,
87749
87875
  tileHeight: 256,
87750
87876
  matrixWidth: 1,
@@ -87753,8 +87879,8 @@ var Citm2000Tmst = {
87753
87879
  {
87754
87880
  type: "TileMatrixType",
87755
87881
  identifier: "1",
87756
- scaleDenominator: 109195754693108e-8,
87757
- topLeftCorner: [5207777145550478e-9, 3.4301543757978342e6],
87882
+ scaleDenominator: 279541132014358e-6,
87883
+ topLeftCorner: [-200375083427892e-7, 200375083427892e-7],
87758
87884
  tileWidth: 256,
87759
87885
  tileHeight: 256,
87760
87886
  matrixWidth: 2,
@@ -87763,8 +87889,8 @@ var Citm2000Tmst = {
87763
87889
  {
87764
87890
  type: "TileMatrixType",
87765
87891
  identifier: "2",
87766
- scaleDenominator: 545978.773465544,
87767
- topLeftCorner: [5207777145550478e-9, 3.4301543757978342e6],
87892
+ scaleDenominator: 139770566007179e-6,
87893
+ topLeftCorner: [-200375083427892e-7, 200375083427892e-7],
87768
87894
  tileWidth: 256,
87769
87895
  tileHeight: 256,
87770
87896
  matrixWidth: 4,
@@ -87773,8 +87899,8 @@ var Citm2000Tmst = {
87773
87899
  {
87774
87900
  type: "TileMatrixType",
87775
87901
  identifier: "3",
87776
- scaleDenominator: 272989.386732772,
87777
- topLeftCorner: [5207777145550478e-9, 3.4301543757978342e6],
87902
+ scaleDenominator: 698852830035897e-7,
87903
+ topLeftCorner: [-200375083427892e-7, 200375083427892e-7],
87778
87904
  tileWidth: 256,
87779
87905
  tileHeight: 256,
87780
87906
  matrixWidth: 8,
@@ -87783,8 +87909,8 @@ var Citm2000Tmst = {
87783
87909
  {
87784
87910
  type: "TileMatrixType",
87785
87911
  identifier: "4",
87786
- scaleDenominator: 136494.693366386,
87787
- topLeftCorner: [5207777145550478e-9, 3.4301543757978342e6],
87912
+ scaleDenominator: 349426415017948e-7,
87913
+ topLeftCorner: [-200375083427892e-7, 200375083427892e-7],
87788
87914
  tileWidth: 256,
87789
87915
  tileHeight: 256,
87790
87916
  matrixWidth: 16,
@@ -87793,8 +87919,8 @@ var Citm2000Tmst = {
87793
87919
  {
87794
87920
  type: "TileMatrixType",
87795
87921
  identifier: "5",
87796
- scaleDenominator: 68247.346683193,
87797
- topLeftCorner: [5207777145550478e-9, 3.4301543757978342e6],
87922
+ scaleDenominator: 174713207508974e-7,
87923
+ topLeftCorner: [-200375083427892e-7, 200375083427892e-7],
87798
87924
  tileWidth: 256,
87799
87925
  tileHeight: 256,
87800
87926
  matrixWidth: 32,
@@ -87803,8 +87929,8 @@ var Citm2000Tmst = {
87803
87929
  {
87804
87930
  type: "TileMatrixType",
87805
87931
  identifier: "6",
87806
- scaleDenominator: 34123.6733415964,
87807
- topLeftCorner: [5207777145550478e-9, 3.4301543757978342e6],
87932
+ scaleDenominator: 873566037544871e-8,
87933
+ topLeftCorner: [-200375083427892e-7, 200375083427892e-7],
87808
87934
  tileWidth: 256,
87809
87935
  tileHeight: 256,
87810
87936
  matrixWidth: 64,
@@ -87813,8 +87939,8 @@ var Citm2000Tmst = {
87813
87939
  {
87814
87940
  type: "TileMatrixType",
87815
87941
  identifier: "7",
87816
- scaleDenominator: 17061.8366707982,
87817
- topLeftCorner: [5207777145550478e-9, 3.4301543757978342e6],
87942
+ scaleDenominator: 436783018772435e-8,
87943
+ topLeftCorner: [-200375083427892e-7, 200375083427892e-7],
87818
87944
  tileWidth: 256,
87819
87945
  tileHeight: 256,
87820
87946
  matrixWidth: 128,
@@ -87823,8 +87949,8 @@ var Citm2000Tmst = {
87823
87949
  {
87824
87950
  type: "TileMatrixType",
87825
87951
  identifier: "8",
87826
- scaleDenominator: 8530.91833539913,
87827
- topLeftCorner: [5207777145550478e-9, 3.4301543757978342e6],
87952
+ scaleDenominator: 218391509386217e-8,
87953
+ topLeftCorner: [-200375083427892e-7, 200375083427892e-7],
87828
87954
  tileWidth: 256,
87829
87955
  tileHeight: 256,
87830
87956
  matrixWidth: 256,
@@ -87833,8 +87959,8 @@ var Citm2000Tmst = {
87833
87959
  {
87834
87960
  type: "TileMatrixType",
87835
87961
  identifier: "9",
87836
- scaleDenominator: 4265.45916769956,
87837
- topLeftCorner: [5207777145550478e-9, 3.4301543757978342e6],
87962
+ scaleDenominator: 109195754693108e-8,
87963
+ topLeftCorner: [-200375083427892e-7, 200375083427892e-7],
87838
87964
  tileWidth: 256,
87839
87965
  tileHeight: 256,
87840
87966
  matrixWidth: 512,
@@ -87843,8 +87969,8 @@ var Citm2000Tmst = {
87843
87969
  {
87844
87970
  type: "TileMatrixType",
87845
87971
  identifier: "10",
87846
- scaleDenominator: 2132.72958384978,
87847
- topLeftCorner: [5207777145550478e-9, 3.4301543757978342e6],
87972
+ scaleDenominator: 545978.773465544,
87973
+ topLeftCorner: [-200375083427892e-7, 200375083427892e-7],
87848
87974
  tileWidth: 256,
87849
87975
  tileHeight: 256,
87850
87976
  matrixWidth: 1024,
@@ -87853,8 +87979,8 @@ var Citm2000Tmst = {
87853
87979
  {
87854
87980
  type: "TileMatrixType",
87855
87981
  identifier: "11",
87856
- scaleDenominator: 1066.36479192489,
87857
- topLeftCorner: [5207777145550478e-9, 3.4301543757978342e6],
87982
+ scaleDenominator: 272989.386732772,
87983
+ topLeftCorner: [-200375083427892e-7, 200375083427892e-7],
87858
87984
  tileWidth: 256,
87859
87985
  tileHeight: 256,
87860
87986
  matrixWidth: 2048,
@@ -87863,8 +87989,8 @@ var Citm2000Tmst = {
87863
87989
  {
87864
87990
  type: "TileMatrixType",
87865
87991
  identifier: "12",
87866
- scaleDenominator: 533.182395962445,
87867
- topLeftCorner: [5207777145550478e-9, 3.4301543757978342e6],
87992
+ scaleDenominator: 136494.693366386,
87993
+ topLeftCorner: [-200375083427892e-7, 200375083427892e-7],
87868
87994
  tileWidth: 256,
87869
87995
  tileHeight: 256,
87870
87996
  matrixWidth: 4096,
@@ -87873,8 +87999,8 @@ var Citm2000Tmst = {
87873
87999
  {
87874
88000
  type: "TileMatrixType",
87875
88001
  identifier: "13",
87876
- scaleDenominator: 266.591197981222,
87877
- topLeftCorner: [5207777145550478e-9, 3.4301543757978342e6],
88002
+ scaleDenominator: 68247.346683193,
88003
+ topLeftCorner: [-200375083427892e-7, 200375083427892e-7],
87878
88004
  tileWidth: 256,
87879
88005
  tileHeight: 256,
87880
88006
  matrixWidth: 8192,
@@ -87883,8 +88009,8 @@ var Citm2000Tmst = {
87883
88009
  {
87884
88010
  type: "TileMatrixType",
87885
88011
  identifier: "14",
87886
- scaleDenominator: 133.295598990611,
87887
- topLeftCorner: [5207777145550478e-9, 3.4301543757978342e6],
88012
+ scaleDenominator: 34123.6733415964,
88013
+ topLeftCorner: [-200375083427892e-7, 200375083427892e-7],
87888
88014
  tileWidth: 256,
87889
88015
  tileHeight: 256,
87890
88016
  matrixWidth: 16384,
@@ -87893,8 +88019,8 @@ var Citm2000Tmst = {
87893
88019
  {
87894
88020
  type: "TileMatrixType",
87895
88021
  identifier: "15",
87896
- scaleDenominator: 66.6477994953056,
87897
- topLeftCorner: [5207777145550478e-9, 3.4301543757978342e6],
88022
+ scaleDenominator: 17061.8366707982,
88023
+ topLeftCorner: [-200375083427892e-7, 200375083427892e-7],
87898
88024
  tileWidth: 256,
87899
88025
  tileHeight: 256,
87900
88026
  matrixWidth: 32768,
@@ -87903,294 +88029,396 @@ var Citm2000Tmst = {
87903
88029
  {
87904
88030
  type: "TileMatrixType",
87905
88031
  identifier: "16",
87906
- scaleDenominator: 33.3238997476528,
87907
- topLeftCorner: [5207777145550478e-9, 3.4301543757978342e6],
88032
+ scaleDenominator: 8530.91833539913,
88033
+ topLeftCorner: [-200375083427892e-7, 200375083427892e-7],
87908
88034
  tileWidth: 256,
87909
88035
  tileHeight: 256,
87910
88036
  matrixWidth: 65536,
87911
88037
  matrixHeight: 65536
87912
- }
87913
- ],
87914
- $generated: {
87915
- package: "@basemaps/cli",
87916
- version: "v7.14.0-4-g2766010d",
87917
- hash: "2766010d8d2bb8b673f6bcbef2fe2636f2e0f4ea",
87918
- createdAt: "2025-02-10T20:34:46.643Z"
87919
- },
87920
- $options: {
87921
- sourceTileMatrix: "WebMercatorQuad",
87922
- zoomOffset: 8
87923
- }
87924
- };
87925
- var Citm2000Tms = new TileMatrixSet(Citm2000Tmst);
87926
-
87927
- // ../geo/build/tms/google.js
87928
- var GoogleTmst = {
87929
- type: "TileMatrixSetType",
87930
- title: "Google Maps Compatible for the World",
87931
- identifier: "WebMercatorQuad",
87932
- boundingBox: {
87933
- type: "BoundingBoxType",
87934
- crs: "http://www.opengis.net/def/crs/EPSG/0/3857",
87935
- lowerCorner: [-200375083427892e-7, -200375083427892e-7],
87936
- upperCorner: [200375083427892e-7, 200375083427892e-7]
87937
- },
87938
- supportedCRS: "https://www.opengis.net/def/crs/EPSG/0/3857",
87939
- wellKnownScaleSet: "https://www.opengis.net/def/wkss/OGC/1.0/GoogleMapsCompatible",
87940
- tileMatrix: [
88038
+ },
87941
88039
  {
87942
88040
  type: "TileMatrixType",
87943
- identifier: "0",
87944
- scaleDenominator: 559082264028717e-6,
88041
+ identifier: "17",
88042
+ scaleDenominator: 4265.45916769956,
87945
88043
  topLeftCorner: [-200375083427892e-7, 200375083427892e-7],
87946
88044
  tileWidth: 256,
87947
88045
  tileHeight: 256,
87948
- matrixWidth: 1,
87949
- matrixHeight: 1
88046
+ matrixWidth: 131072,
88047
+ matrixHeight: 131072
87950
88048
  },
87951
88049
  {
87952
88050
  type: "TileMatrixType",
87953
- identifier: "1",
87954
- scaleDenominator: 279541132014358e-6,
88051
+ identifier: "18",
88052
+ scaleDenominator: 2132.72958384978,
87955
88053
  topLeftCorner: [-200375083427892e-7, 200375083427892e-7],
87956
88054
  tileWidth: 256,
87957
88055
  tileHeight: 256,
87958
- matrixWidth: 2,
87959
- matrixHeight: 2
88056
+ matrixWidth: 262144,
88057
+ matrixHeight: 262144
87960
88058
  },
87961
88059
  {
87962
88060
  type: "TileMatrixType",
87963
- identifier: "2",
87964
- scaleDenominator: 139770566007179e-6,
88061
+ identifier: "19",
88062
+ scaleDenominator: 1066.36479192489,
87965
88063
  topLeftCorner: [-200375083427892e-7, 200375083427892e-7],
87966
88064
  tileWidth: 256,
87967
88065
  tileHeight: 256,
87968
- matrixWidth: 4,
87969
- matrixHeight: 4
88066
+ matrixWidth: 524288,
88067
+ matrixHeight: 524288
87970
88068
  },
87971
88069
  {
87972
88070
  type: "TileMatrixType",
87973
- identifier: "3",
87974
- scaleDenominator: 698852830035897e-7,
88071
+ identifier: "20",
88072
+ scaleDenominator: 533.182395962445,
87975
88073
  topLeftCorner: [-200375083427892e-7, 200375083427892e-7],
87976
88074
  tileWidth: 256,
87977
88075
  tileHeight: 256,
87978
- matrixWidth: 8,
87979
- matrixHeight: 8
88076
+ matrixWidth: 1048576,
88077
+ matrixHeight: 1048576
87980
88078
  },
87981
88079
  {
87982
88080
  type: "TileMatrixType",
87983
- identifier: "4",
87984
- scaleDenominator: 349426415017948e-7,
88081
+ identifier: "21",
88082
+ scaleDenominator: 266.591197981222,
87985
88083
  topLeftCorner: [-200375083427892e-7, 200375083427892e-7],
87986
88084
  tileWidth: 256,
87987
88085
  tileHeight: 256,
87988
- matrixWidth: 16,
87989
- matrixHeight: 16
88086
+ matrixWidth: 2097152,
88087
+ matrixHeight: 2097152
87990
88088
  },
87991
88089
  {
87992
88090
  type: "TileMatrixType",
87993
- identifier: "5",
87994
- scaleDenominator: 174713207508974e-7,
88091
+ identifier: "22",
88092
+ scaleDenominator: 133.295598990611,
87995
88093
  topLeftCorner: [-200375083427892e-7, 200375083427892e-7],
87996
88094
  tileWidth: 256,
87997
88095
  tileHeight: 256,
87998
- matrixWidth: 32,
87999
- matrixHeight: 32
88096
+ matrixWidth: 4194304,
88097
+ matrixHeight: 4194304
88000
88098
  },
88001
88099
  {
88002
88100
  type: "TileMatrixType",
88003
- identifier: "6",
88004
- scaleDenominator: 873566037544871e-8,
88101
+ identifier: "23",
88102
+ scaleDenominator: 66.6477994953056,
88005
88103
  topLeftCorner: [-200375083427892e-7, 200375083427892e-7],
88006
88104
  tileWidth: 256,
88007
88105
  tileHeight: 256,
88008
- matrixWidth: 64,
88009
- matrixHeight: 64
88106
+ matrixWidth: 8388608,
88107
+ matrixHeight: 8388608
88010
88108
  },
88011
88109
  {
88012
88110
  type: "TileMatrixType",
88013
- identifier: "7",
88014
- scaleDenominator: 436783018772435e-8,
88111
+ identifier: "24",
88112
+ scaleDenominator: 33.3238997476528,
88015
88113
  topLeftCorner: [-200375083427892e-7, 200375083427892e-7],
88016
88114
  tileWidth: 256,
88017
88115
  tileHeight: 256,
88018
- matrixWidth: 128,
88019
- matrixHeight: 128
88020
- },
88116
+ matrixWidth: 16777216,
88117
+ matrixHeight: 16777216
88118
+ }
88119
+ ]
88120
+ };
88121
+ var GoogleTms = new TileMatrixSet(GoogleTmst);
88122
+
88123
+ // ../geo/build/location.transform.js
88124
+ function isGoogle(tms) {
88125
+ return tms.identifier === GoogleTms.identifier;
88126
+ }
88127
+ function locationTransform(location, tileMatrix, targetTileMatrix) {
88128
+ if (tileMatrix.identifier === targetTileMatrix.identifier)
88129
+ return location;
88130
+ if (!isGoogle(tileMatrix) && !isGoogle(targetTileMatrix)) {
88131
+ throw new Error("Either tileMatrix or targetTileMatrix must be GoogleTms");
88132
+ }
88133
+ const coords = Projection.get(tileMatrix).fromWgs84([location.lon, location.lat]);
88134
+ const point = tileMatrix.sourceToPixels(coords[0], coords[1], Math.round(location.zoom));
88135
+ const tile = { x: point.x / tileMatrix.tileSize, y: point.y / tileMatrix.tileSize, z: Math.round(location.zoom) };
88136
+ const source = targetTileMatrix.tileToSource(tile);
88137
+ const lonLat = Projection.get(targetTileMatrix).toWgs84([source.x, source.y]);
88138
+ return { lon: Math.round(lonLat[0] * 1e8) / 1e8, lat: Math.round(lonLat[1] * 1e8) / 1e8, zoom: location.zoom };
88139
+ }
88140
+ function projectFeature(f, targetTileMatrix) {
88141
+ if (f.geometry.type === "Polygon") {
88142
+ for (const poly2 of f.geometry.coordinates) {
88143
+ for (const coord of poly2) {
88144
+ const output = locationTransform({ lat: coord[1], lon: coord[0], zoom: targetTileMatrix.maxZoom }, targetTileMatrix, GoogleTms);
88145
+ coord[0] = output.lon;
88146
+ coord[1] = output.lat;
88147
+ }
88148
+ }
88149
+ } else if (f.geometry.type === "MultiPolygon") {
88150
+ for (const multiPoly of f.geometry.coordinates) {
88151
+ for (const poly2 of multiPoly) {
88152
+ for (const coord of poly2) {
88153
+ const output = locationTransform({ lat: coord[1], lon: coord[0], zoom: targetTileMatrix.maxZoom }, targetTileMatrix, GoogleTms);
88154
+ coord[0] = output.lon;
88155
+ coord[1] = output.lat;
88156
+ }
88157
+ }
88158
+ }
88159
+ } else if (f.geometry.type === "Point") {
88160
+ const coord = f.geometry.coordinates;
88161
+ const output = locationTransform({ lat: coord[1], lon: coord[0], zoom: targetTileMatrix.maxZoom }, targetTileMatrix, GoogleTms);
88162
+ coord[0] = output.lon;
88163
+ coord[1] = output.lat;
88164
+ } else if (f.geometry.type === "MultiLineString") {
88165
+ for (const line of f.geometry.coordinates) {
88166
+ for (const coord of line) {
88167
+ const output = locationTransform({ lat: coord[1], lon: coord[0], zoom: targetTileMatrix.maxZoom }, targetTileMatrix, GoogleTms);
88168
+ coord[0] = output.lon;
88169
+ coord[1] = output.lat;
88170
+ }
88171
+ }
88172
+ } else if (f.geometry.type === "LineString") {
88173
+ for (const coord of f.geometry.coordinates) {
88174
+ const output = locationTransform({ lat: coord[1], lon: coord[0], zoom: targetTileMatrix.maxZoom }, targetTileMatrix, GoogleTms);
88175
+ coord[0] = output.lon;
88176
+ coord[1] = output.lat;
88177
+ }
88178
+ } else {
88179
+ throw new Error(`Geometry feature type: ${f.geometry.type} not supported`);
88180
+ }
88181
+ }
88182
+
88183
+ // ../geo/build/proj/projection.loader.js
88184
+ var ProjectionLoader = class {
88185
+ /**
88186
+ * Ensure that a projection EPSG code is avialable for use in Proj4js
88187
+ *
88188
+ * If its not already loaded, lookup definition from spatialreference.org
88189
+ * @param code
88190
+ */
88191
+ static async load(code) {
88192
+ if (Projection.tryGet(code) != null)
88193
+ return Epsg.get(code);
88194
+ const url = `https://spatialreference.org/ref/epsg/${code}/ogcwkt/`;
88195
+ const res = await this._fetch(url);
88196
+ if (!res.ok)
88197
+ throw new Error("Failed to load projection information for:" + code);
88198
+ let epsg = Epsg.tryGet(code);
88199
+ if (epsg == null)
88200
+ epsg = new Epsg(code);
88201
+ const text = await res.text();
88202
+ Projection.define(epsg, text);
88203
+ return epsg;
88204
+ }
88205
+ };
88206
+ Object.defineProperty(ProjectionLoader, "_fetch", {
88207
+ enumerable: true,
88208
+ configurable: true,
88209
+ writable: true,
88210
+ value: fetch
88211
+ });
88212
+
88213
+ // ../geo/build/proj/tile.set.name.js
88214
+ var TileSetName;
88215
+ (function(TileSetName2) {
88216
+ TileSetName2["aerial"] = "aerial";
88217
+ })(TileSetName || (TileSetName = {}));
88218
+
88219
+ // ../geo/build/quad.key.js
88220
+ var CHAR_0 = "0".charCodeAt(0);
88221
+ var CHAR_1 = "1".charCodeAt(0);
88222
+ var CHAR_2 = "2".charCodeAt(0);
88223
+ var CHAR_3 = "3".charCodeAt(0);
88224
+
88225
+ // ../geo/build/tms/citm2000.js
88226
+ var Citm2000Tmst = {
88227
+ type: "TileMatrixSetType",
88228
+ title: "Debug tile matrix for EPSG:3793",
88229
+ abstract: "",
88230
+ identifier: "CITM2000Quad",
88231
+ supportedCRS: "https://www.opengis.net/def/crs/EPSG/0/3793",
88232
+ boundingBox: {
88233
+ type: "BoundingBoxType",
88234
+ crs: "https://www.opengis.net/def/crs/EPSG/0/3793",
88235
+ lowerCorner: [5051234111622438e-9, 3.4301543757978342e6],
88236
+ upperCorner: [5207777145550478e-9, 3.5866974097258747e6]
88237
+ },
88238
+ tileMatrix: [
88021
88239
  {
88022
88240
  type: "TileMatrixType",
88023
- identifier: "8",
88241
+ identifier: "0",
88024
88242
  scaleDenominator: 218391509386217e-8,
88025
- topLeftCorner: [-200375083427892e-7, 200375083427892e-7],
88243
+ topLeftCorner: [5207777145550478e-9, 3.4301543757978342e6],
88026
88244
  tileWidth: 256,
88027
88245
  tileHeight: 256,
88028
- matrixWidth: 256,
88029
- matrixHeight: 256
88246
+ matrixWidth: 1,
88247
+ matrixHeight: 1
88030
88248
  },
88031
88249
  {
88032
88250
  type: "TileMatrixType",
88033
- identifier: "9",
88251
+ identifier: "1",
88034
88252
  scaleDenominator: 109195754693108e-8,
88035
- topLeftCorner: [-200375083427892e-7, 200375083427892e-7],
88253
+ topLeftCorner: [5207777145550478e-9, 3.4301543757978342e6],
88036
88254
  tileWidth: 256,
88037
88255
  tileHeight: 256,
88038
- matrixWidth: 512,
88039
- matrixHeight: 512
88256
+ matrixWidth: 2,
88257
+ matrixHeight: 2
88040
88258
  },
88041
88259
  {
88042
88260
  type: "TileMatrixType",
88043
- identifier: "10",
88261
+ identifier: "2",
88044
88262
  scaleDenominator: 545978.773465544,
88045
- topLeftCorner: [-200375083427892e-7, 200375083427892e-7],
88263
+ topLeftCorner: [5207777145550478e-9, 3.4301543757978342e6],
88046
88264
  tileWidth: 256,
88047
88265
  tileHeight: 256,
88048
- matrixWidth: 1024,
88049
- matrixHeight: 1024
88266
+ matrixWidth: 4,
88267
+ matrixHeight: 4
88050
88268
  },
88051
88269
  {
88052
88270
  type: "TileMatrixType",
88053
- identifier: "11",
88271
+ identifier: "3",
88054
88272
  scaleDenominator: 272989.386732772,
88055
- topLeftCorner: [-200375083427892e-7, 200375083427892e-7],
88273
+ topLeftCorner: [5207777145550478e-9, 3.4301543757978342e6],
88056
88274
  tileWidth: 256,
88057
88275
  tileHeight: 256,
88058
- matrixWidth: 2048,
88059
- matrixHeight: 2048
88276
+ matrixWidth: 8,
88277
+ matrixHeight: 8
88060
88278
  },
88061
88279
  {
88062
88280
  type: "TileMatrixType",
88063
- identifier: "12",
88281
+ identifier: "4",
88064
88282
  scaleDenominator: 136494.693366386,
88065
- topLeftCorner: [-200375083427892e-7, 200375083427892e-7],
88283
+ topLeftCorner: [5207777145550478e-9, 3.4301543757978342e6],
88066
88284
  tileWidth: 256,
88067
88285
  tileHeight: 256,
88068
- matrixWidth: 4096,
88069
- matrixHeight: 4096
88286
+ matrixWidth: 16,
88287
+ matrixHeight: 16
88070
88288
  },
88071
88289
  {
88072
88290
  type: "TileMatrixType",
88073
- identifier: "13",
88291
+ identifier: "5",
88074
88292
  scaleDenominator: 68247.346683193,
88075
- topLeftCorner: [-200375083427892e-7, 200375083427892e-7],
88293
+ topLeftCorner: [5207777145550478e-9, 3.4301543757978342e6],
88076
88294
  tileWidth: 256,
88077
88295
  tileHeight: 256,
88078
- matrixWidth: 8192,
88079
- matrixHeight: 8192
88296
+ matrixWidth: 32,
88297
+ matrixHeight: 32
88080
88298
  },
88081
88299
  {
88082
88300
  type: "TileMatrixType",
88083
- identifier: "14",
88301
+ identifier: "6",
88084
88302
  scaleDenominator: 34123.6733415964,
88085
- topLeftCorner: [-200375083427892e-7, 200375083427892e-7],
88303
+ topLeftCorner: [5207777145550478e-9, 3.4301543757978342e6],
88086
88304
  tileWidth: 256,
88087
88305
  tileHeight: 256,
88088
- matrixWidth: 16384,
88089
- matrixHeight: 16384
88306
+ matrixWidth: 64,
88307
+ matrixHeight: 64
88090
88308
  },
88091
88309
  {
88092
88310
  type: "TileMatrixType",
88093
- identifier: "15",
88311
+ identifier: "7",
88094
88312
  scaleDenominator: 17061.8366707982,
88095
- topLeftCorner: [-200375083427892e-7, 200375083427892e-7],
88313
+ topLeftCorner: [5207777145550478e-9, 3.4301543757978342e6],
88096
88314
  tileWidth: 256,
88097
88315
  tileHeight: 256,
88098
- matrixWidth: 32768,
88099
- matrixHeight: 32768
88316
+ matrixWidth: 128,
88317
+ matrixHeight: 128
88100
88318
  },
88101
88319
  {
88102
88320
  type: "TileMatrixType",
88103
- identifier: "16",
88321
+ identifier: "8",
88104
88322
  scaleDenominator: 8530.91833539913,
88105
- topLeftCorner: [-200375083427892e-7, 200375083427892e-7],
88323
+ topLeftCorner: [5207777145550478e-9, 3.4301543757978342e6],
88106
88324
  tileWidth: 256,
88107
88325
  tileHeight: 256,
88108
- matrixWidth: 65536,
88109
- matrixHeight: 65536
88326
+ matrixWidth: 256,
88327
+ matrixHeight: 256
88110
88328
  },
88111
88329
  {
88112
88330
  type: "TileMatrixType",
88113
- identifier: "17",
88331
+ identifier: "9",
88114
88332
  scaleDenominator: 4265.45916769956,
88115
- topLeftCorner: [-200375083427892e-7, 200375083427892e-7],
88333
+ topLeftCorner: [5207777145550478e-9, 3.4301543757978342e6],
88116
88334
  tileWidth: 256,
88117
88335
  tileHeight: 256,
88118
- matrixWidth: 131072,
88119
- matrixHeight: 131072
88336
+ matrixWidth: 512,
88337
+ matrixHeight: 512
88120
88338
  },
88121
88339
  {
88122
88340
  type: "TileMatrixType",
88123
- identifier: "18",
88341
+ identifier: "10",
88124
88342
  scaleDenominator: 2132.72958384978,
88125
- topLeftCorner: [-200375083427892e-7, 200375083427892e-7],
88343
+ topLeftCorner: [5207777145550478e-9, 3.4301543757978342e6],
88126
88344
  tileWidth: 256,
88127
88345
  tileHeight: 256,
88128
- matrixWidth: 262144,
88129
- matrixHeight: 262144
88346
+ matrixWidth: 1024,
88347
+ matrixHeight: 1024
88130
88348
  },
88131
88349
  {
88132
88350
  type: "TileMatrixType",
88133
- identifier: "19",
88351
+ identifier: "11",
88134
88352
  scaleDenominator: 1066.36479192489,
88135
- topLeftCorner: [-200375083427892e-7, 200375083427892e-7],
88353
+ topLeftCorner: [5207777145550478e-9, 3.4301543757978342e6],
88136
88354
  tileWidth: 256,
88137
88355
  tileHeight: 256,
88138
- matrixWidth: 524288,
88139
- matrixHeight: 524288
88356
+ matrixWidth: 2048,
88357
+ matrixHeight: 2048
88140
88358
  },
88141
88359
  {
88142
88360
  type: "TileMatrixType",
88143
- identifier: "20",
88361
+ identifier: "12",
88144
88362
  scaleDenominator: 533.182395962445,
88145
- topLeftCorner: [-200375083427892e-7, 200375083427892e-7],
88363
+ topLeftCorner: [5207777145550478e-9, 3.4301543757978342e6],
88146
88364
  tileWidth: 256,
88147
88365
  tileHeight: 256,
88148
- matrixWidth: 1048576,
88149
- matrixHeight: 1048576
88366
+ matrixWidth: 4096,
88367
+ matrixHeight: 4096
88150
88368
  },
88151
88369
  {
88152
88370
  type: "TileMatrixType",
88153
- identifier: "21",
88371
+ identifier: "13",
88154
88372
  scaleDenominator: 266.591197981222,
88155
- topLeftCorner: [-200375083427892e-7, 200375083427892e-7],
88373
+ topLeftCorner: [5207777145550478e-9, 3.4301543757978342e6],
88156
88374
  tileWidth: 256,
88157
88375
  tileHeight: 256,
88158
- matrixWidth: 2097152,
88159
- matrixHeight: 2097152
88376
+ matrixWidth: 8192,
88377
+ matrixHeight: 8192
88160
88378
  },
88161
88379
  {
88162
88380
  type: "TileMatrixType",
88163
- identifier: "22",
88381
+ identifier: "14",
88164
88382
  scaleDenominator: 133.295598990611,
88165
- topLeftCorner: [-200375083427892e-7, 200375083427892e-7],
88383
+ topLeftCorner: [5207777145550478e-9, 3.4301543757978342e6],
88166
88384
  tileWidth: 256,
88167
88385
  tileHeight: 256,
88168
- matrixWidth: 4194304,
88169
- matrixHeight: 4194304
88386
+ matrixWidth: 16384,
88387
+ matrixHeight: 16384
88170
88388
  },
88171
88389
  {
88172
88390
  type: "TileMatrixType",
88173
- identifier: "23",
88391
+ identifier: "15",
88174
88392
  scaleDenominator: 66.6477994953056,
88175
- topLeftCorner: [-200375083427892e-7, 200375083427892e-7],
88393
+ topLeftCorner: [5207777145550478e-9, 3.4301543757978342e6],
88176
88394
  tileWidth: 256,
88177
88395
  tileHeight: 256,
88178
- matrixWidth: 8388608,
88179
- matrixHeight: 8388608
88396
+ matrixWidth: 32768,
88397
+ matrixHeight: 32768
88180
88398
  },
88181
88399
  {
88182
88400
  type: "TileMatrixType",
88183
- identifier: "24",
88401
+ identifier: "16",
88184
88402
  scaleDenominator: 33.3238997476528,
88185
- topLeftCorner: [-200375083427892e-7, 200375083427892e-7],
88403
+ topLeftCorner: [5207777145550478e-9, 3.4301543757978342e6],
88186
88404
  tileWidth: 256,
88187
88405
  tileHeight: 256,
88188
- matrixWidth: 16777216,
88189
- matrixHeight: 16777216
88406
+ matrixWidth: 65536,
88407
+ matrixHeight: 65536
88190
88408
  }
88191
- ]
88409
+ ],
88410
+ $generated: {
88411
+ package: "@basemaps/cli",
88412
+ version: "v7.14.0-4-g2766010d",
88413
+ hash: "2766010d8d2bb8b673f6bcbef2fe2636f2e0f4ea",
88414
+ createdAt: "2025-02-10T20:34:46.643Z"
88415
+ },
88416
+ $options: {
88417
+ sourceTileMatrix: "WebMercatorQuad",
88418
+ zoomOffset: 8
88419
+ }
88192
88420
  };
88193
- var GoogleTms = new TileMatrixSet(GoogleTmst);
88421
+ var Citm2000Tms = new TileMatrixSet(Citm2000Tmst);
88194
88422
 
88195
88423
  // ../geo/build/tms/nztm2000.js
88196
88424
  var Nztm20002 = __toESM(require_src3(), 1);
@@ -90402,7 +90630,8 @@ var zLayer = z.object({
90402
90630
  attributes: zAttributes.optional(),
90403
90631
  style: zStyling,
90404
90632
  simplify: z.array(zSimplify).optional(),
90405
- tippecanoe: z.array(z.string()).optional()
90633
+ tippecanoe: z.array(z.string()).optional(),
90634
+ includeDerivedArea: z.boolean().optional()
90406
90635
  });
90407
90636
  var zSchema = z.object({
90408
90637
  name: z.string(),
@@ -90416,13 +90645,15 @@ var zSchema = z.object({
90416
90645
  // src/schema-loader/schema.loader.ts
90417
90646
  var LARGE_LAYER_SIZE = 1024 * 1024 * 1024;
90418
90647
  var SchemaLoader = class {
90419
- constructor(path4, logger, cache) {
90648
+ constructor(path4, tileMatrix, logger, cache) {
90420
90649
  __publicField(this, "path");
90421
90650
  __publicField(this, "logger");
90422
90651
  __publicField(this, "schemas", []);
90652
+ __publicField(this, "tileMatrix");
90423
90653
  __publicField(this, "cache");
90424
90654
  this.path = path4;
90425
90655
  this.logger = logger;
90656
+ this.tileMatrix = tileMatrix;
90426
90657
  this.cache = cache;
90427
90658
  }
90428
90659
  /**
@@ -90476,7 +90707,7 @@ var SchemaLoader = class {
90476
90707
  const configHash = sha256base58(JSON.stringify({ name: schema.name, layer, version: CliInfo.version }));
90477
90708
  if (this.cache != null) {
90478
90709
  const fileName = isLdsFile ? `${layer.id}_${layer.version}_${configHash}.mbtiles` : `${layer.id}_${configHash}.mbtiles`;
90479
- const path4 = new URL(`${layer.id}/${fileName}`, this.cache);
90710
+ const path4 = new URL(`${this.tileMatrix.projection.code}/${layer.id}/${fileName}`, this.cache);
90480
90711
  const exists = await Fsa.exists(path4);
90481
90712
  const cache = {
90482
90713
  fileName,
@@ -90547,7 +90778,7 @@ var VectorStac = class {
90547
90778
  stac_version: "1.0.0",
90548
90779
  stac_extensions: [],
90549
90780
  geometry: null,
90550
- bbox: [-180, -90, 180, 90],
90781
+ bbox: tileMatrix.extent.toBbox(),
90551
90782
  links: [
90552
90783
  { href: `./${filename}.json`, rel: "self" },
90553
90784
  { href: "./collection.json", rel: "collection" },
@@ -90555,6 +90786,7 @@ var VectorStac = class {
90555
90786
  ...layers
90556
90787
  ],
90557
90788
  properties: {
90789
+ datetime: CliDate,
90558
90790
  "proj:epsg": tileMatrix.projection.code,
90559
90791
  "linz_basemaps:generated": {
90560
90792
  package: CliInfo.package,
@@ -90637,7 +90869,7 @@ async function createStacFiles(filePaths, targetPath, filename, tileMatrix, titl
90637
90869
  };
90638
90870
  const stacCollection = vectorStac.createStacCollection(unionBbox, layers, filename, title);
90639
90871
  let stacCatalog = vectorStac.createStacCatalog();
90640
- const catalogPath = new URL("catalog.json", targetPath);
90872
+ const catalogPath = new URL("topographic/catalog.json", targetPath);
90641
90873
  if (await Fsa.exists(catalogPath))
90642
90874
  stacCatalog = await Fsa.readJson(catalogPath);
90643
90875
  stacCatalog.links.push({
@@ -90697,7 +90929,7 @@ var ExtractCommand = (0, import_cmd_ts2.command)({
90697
90929
  if (tileMatrix == null)
90698
90930
  throw new Error(`Tile matrix ${args.tileMatrix} is not supported`);
90699
90931
  logger.info({ schema: args.schema }, "Extract: Start");
90700
- const schemaLoader = new SchemaLoader(args.schema, logger, cache);
90932
+ const schemaLoader = new SchemaLoader(args.schema, tileMatrix, logger, cache);
90701
90933
  const schemas = await schemaLoader.load();
90702
90934
  const smallLayers = [];
90703
90935
  const largeLayers = [];
@@ -90949,99 +91181,79 @@ function handleKindPeak(feature, logger) {
90949
91181
  }
90950
91182
 
90951
91183
  // src/modify/parser.ts
91184
+ var optionalString = z.preprocess((value) => {
91185
+ if (value === "0" || value === null) {
91186
+ return void 0;
91187
+ } else {
91188
+ return value;
91189
+ }
91190
+ }, z.string().optional());
90952
91191
  var zPlaceLabelsProperties = z.object({
90953
91192
  /** @example "Kaitaia" */
90954
91193
  label: z.string(),
91194
+ /** @example 8 */
91195
+ zoom_level: z.number(),
90955
91196
  /** @example "TWN1" */
90956
91197
  style: z.string(),
91198
+ /** @example "cape" */
91199
+ natural: optionalString,
90957
91200
  /** @example "city" */
90958
- place: z.string(),
90959
- /** @example 7 */
90960
- adminlevel: z.number(),
90961
- /** @example "0" */
90962
- natural: z.string(),
90963
- /** @example "0" */
90964
- water: z.string()
90965
- });
90966
- var zPlaceLabelsTippecanoe = z.object({
90967
- /** @example "place_labels" */
90968
- layer: z.string(),
90969
- /** @example 8 */
90970
- minzoom: z.number(),
90971
- /** @example 8 */
90972
- maxzoom: z.number()
91201
+ place: optionalString,
91202
+ /** @example "bay" */
91203
+ water: optionalString
90973
91204
  });
90974
91205
 
90975
91206
  // src/modify/layers/place_labels.ts
90976
91207
  var PlaceLabelsFeatures = /* @__PURE__ */ new Map();
90977
91208
  function handleLayerPlaceLabels(feature, logger) {
90978
91209
  logger.trace({}, "HandlePlaceLabels:Start");
90979
- feature = structuredClone(feature);
90980
- const label = feature.properties["label"];
90981
- if (typeof label !== "string")
90982
- throw new Error("Label property is not a string");
90983
- const zoomLevel = feature.properties["zoom_level"];
90984
- if (typeof zoomLevel !== "number")
90985
- throw new Error("Zoom level is not a number");
90986
- const storedFeature = PlaceLabelsFeatures.get(label);
91210
+ const newFeature = createNewFeature(feature, logger);
91211
+ const name = newFeature.properties.name;
91212
+ const storedFeature = PlaceLabelsFeatures.get(name);
90987
91213
  if (storedFeature == null) {
90988
- const newFeature = createNewFeature(feature, label, zoomLevel, logger);
90989
- if (newFeature == null)
90990
- return null;
90991
- PlaceLabelsFeatures.set(label, newFeature);
91214
+ PlaceLabelsFeatures.set(name, newFeature);
90992
91215
  logger.trace({}, "HandlePlaceLabels:End");
90993
91216
  return newFeature;
90994
91217
  }
90995
- if (zoomLevel < storedFeature.tippecanoe.minzoom) {
90996
- storedFeature.tippecanoe.minzoom = zoomLevel;
90997
- PlaceLabelsFeatures.set(label, storedFeature);
90998
- }
90999
- if (zoomLevel > storedFeature.tippecanoe.maxzoom) {
91000
- storedFeature.tippecanoe.maxzoom = zoomLevel;
91001
- PlaceLabelsFeatures.set(label, storedFeature);
91002
- }
91218
+ storedFeature.tippecanoe.minzoom = newFeature.tippecanoe.minzoom;
91219
+ storedFeature.tippecanoe.maxzoom = newFeature.tippecanoe.minzoom;
91003
91220
  logger.trace({}, "HandlePlaceLabels:End");
91004
- return storedFeature;
91221
+ return structuredClone(storedFeature);
91005
91222
  }
91006
- function createNewFeature(feature, label, zoomLevel, logger) {
91007
- let properties;
91008
- let tippecanoe2;
91223
+ function createNewFeature(feature, logger) {
91009
91224
  try {
91010
- properties = zPlaceLabelsProperties.parse({
91011
- label,
91225
+ const properties = zPlaceLabelsProperties.parse({
91226
+ label: feature.properties["label"],
91227
+ zoom_level: feature.properties["zoom_level"],
91012
91228
  style: feature.properties["style"],
91013
- place: feature.properties["place"],
91014
- adminlevel: feature.properties["adminlevel"],
91015
91229
  natural: feature.properties["natural"],
91230
+ place: feature.properties["place"],
91016
91231
  water: feature.properties["water"]
91017
91232
  });
91018
- tippecanoe2 = zPlaceLabelsTippecanoe.parse({
91233
+ const tippecanoe2 = {
91019
91234
  layer: "place_labels",
91020
- minzoom: zoomLevel,
91021
- maxzoom: zoomLevel
91022
- });
91235
+ minzoom: properties.zoom_level,
91236
+ maxzoom: properties.zoom_level
91237
+ };
91238
+ const newFeature = {
91239
+ type: feature.type,
91240
+ properties: {
91241
+ name: properties.label,
91242
+ kind: convertStyleToKind(properties.style, tippecanoe2.minzoom),
91243
+ natural: properties.natural,
91244
+ place: properties.place,
91245
+ water: properties.water
91246
+ },
91247
+ geometry: feature.geometry,
91248
+ tippecanoe: tippecanoe2
91249
+ };
91250
+ return newFeature;
91023
91251
  } catch (e) {
91024
91252
  if (e instanceof z.ZodError) {
91025
- logger.trace({ label }, "Failed to parse expected properties. Discarding feature.");
91026
- return null;
91027
- } else {
91028
- throw new Error("An unexpected error occurred.");
91029
- }
91030
- }
91031
- const newFeature = {
91032
- type: feature.type,
91033
- properties: {
91034
- name: properties.label,
91035
- kind: convertStyleToKind(properties.style, tippecanoe2.minzoom),
91036
- place: properties.place,
91037
- adminlevel: properties.adminlevel,
91038
- natural: properties.natural,
91039
- water: properties.water
91040
- },
91041
- geometry: feature.geometry,
91042
- tippecanoe: tippecanoe2
91043
- };
91044
- return newFeature;
91253
+ logger.trace({ properties: feature.properties }, "Failed to parse required properties.");
91254
+ }
91255
+ throw e;
91256
+ }
91045
91257
  }
91046
91258
  function convertStyleToKind(style, minzoom) {
91047
91259
  if (style.startsWith("ANT"))
@@ -91061,240 +91273,8 @@ function convertStyleToKind(style, minzoom) {
91061
91273
  return "";
91062
91274
  }
91063
91275
 
91064
- // src/modify/layers/pois.ts
91065
- function handleLayerPois(feature, logger) {
91066
- logger.trace({}, "HandlePois:Start");
91067
- feature = structuredClone(feature);
91068
- if (feature.properties["building"] === "building") {
91069
- const bldgUse = feature.properties["bldg_use"];
91070
- if (bldgUse == null) {
91071
- logger.trace({}, "HandlePois:End");
91072
- return null;
91073
- }
91074
- feature.properties["building"] = bldgUse;
91075
- }
91076
- logger.trace({}, "HandlePois:End");
91077
- return feature;
91078
- }
91079
-
91080
- // ../../node_modules/tinyqueue/index.js
91081
- var TinyQueue = class {
91082
- constructor(data = [], compare = (a, b) => a < b ? -1 : a > b ? 1 : 0) {
91083
- this.data = data;
91084
- this.length = this.data.length;
91085
- this.compare = compare;
91086
- if (this.length > 0) {
91087
- for (let i = (this.length >> 1) - 1; i >= 0; i--)
91088
- this._down(i);
91089
- }
91090
- }
91091
- push(item) {
91092
- this.data.push(item);
91093
- this._up(this.length++);
91094
- }
91095
- pop() {
91096
- if (this.length === 0)
91097
- return void 0;
91098
- const top = this.data[0];
91099
- const bottom = this.data.pop();
91100
- if (--this.length > 0) {
91101
- this.data[0] = bottom;
91102
- this._down(0);
91103
- }
91104
- return top;
91105
- }
91106
- peek() {
91107
- return this.data[0];
91108
- }
91109
- _up(pos) {
91110
- const { data, compare } = this;
91111
- const item = data[pos];
91112
- while (pos > 0) {
91113
- const parent = pos - 1 >> 1;
91114
- const current = data[parent];
91115
- if (compare(item, current) >= 0)
91116
- break;
91117
- data[pos] = current;
91118
- pos = parent;
91119
- }
91120
- data[pos] = item;
91121
- }
91122
- _down(pos) {
91123
- const { data, compare } = this;
91124
- const halfLength = this.length >> 1;
91125
- const item = data[pos];
91126
- while (pos < halfLength) {
91127
- let bestChild = (pos << 1) + 1;
91128
- const right = bestChild + 1;
91129
- if (right < this.length && compare(data[right], data[bestChild]) < 0) {
91130
- bestChild = right;
91131
- }
91132
- if (compare(data[bestChild], item) >= 0)
91133
- break;
91134
- data[pos] = data[bestChild];
91135
- pos = bestChild;
91136
- }
91137
- data[pos] = item;
91138
- }
91139
- };
91140
-
91141
- // ../../node_modules/polylabel/polylabel.js
91142
- function polylabel(polygon, precision = 1, debug = false) {
91143
- let minX = Infinity;
91144
- let minY = Infinity;
91145
- let maxX = -Infinity;
91146
- let maxY = -Infinity;
91147
- for (const [x, y] of polygon[0]) {
91148
- if (x < minX)
91149
- minX = x;
91150
- if (y < minY)
91151
- minY = y;
91152
- if (x > maxX)
91153
- maxX = x;
91154
- if (y > maxY)
91155
- maxY = y;
91156
- }
91157
- const width = maxX - minX;
91158
- const height = maxY - minY;
91159
- const cellSize = Math.max(precision, Math.min(width, height));
91160
- if (cellSize === precision) {
91161
- const result2 = [minX, minY];
91162
- result2.distance = 0;
91163
- return result2;
91164
- }
91165
- const cellQueue = new TinyQueue([], (a, b) => b.max - a.max);
91166
- let bestCell = getCentroidCell(polygon);
91167
- const bboxCell = new Cell(minX + width / 2, minY + height / 2, 0, polygon);
91168
- if (bboxCell.d > bestCell.d)
91169
- bestCell = bboxCell;
91170
- let numProbes = 2;
91171
- function potentiallyQueue(x, y, h2) {
91172
- const cell = new Cell(x, y, h2, polygon);
91173
- numProbes++;
91174
- if (cell.max > bestCell.d + precision)
91175
- cellQueue.push(cell);
91176
- if (cell.d > bestCell.d) {
91177
- bestCell = cell;
91178
- if (debug)
91179
- console.log(`found best ${Math.round(1e4 * cell.d) / 1e4} after ${numProbes} probes`);
91180
- }
91181
- }
91182
- let h = cellSize / 2;
91183
- for (let x = minX; x < maxX; x += cellSize) {
91184
- for (let y = minY; y < maxY; y += cellSize) {
91185
- potentiallyQueue(x + h, y + h, h);
91186
- }
91187
- }
91188
- while (cellQueue.length) {
91189
- const { max, x, y, h: ch } = cellQueue.pop();
91190
- if (max - bestCell.d <= precision)
91191
- break;
91192
- h = ch / 2;
91193
- potentiallyQueue(x - h, y - h, h);
91194
- potentiallyQueue(x + h, y - h, h);
91195
- potentiallyQueue(x - h, y + h, h);
91196
- potentiallyQueue(x + h, y + h, h);
91197
- }
91198
- if (debug) {
91199
- console.log(`num probes: ${numProbes}
91200
- best distance: ${bestCell.d}`);
91201
- }
91202
- const result = [bestCell.x, bestCell.y];
91203
- result.distance = bestCell.d;
91204
- return result;
91205
- }
91206
- function Cell(x, y, h, polygon) {
91207
- this.x = x;
91208
- this.y = y;
91209
- this.h = h;
91210
- this.d = pointToPolygonDist(x, y, polygon);
91211
- this.max = this.d + this.h * Math.SQRT2;
91212
- }
91213
- function pointToPolygonDist(x, y, polygon) {
91214
- let inside = false;
91215
- let minDistSq = Infinity;
91216
- for (const ring of polygon) {
91217
- for (let i = 0, len = ring.length, j = len - 1; i < len; j = i++) {
91218
- const a = ring[i];
91219
- const b = ring[j];
91220
- if (a[1] > y !== b[1] > y && x < (b[0] - a[0]) * (y - a[1]) / (b[1] - a[1]) + a[0])
91221
- inside = !inside;
91222
- minDistSq = Math.min(minDistSq, getSegDistSq(x, y, a, b));
91223
- }
91224
- }
91225
- return minDistSq === 0 ? 0 : (inside ? 1 : -1) * Math.sqrt(minDistSq);
91226
- }
91227
- function getCentroidCell(polygon) {
91228
- let area = 0;
91229
- let x = 0;
91230
- let y = 0;
91231
- const points = polygon[0];
91232
- for (let i = 0, len = points.length, j = len - 1; i < len; j = i++) {
91233
- const a = points[i];
91234
- const b = points[j];
91235
- const f = a[0] * b[1] - b[0] * a[1];
91236
- x += (a[0] + b[0]) * f;
91237
- y += (a[1] + b[1]) * f;
91238
- area += f * 3;
91239
- }
91240
- const centroid = new Cell(x / area, y / area, 0, polygon);
91241
- if (area === 0 || centroid.d < 0)
91242
- return new Cell(points[0][0], points[0][1], 0, polygon);
91243
- return centroid;
91244
- }
91245
- function getSegDistSq(px, py, a, b) {
91246
- let x = a[0];
91247
- let y = a[1];
91248
- let dx = b[0] - x;
91249
- let dy = b[1] - y;
91250
- if (dx !== 0 || dy !== 0) {
91251
- const t = ((px - x) * dx + (py - y) * dy) / (dx * dx + dy * dy);
91252
- if (t > 1) {
91253
- x = b[0];
91254
- y = b[1];
91255
- } else if (t > 0) {
91256
- x += dx * t;
91257
- y += dy * t;
91258
- }
91259
- }
91260
- dx = px - x;
91261
- dy = py - y;
91262
- return dx * dx + dy * dy;
91263
- }
91264
-
91265
- // src/modify/layers/public_transport.ts
91266
- var polylabel2 = polylabel;
91267
- function handleLayerPublicTransport(feature, options, logger) {
91268
- logger.trace({}, "HandlePublicTransport:Start");
91269
- const kind = options.layer.tags["kind"];
91270
- switch (kind) {
91271
- case "aerodrome":
91272
- feature = handleKindAerodrome(feature, logger);
91273
- break;
91274
- }
91275
- logger.trace({}, "HandlePublicTransport:End");
91276
- return feature;
91277
- }
91278
- function handleKindAerodrome(feature, logger) {
91279
- logger.trace({}, "HandleKindAerodrome:Start");
91280
- feature = structuredClone(feature);
91281
- const coordinates = getCoordinates(feature.geometry, logger);
91282
- const inaccessibilityPole = polylabel2(coordinates);
91283
- const point = { type: "Point", coordinates: inaccessibilityPole };
91284
- feature.geometry = point;
91285
- logger.trace({}, "HandleKindAerodrome:End");
91286
- return feature;
91287
- }
91288
- function getCoordinates(geometry, logger) {
91289
- switch (geometry.type) {
91290
- case "MultiPolygon":
91291
- return geometry.coordinates[0];
91292
- case "Polygon":
91293
- return geometry.coordinates;
91294
- }
91295
- logger.error({ type: geometry.type }, "Unsupported geometry type");
91296
- throw new Error("Unsupported geometry type");
91297
- }
91276
+ // src/modify/shared.ts
91277
+ var poly = __toESM(require_polylabel(), 1);
91298
91278
 
91299
91279
  // src/modify/consts.ts
91300
91280
  var MajorHighWays = /* @__PURE__ */ new Set([
@@ -91321,19 +91301,22 @@ var MajorHighWays = /* @__PURE__ */ new Set([
91321
91301
  ]);
91322
91302
 
91323
91303
  // src/modify/shared.ts
91304
+ var polylabel = poly.default;
91324
91305
  function handleRoadFeature(feature, options, logger) {
91325
91306
  logger.trace({}, "HandleRoadFeature:Start");
91326
91307
  feature = structuredClone(feature);
91327
91308
  const highwayNum = feature.properties["hway_num"];
91328
- if (typeof highwayNum === "string") {
91309
+ if (highwayNum != null && typeof highwayNum === "string") {
91329
91310
  const kind = "motorway";
91330
91311
  feature.properties["kind"] = kind;
91331
91312
  const ref = highwayNum;
91332
91313
  feature.properties["ref"] = ref;
91333
91314
  logger.trace({ kind, ref }, "new/overidden tags");
91334
- const minzoom = MajorHighWays.has(highwayNum) ? 2 : 8;
91335
- feature.tippecanoe.minzoom = minzoom;
91336
- logger.trace({ minzoom }, "overidden styles");
91315
+ if (feature.tippecanoe.minzoom < 8) {
91316
+ const minzoom = MajorHighWays.has(highwayNum) ? feature.tippecanoe.maxzoom : 8;
91317
+ feature.tippecanoe.minzoom = minzoom;
91318
+ logger.trace({ minzoom }, "overidden styles");
91319
+ }
91337
91320
  logger.trace({}, "HandleRoadFeature:End");
91338
91321
  return feature;
91339
91322
  }
@@ -91351,6 +91334,60 @@ function handleRoadFeature(feature, options, logger) {
91351
91334
  logger.trace({}, "HandleRoadFeature:End");
91352
91335
  return feature;
91353
91336
  }
91337
+ function getInaccessibilityPole(geometry, logger) {
91338
+ const coordinates = getCoordinates(geometry, logger);
91339
+ const inaccessibilityPole = polylabel(coordinates);
91340
+ return { type: "Point", coordinates: inaccessibilityPole };
91341
+ }
91342
+ function getCoordinates(geometry, logger) {
91343
+ switch (geometry.type) {
91344
+ case "MultiPolygon":
91345
+ return geometry.coordinates[0];
91346
+ case "Polygon":
91347
+ return geometry.coordinates;
91348
+ }
91349
+ logger.error({ type: geometry.type }, "Unsupported geometry type");
91350
+ throw new Error("Unsupported geometry type");
91351
+ }
91352
+
91353
+ // src/modify/layers/pois.ts
91354
+ function handleLayerPois(feature, logger) {
91355
+ logger.trace({}, "HandlePois:Start");
91356
+ feature = structuredClone(feature);
91357
+ if (feature.properties["building"] === "building") {
91358
+ const bldgUse = feature.properties["bldg_use"];
91359
+ if (bldgUse == null) {
91360
+ logger.trace({}, "HandlePois:End");
91361
+ return null;
91362
+ }
91363
+ feature.properties["building"] = bldgUse;
91364
+ if (feature.geometry.type === "Polygon" || feature.geometry.type === "MultiPolygon") {
91365
+ feature.geometry = getInaccessibilityPole(feature.geometry, logger);
91366
+ }
91367
+ }
91368
+ logger.trace({}, "HandlePois:End");
91369
+ return feature;
91370
+ }
91371
+
91372
+ // src/modify/layers/public_transport.ts
91373
+ function handleLayerPublicTransport(feature, options, logger) {
91374
+ logger.trace({}, "HandlePublicTransport:Start");
91375
+ const kind = options.layer.tags["kind"];
91376
+ switch (kind) {
91377
+ case "aerodrome":
91378
+ feature = handleKindAerodrome(feature, logger);
91379
+ break;
91380
+ }
91381
+ logger.trace({}, "HandlePublicTransport:End");
91382
+ return feature;
91383
+ }
91384
+ function handleKindAerodrome(feature, logger) {
91385
+ logger.trace({}, "HandleKindAerodrome:Start");
91386
+ feature = structuredClone(feature);
91387
+ feature.geometry = getInaccessibilityPole(feature.geometry, logger);
91388
+ logger.trace({}, "HandleKindAerodrome:End");
91389
+ return feature;
91390
+ }
91354
91391
 
91355
91392
  // src/modify/layers/street_labels.ts
91356
91393
  function handleLayerStreetLabels(feature, options, logger) {
@@ -91416,9 +91453,9 @@ function handleKindTrack(feature, logger) {
91416
91453
  return feature;
91417
91454
  }
91418
91455
 
91419
- // src/modify/layers/water_polygons.ts
91456
+ // src/modify/layers/water.ts
91420
91457
  var LargeLakeSize = 4e6;
91421
- function handleLayerWaterPolygons(feature, options, logger) {
91458
+ function handleLayerWater(feature, options, logger) {
91422
91459
  logger.trace({}, "HandleWaterPolygons:Start");
91423
91460
  feature = structuredClone(feature);
91424
91461
  const kind = options.layer.tags["kind"];
@@ -91448,15 +91485,14 @@ function handleKindWater(feature, logger) {
91448
91485
  feature.properties["name"] = grpName;
91449
91486
  logger.trace({ name: grpName }, "new/overidden tags");
91450
91487
  }
91451
- let area = 0;
91452
- if (feature.geometry.type === "MultiPolygon") {
91453
- area = Area.multiPolygon(feature.geometry.coordinates);
91454
- } else if (feature.geometry.type === "Polygon") {
91455
- area = Area.polygon(feature.geometry.coordinates);
91488
+ if (feature.properties["water"] === "lake") {
91489
+ const aera = feature.properties["_derived_area"];
91490
+ if (aera != null && Number(aera) >= LargeLakeSize) {
91491
+ feature.tippecanoe.minzoom = 1;
91492
+ } else {
91493
+ feature.tippecanoe.minzoom = 9;
91494
+ }
91456
91495
  }
91457
- const minzoom = area >= LargeLakeSize ? 1 : 9;
91458
- feature.tippecanoe.minzoom = minzoom;
91459
- logger.trace({ minzoom }, "overidden styles");
91460
91496
  logger.trace({}, "HandleKindWater:End");
91461
91497
  return feature;
91462
91498
  }
@@ -91465,7 +91501,7 @@ function handleKindRiver(feature, options, logger) {
91465
91501
  feature = structuredClone(feature);
91466
91502
  if (options.layer.style.minZoom < 11) {
91467
91503
  const name = feature.properties["name"];
91468
- if (name === "") {
91504
+ if (name === "" && feature.tippecanoe.minzoom < 11) {
91469
91505
  const minzoom = 11;
91470
91506
  feature.tippecanoe.minzoom = minzoom;
91471
91507
  logger.trace({ minzoom }, "overidden styles");
@@ -91501,7 +91537,8 @@ function modifyFeature(feature, options, logger) {
91501
91537
  modifiedFeature = handleLayerStreets(feature, options, logger);
91502
91538
  break;
91503
91539
  case "water_polygons":
91504
- modifiedFeature = handleLayerWaterPolygons(feature, options, logger);
91540
+ case "water_lines":
91541
+ modifiedFeature = handleLayerWater(feature, options, logger);
91505
91542
  break;
91506
91543
  default:
91507
91544
  modifiedFeature = structuredClone(feature);
@@ -91510,6 +91547,17 @@ function modifyFeature(feature, options, logger) {
91510
91547
  return modifiedFeature;
91511
91548
  }
91512
91549
 
91550
+ // src/transform/nztm.ts
91551
+ function transformNdJson(feature) {
91552
+ projectFeature(feature, Nztm2000QuadTms);
91553
+ }
91554
+ function transformZoom(z2, tileMatrix) {
91555
+ if (tileMatrix.identifier === Nztm2000QuadTms.identifier)
91556
+ return Math.max(0, z2 - 2);
91557
+ else
91558
+ return z2;
91559
+ }
91560
+
91513
91561
  // src/util.ts
91514
91562
  var import_node_fs3 = require("fs");
91515
91563
  var import_fs4 = require("fs");
@@ -91626,7 +91674,7 @@ function simplify(points, tolerance, highestQuality) {
91626
91674
  }
91627
91675
 
91628
91676
  // src/generalization/generalization.ts
91629
- async function generalize(input, output, options, logger) {
91677
+ async function generalize(input, output, tileMatrix, options, logger) {
91630
91678
  logger.info({}, "Generalize:Start");
91631
91679
  const fileStream = await createReadStreamSafe(input.pathname);
91632
91680
  const simplify2 = options.layer.simplify;
@@ -91640,20 +91688,23 @@ async function generalize(input, output, options, logger) {
91640
91688
  for await (const line of rl) {
91641
91689
  if (line === "")
91642
91690
  continue;
91691
+ const feature = JSON.parse(line);
91692
+ if (tileMatrix.identifier === "NZTM2000Quad")
91693
+ transformNdJson(feature);
91643
91694
  inputCount++;
91644
91695
  if (simplify2 != null) {
91645
91696
  for (const s of simplify2) {
91646
- const feature = tag(options, line, s, logger);
91647
- if (feature == null)
91697
+ const vectorGeofeature = tag(tileMatrix, options, feature, s, logger);
91698
+ if (vectorGeofeature == null)
91648
91699
  continue;
91649
- writeStream.write(JSON.stringify(feature) + "\n");
91700
+ writeStream.write(JSON.stringify(vectorGeofeature) + "\n");
91650
91701
  outputCount++;
91651
91702
  }
91652
91703
  } else {
91653
- const feature = tag(options, line, null, logger);
91654
- if (feature == null)
91704
+ const vectorGeofeature = tag(tileMatrix, options, feature, null, logger);
91705
+ if (vectorGeofeature == null)
91655
91706
  continue;
91656
- writeStream.write(JSON.stringify(feature) + "\n");
91707
+ writeStream.write(JSON.stringify(vectorGeofeature) + "\n");
91657
91708
  outputCount++;
91658
91709
  }
91659
91710
  }
@@ -91667,36 +91718,40 @@ async function generalize(input, output, options, logger) {
91667
91718
  logger.info({ inputCount, outputCount }, "Generalize:End");
91668
91719
  return metrics;
91669
91720
  }
91670
- function tag(options, line, simplify2, logger) {
91671
- const feature = {
91672
- ...JSON.parse(line),
91721
+ function tag(tileMatrix, options, feature, simplify2, logger) {
91722
+ const vectorGeofeature = {
91723
+ ...structuredClone(feature),
91673
91724
  tippecanoe: {
91674
91725
  layer: options.name,
91675
91726
  minzoom: options.layer.style.minZoom,
91676
91727
  maxzoom: options.layer.style.maxZoom
91677
91728
  }
91678
91729
  };
91679
- Object.entries(options.layer.tags).forEach(([key, value]) => feature.properties[key] = value);
91680
- const modifiedFeature = modifyFeature(feature, options, logger);
91681
- if (modifiedFeature == null) {
91682
- return null;
91683
- }
91730
+ Object.entries(options.layer.tags).forEach(([key, value]) => vectorGeofeature.properties[key] = value);
91684
91731
  if (simplify2 != null) {
91685
- modifiedFeature["tippecanoe"] = {
91732
+ vectorGeofeature["tippecanoe"] = {
91686
91733
  layer: options.name,
91687
91734
  minzoom: simplify2.style.minZoom,
91688
91735
  maxzoom: simplify2.style.maxZoom
91689
91736
  };
91690
91737
  if (simplify2.tolerance != null) {
91691
- const geom = modifiedFeature.geometry;
91738
+ const geom = vectorGeofeature.geometry;
91692
91739
  const type = geom.type;
91693
- const coordinates = simplifyFeature(type, geom, simplify2.tolerance);
91694
- if (coordinates == null) {
91740
+ const geometry = simplifyFeature(type, geom, simplify2.tolerance);
91741
+ if (geometry == null) {
91695
91742
  return null;
91696
91743
  }
91697
- modifiedFeature.geometry = coordinates;
91744
+ vectorGeofeature.geometry = geometry;
91698
91745
  }
91699
91746
  }
91747
+ const modifiedFeature = modifyFeature(vectorGeofeature, options, logger);
91748
+ if (modifiedFeature == null) {
91749
+ return null;
91750
+ }
91751
+ if (modifiedFeature.tippecanoe.maxzoom < modifiedFeature.tippecanoe.minzoom)
91752
+ return null;
91753
+ modifiedFeature.tippecanoe.minzoom = transformZoom(modifiedFeature.tippecanoe.minzoom, tileMatrix);
91754
+ modifiedFeature.tippecanoe.maxzoom = transformZoom(modifiedFeature.tippecanoe.maxzoom, tileMatrix);
91700
91755
  const cleanedFeature = removeAttributes(modifiedFeature, options);
91701
91756
  return cleanedFeature;
91702
91757
  }
@@ -91979,32 +92034,54 @@ var CommandExecution = class {
91979
92034
  };
91980
92035
 
91981
92036
  // src/transform/ogr2ogr.ts
91982
- async function ogr2ogrNDJson(input, output, logger) {
92037
+ async function ogr2ogrNDJson(input, output, layer, logger) {
91983
92038
  const cmd = Command.create("ogr2ogr");
91984
92039
  cmd.args.push("-f", "GeoJSONSeq");
91985
92040
  cmd.args.push(output.pathname);
91986
92041
  cmd.args.push("-t_srs", Epsg.Wgs84.toEpsgString());
92042
+ if (layer.includeDerivedArea) {
92043
+ const table = await getTableName(input, logger);
92044
+ cmd.args.push("-dialect", "SQLite");
92045
+ cmd.args.push("-sql", `SELECT *, ST_Area(geom) AS _derived_area FROM "${table}"`);
92046
+ }
92047
+ cmd.args.push(input.pathname);
92048
+ const res = await cmd.run();
92049
+ if (res.exitCode !== 0) {
92050
+ logger.fatal({ Gdal: res }, "Failure");
92051
+ throw new Error("Gdal failed to run");
92052
+ }
92053
+ }
92054
+ async function getTableName(input, logger) {
92055
+ const cmd = Command.create("ogrinfo");
92056
+ cmd.args.push("-ro");
92057
+ cmd.args.push("-q");
92058
+ cmd.args.push("-json");
91987
92059
  cmd.args.push(input.pathname);
91988
92060
  const res = await cmd.run();
91989
92061
  if (res.exitCode !== 0) {
91990
92062
  logger.fatal({ Gdal: res }, "Failure");
91991
92063
  throw new Error("Gdal failed to run");
91992
92064
  }
92065
+ const info = JSON.parse(res.stdout);
92066
+ if (info.layers == null || info.layers.length === 0) {
92067
+ throw new Error(`No layers found in ${input.pathname}`);
92068
+ }
92069
+ return info.layers[0].name;
91993
92070
  }
91994
92071
 
91995
92072
  // src/transform/tippecanoe.ts
91996
92073
  var import_path2 = __toESM(require("path"), 1);
91997
- async function tippecanoe(input, output, layer, logger) {
92074
+ async function tippecanoe(input, output, layer, tileMatrix, logger) {
91998
92075
  const cmd = Command.create("tippecanoe");
91999
92076
  cmd.args.push("--read-parallel");
92000
92077
  cmd.args.push("-s", Epsg.Wgs84.toEpsgString());
92001
92078
  if (layer.style != null) {
92002
- cmd.args.push(`-Z${layer.style.minZoom}`);
92003
- cmd.args.push(`-z${layer.style.maxZoom}`);
92079
+ cmd.args.push(`-Z${transformZoom(layer.style.minZoom, tileMatrix)}`);
92080
+ cmd.args.push(`-z${transformZoom(layer.style.maxZoom, tileMatrix)}`);
92004
92081
  if (layer.style.detail != null)
92005
92082
  cmd.args.push(`--full-detail=${layer.style.detail}`);
92006
92083
  } else {
92007
- cmd.args.push(`-z15`);
92084
+ cmd.args.push(`-z${transformZoom(15, tileMatrix)}`);
92008
92085
  }
92009
92086
  cmd.mount((0, import_path2.dirname)(input.pathname));
92010
92087
  cmd.mount((0, import_path2.dirname)(output.pathname));
@@ -92140,16 +92217,19 @@ async function createMbtilesFile({ stac, tmpPaths }, logger) {
92140
92217
  throw new Error(`Stac file missing linz_basemaps:options ${stac.id}`);
92141
92218
  const layer = options.layer;
92142
92219
  const shortbreadLayer = options.name;
92220
+ const tileMatrix = TileMatrixSets.find(options.tileMatrix);
92221
+ if (tileMatrix == null)
92222
+ throw new Error(`Tile matrix ${options.tileMatrix} is not supported`);
92143
92223
  logger.info({ shortbreadLayer, dataset: layer.name }, "CreateMbtilesFile: Start");
92144
92224
  logger.info({ source: tmpPaths.source.path, dataset: layer.name }, "[1/5] Convert source file to ndjson: Start");
92145
92225
  if (!await Fsa.exists(tmpPaths.ndjson)) {
92146
- await ogr2ogrNDJson(tmpPaths.source.path, tmpPaths.ndjson, logger);
92226
+ await ogr2ogrNDJson(tmpPaths.source.path, tmpPaths.ndjson, layer, logger);
92147
92227
  }
92148
92228
  logger.info({ destination: tmpPaths.ndjson, dataset: layer.name }, "[1/5] Convert source file to ndjson: End");
92149
92229
  logger.info({ source: tmpPaths.ndjson, dataset: layer.name }, "[2/5] Generalise ndjson features: Start");
92150
92230
  let metrics = null;
92151
92231
  if (!await Fsa.exists(tmpPaths.genNdjson)) {
92152
- metrics = await generalize(tmpPaths.ndjson, tmpPaths.genNdjson, options, logger);
92232
+ metrics = await generalize(tmpPaths.ndjson, tmpPaths.genNdjson, tileMatrix, options, logger);
92153
92233
  if (metrics.output === 0)
92154
92234
  throw new Error(`Failed to generalize ndjson file ${tmpPaths.ndjson.href}`);
92155
92235
  }
@@ -92159,7 +92239,7 @@ async function createMbtilesFile({ stac, tmpPaths }, logger) {
92159
92239
  "[3/5] Transform generalised ndjson into mbtiles: Start"
92160
92240
  );
92161
92241
  if (!await Fsa.exists(tmpPaths.mbtiles)) {
92162
- await tippecanoe(tmpPaths.genNdjson, tmpPaths.mbtiles, layer, logger);
92242
+ await tippecanoe(tmpPaths.genNdjson, tmpPaths.mbtiles, layer, tileMatrix, logger);
92163
92243
  }
92164
92244
  logger.info(
92165
92245
  { destination: tmpPaths.mbtiles, dataset: layer.name },
@@ -93154,7 +93234,7 @@ async function upload(file, bucketPath, logger) {
93154
93234
  if (path4.protocol === "file:")
93155
93235
  await (0, import_promises.mkdir)((0, import_path3.dirname)(path4.pathname), { recursive: true });
93156
93236
  if (filename.endsWith("catalog.json"))
93157
- path4 = new URL(filename, bucketPath);
93237
+ path4 = new URL(`topographic/${filename}`, bucketPath);
93158
93238
  await Fsa.write(path4, stream);
93159
93239
  logger.info({ file, path: path4 }, "Load:Finish");
93160
93240
  return path4;
@@ -93234,7 +93314,7 @@ var JoinCommand = (0, import_cmd_ts4.command)({
93234
93314
  }
93235
93315
  if (isArgo()) {
93236
93316
  const target = new URL(`topographic/${CliId}/${args.filename}.tar.co`, bucketPath);
93237
- await Fsa.write(Fsa.toUrl("/tmp/target"), JSON.stringify([target]));
93317
+ await Fsa.write(Fsa.toUrl("/tmp/target"), urlToString(target));
93238
93318
  const mbTilesTarget = new URL(`topographic/${CliId}/${args.filename}.mbtiles`, bucketPath);
93239
93319
  await Fsa.write(Fsa.toUrl("/tmp/mbTilesTarget"), mbTilesTarget.toString());
93240
93320
  const analyseTarget = new URL(`topographic/${CliId}/`, bucketPath);
@@ -93789,7 +93869,7 @@ var AnalyseCommand = (0, import_cmd_ts5.command)({
93789
93869
  y: row.y,
93790
93870
  z: row.z,
93791
93871
  max: buffer.length,
93792
- link: `https://basemaps.linz.govt.nz/v1/tiles/topographic/WebMercatorQuad/${row.z}/${row.z}/${row.y}.pbf`
93872
+ link: `https://basemaps.linz.govt.nz/v1/tiles/topographic/WebMercatorQuad/${row.z}/${row.x}/${row.y}.pbf`
93793
93873
  };
93794
93874
  const dis = distribution(buffer.length);
93795
93875
  const value = distributionSum.get(dis);