tileserver-gl-light 4.9.1 → 4.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tileserver-gl-light",
3
- "version": "4.9.1",
3
+ "version": "4.10.0",
4
4
  "description": "Map tile server for JSON GL styles - serving vector tiles",
5
5
  "main": "src/main.js",
6
6
  "bin": "src/main.js",
@@ -108,6 +108,7 @@
108
108
  for (tile_url in tile_urls) {
109
109
  L.tileLayer(tile_urls[tile_url], {
110
110
  tileSize: 512,
111
+ zoomOffset: -1,
111
112
  minZoom: tile_minzoom,
112
113
  maxZoom: tile_maxzoom,
113
114
  attribution: tile_attribution
@@ -251,7 +251,7 @@
251
251
  <ows:Identifier>GoogleMapsCompatible_512</ows:Identifier>
252
252
  <ows:SupportedCRS>urn:ogc:def:crs:EPSG::3857</ows:SupportedCRS>
253
253
  <TileMatrix>
254
- <ows:Identifier>1</ows:Identifier>
254
+ <ows:Identifier>0</ows:Identifier>
255
255
  <ScaleDenominator>279541132.0143589</ScaleDenominator>
256
256
  <TopLeftCorner>-20037508.34 20037508.34</TopLeftCorner>
257
257
  <TileWidth>512</TileWidth>
@@ -260,7 +260,7 @@
260
260
  <MatrixHeight>1</MatrixHeight>
261
261
  </TileMatrix>
262
262
  <TileMatrix>
263
- <ows:Identifier>2</ows:Identifier>
263
+ <ows:Identifier>1</ows:Identifier>
264
264
  <ScaleDenominator>139770566.0071794</ScaleDenominator>
265
265
  <TopLeftCorner>-20037508.34 20037508.34</TopLeftCorner>
266
266
  <TileWidth>512</TileWidth>
@@ -269,7 +269,7 @@
269
269
  <MatrixHeight>2</MatrixHeight>
270
270
  </TileMatrix>
271
271
  <TileMatrix>
272
- <ows:Identifier>3</ows:Identifier>
272
+ <ows:Identifier>2</ows:Identifier>
273
273
  <ScaleDenominator>69885283.00358972</ScaleDenominator>
274
274
  <TopLeftCorner>-20037508.34 20037508.34</TopLeftCorner>
275
275
  <TileWidth>512</TileWidth>
@@ -278,7 +278,7 @@
278
278
  <MatrixHeight>4</MatrixHeight>
279
279
  </TileMatrix>
280
280
  <TileMatrix>
281
- <ows:Identifier>4</ows:Identifier>
281
+ <ows:Identifier>3</ows:Identifier>
282
282
  <ScaleDenominator>34942641.501795</ScaleDenominator>
283
283
  <TopLeftCorner>-20037508.34 20037508.34</TopLeftCorner>
284
284
  <TileWidth>512</TileWidth>
@@ -287,7 +287,7 @@
287
287
  <MatrixHeight>8</MatrixHeight>
288
288
  </TileMatrix>
289
289
  <TileMatrix>
290
- <ows:Identifier>5</ows:Identifier>
290
+ <ows:Identifier>4</ows:Identifier>
291
291
  <ScaleDenominator>17471320.750897</ScaleDenominator>
292
292
  <TopLeftCorner>-20037508.34 20037508.34</TopLeftCorner>
293
293
  <TileWidth>512</TileWidth>
@@ -296,7 +296,7 @@
296
296
  <MatrixHeight>16</MatrixHeight>
297
297
  </TileMatrix>
298
298
  <TileMatrix>
299
- <ows:Identifier>6</ows:Identifier>
299
+ <ows:Identifier>5</ows:Identifier>
300
300
  <ScaleDenominator>8735660.3754487</ScaleDenominator>
301
301
  <TopLeftCorner>-20037508.34 20037508.34</TopLeftCorner>
302
302
  <TileWidth>512</TileWidth>
@@ -305,7 +305,7 @@
305
305
  <MatrixHeight>32</MatrixHeight>
306
306
  </TileMatrix>
307
307
  <TileMatrix>
308
- <ows:Identifier>7</ows:Identifier>
308
+ <ows:Identifier>6</ows:Identifier>
309
309
  <ScaleDenominator>4367830.1877244</ScaleDenominator>
310
310
  <TopLeftCorner>-20037508.34 20037508.34</TopLeftCorner>
311
311
  <TileWidth>512</TileWidth>
@@ -314,7 +314,7 @@
314
314
  <MatrixHeight>64</MatrixHeight>
315
315
  </TileMatrix>
316
316
  <TileMatrix>
317
- <ows:Identifier>8</ows:Identifier>
317
+ <ows:Identifier>7</ows:Identifier>
318
318
  <ScaleDenominator>2183915.0938622</ScaleDenominator>
319
319
  <TopLeftCorner>-20037508.34 20037508.34</TopLeftCorner>
320
320
  <TileWidth>512</TileWidth>
@@ -323,7 +323,7 @@
323
323
  <MatrixHeight>128</MatrixHeight>
324
324
  </TileMatrix>
325
325
  <TileMatrix>
326
- <ows:Identifier>9</ows:Identifier>
326
+ <ows:Identifier>8</ows:Identifier>
327
327
  <ScaleDenominator>1091957.5469311</ScaleDenominator>
328
328
  <TopLeftCorner>-20037508.34 20037508.34</TopLeftCorner>
329
329
  <TileWidth>512</TileWidth>
@@ -332,7 +332,7 @@
332
332
  <MatrixHeight>256</MatrixHeight>
333
333
  </TileMatrix>
334
334
  <TileMatrix>
335
- <ows:Identifier>10</ows:Identifier>
335
+ <ows:Identifier>9</ows:Identifier>
336
336
  <ScaleDenominator>545978.77346554</ScaleDenominator>
337
337
  <TopLeftCorner>-20037508.34 20037508.34</TopLeftCorner>
338
338
  <TileWidth>512</TileWidth>
@@ -341,7 +341,7 @@
341
341
  <MatrixHeight>512</MatrixHeight>
342
342
  </TileMatrix>
343
343
  <TileMatrix>
344
- <ows:Identifier>11</ows:Identifier>
344
+ <ows:Identifier>10</ows:Identifier>
345
345
  <ScaleDenominator>272989.38673277</ScaleDenominator>
346
346
  <TopLeftCorner>-20037508.34 20037508.34</TopLeftCorner>
347
347
  <TileWidth>512</TileWidth>
@@ -350,7 +350,7 @@
350
350
  <MatrixHeight>1024</MatrixHeight>
351
351
  </TileMatrix>
352
352
  <TileMatrix>
353
- <ows:Identifier>12</ows:Identifier>
353
+ <ows:Identifier>11</ows:Identifier>
354
354
  <ScaleDenominator>136494.69336639</ScaleDenominator>
355
355
  <TopLeftCorner>-20037508.34 20037508.34</TopLeftCorner>
356
356
  <TileWidth>512</TileWidth>
@@ -359,7 +359,7 @@
359
359
  <MatrixHeight>2048</MatrixHeight>
360
360
  </TileMatrix>
361
361
  <TileMatrix>
362
- <ows:Identifier>13</ows:Identifier>
362
+ <ows:Identifier>12</ows:Identifier>
363
363
  <ScaleDenominator>68247.346683193</ScaleDenominator>
364
364
  <TopLeftCorner>-20037508.34 20037508.34</TopLeftCorner>
365
365
  <TileWidth>512</TileWidth>
@@ -368,7 +368,7 @@
368
368
  <MatrixHeight>4096</MatrixHeight>
369
369
  </TileMatrix>
370
370
  <TileMatrix>
371
- <ows:Identifier>14</ows:Identifier>
371
+ <ows:Identifier>13</ows:Identifier>
372
372
  <ScaleDenominator>34123.673341597</ScaleDenominator>
373
373
  <TopLeftCorner>-20037508.34 20037508.34</TopLeftCorner>
374
374
  <TileWidth>512</TileWidth>
@@ -377,7 +377,7 @@
377
377
  <MatrixHeight>8192</MatrixHeight>
378
378
  </TileMatrix>
379
379
  <TileMatrix>
380
- <ows:Identifier>15</ows:Identifier>
380
+ <ows:Identifier>14</ows:Identifier>
381
381
  <ScaleDenominator>17061.836670798</ScaleDenominator>
382
382
  <TopLeftCorner>-20037508.34 20037508.34</TopLeftCorner>
383
383
  <TileWidth>512</TileWidth>
@@ -386,7 +386,7 @@
386
386
  <MatrixHeight>16384</MatrixHeight>
387
387
  </TileMatrix>
388
388
  <TileMatrix>
389
- <ows:Identifier>16</ows:Identifier>
389
+ <ows:Identifier>15</ows:Identifier>
390
390
  <ScaleDenominator>8530.9183353991</ScaleDenominator>
391
391
  <TopLeftCorner>-20037508.34 20037508.34</TopLeftCorner>
392
392
  <TileWidth>512</TileWidth>
@@ -395,7 +395,7 @@
395
395
  <MatrixHeight>32768</MatrixHeight>
396
396
  </TileMatrix>
397
397
  <TileMatrix>
398
- <ows:Identifier>17</ows:Identifier>
398
+ <ows:Identifier>16</ows:Identifier>
399
399
  <ScaleDenominator>4265.4591676996</ScaleDenominator>
400
400
  <TopLeftCorner>-20037508.34 20037508.34</TopLeftCorner>
401
401
  <TileWidth>512</TileWidth>
@@ -404,7 +404,7 @@
404
404
  <MatrixHeight>65536</MatrixHeight>
405
405
  </TileMatrix>
406
406
  <TileMatrix>
407
- <ows:Identifier>18</ows:Identifier>
407
+ <ows:Identifier>17</ows:Identifier>
408
408
  <ScaleDenominator>2132.7295838498</ScaleDenominator>
409
409
  <TopLeftCorner>-20037508.34 20037508.34</TopLeftCorner>
410
410
  <TileWidth>512</TileWidth>
@@ -413,7 +413,7 @@
413
413
  <MatrixHeight>131072</MatrixHeight>
414
414
  </TileMatrix>
415
415
  <TileMatrix>
416
- <ows:Identifier>19</ows:Identifier>
416
+ <ows:Identifier>18</ows:Identifier>
417
417
  <ScaleDenominator>1066.364791924892</ScaleDenominator>
418
418
  <TopLeftCorner>-20037508.34 20037508.34</TopLeftCorner>
419
419
  <TileWidth>512</TileWidth>
@@ -413,7 +413,14 @@ const respondImage = (
413
413
  pool = item.map.renderersStatic[scale];
414
414
  }
415
415
  pool.acquire((err, renderer) => {
416
- const mlglZ = Math.max(0, z - 1);
416
+ // For 512px tiles, use the actual maplibre-native zoom. For 256px tiles, use zoom - 1
417
+ let mlglZ;
418
+ if (width === 512) {
419
+ mlglZ = Math.max(0, z);
420
+ } else {
421
+ mlglZ = Math.max(0, z - 1);
422
+ }
423
+
417
424
  const params = {
418
425
  zoom: mlglZ,
419
426
  center: [lon, lat],
@@ -423,12 +430,14 @@ const respondImage = (
423
430
  height,
424
431
  };
425
432
 
426
- if (z === 0) {
433
+ // HACK(Part 1) 256px tiles are a zoom level lower than maplibre-native default tiles. this hack allows tileserver-gl to support zoom 0 256px tiles, which would actually be zoom -1 in maplibre-native. Since zoom -1 isn't supported, a double sized zoom 0 tile is requested and resized in Part 2.
434
+ if (z === 0 && width === 256) {
427
435
  params.width *= 2;
428
436
  params.height *= 2;
429
437
  }
438
+ // END HACK(Part 1)
430
439
 
431
- if (z > 2 && tileMargin > 0) {
440
+ if (z > 0 && tileMargin > 0) {
432
441
  params.width += tileMargin * 2;
433
442
  params.height += tileMargin * 2;
434
443
  }
@@ -449,9 +458,9 @@ const respondImage = (
449
458
  },
450
459
  });
451
460
 
452
- if (z > 2 && tileMargin > 0) {
453
- const [_, y] = mercator.px(params.center, z);
454
- let yoffset = Math.max(
461
+ if (z > 0 && tileMargin > 0) {
462
+ const y = mercator.px(params.center, z)[1];
463
+ const yoffset = Math.max(
455
464
  Math.min(0, y - 128 - tileMargin),
456
465
  y + 128 + tileMargin - Math.pow(2, z + 8),
457
466
  );
@@ -463,10 +472,11 @@ const respondImage = (
463
472
  });
464
473
  }
465
474
 
466
- if (z === 0) {
467
- // HACK: when serving zoom 0, resize the 0 tile from 512 to 256
475
+ // HACK(Part 2) 256px tiles are a zoom level lower than maplibre-native default tiles. this hack allows tileserver-gl to support zoom 0 256px tiles, which would actually be zoom -1 in maplibre-native. Since zoom -1 isn't supported, a double sized zoom 0 tile is requested and resized here.
476
+ if (z === 0 && width === 256) {
468
477
  image.resize(width * scale, height * scale);
469
478
  }
479
+ // END HACK(Part 2)
470
480
 
471
481
  const composites = [];
472
482
  if (overlay) {
@@ -564,10 +574,11 @@ export const serve_rendered = {
564
574
  ) {
565
575
  return res.status(404).send('Out of bounds');
566
576
  }
577
+
567
578
  const tileCenter = mercator.ll(
568
579
  [
569
- ((x + 0.5) / (1 << z)) * (tileSize << z),
570
- ((y + 0.5) / (1 << z)) * (tileSize << z),
580
+ ((x + 0.5) / (1 << z)) * (256 << z),
581
+ ((y + 0.5) / (1 << z)) * (256 << z),
571
582
  ],
572
583
  z,
573
584
  );