Skip to content

Commit d79c87d

Browse files
authored
feat(stac): add PMTiles assets to the map (#1950)
* refactor(map): build every PMTiles store layer through one shared shaper * feat(stac): add PMTiles assets to the map * i18n: list PMTiles in the STAC unsupported-asset tooltip across all 18 locales * fix(stac): fail a PMTiles add without an app, and queue pending layer names per archive * fix(stac): let a declared media type outrank an extension, and fail a refused PMTiles add * docs(plugins): record why the pending-name disposer is for the failure path * docs(stac): attach the format table's comment to the table * docs(map): stop claiming a reason for the layer-id percent swap * fix(plugins): take PMTiles adds one at a time, since the control holds state across awaits * fix(stac): fail a GeoJSON add without an app, and drop a PMTiles add the panel abandoned * fix(plugins): match a pending PMTiles name to its archive so a panel add cannot take it * refactor(stac): name a PMTiles layer after adding it, and honor the signal once queued * refactor(stac): build the PMTiles layer directly instead of driving the shared control * fix(map): read an MLT archive as vector and tell MapLibre how to decode it * fix(map): follow a caller's fill colour with the outline unless it set its own * fix(stac): refuse a PMTiles archive with no layers instead of adding a placeholder * fix(stac): localize the no-layers message, and forward the tile encoding when extracting * fix(map): carry a caller's abort signal into the archive header read * refactor(map): read tile types from the pmtiles enum instead of literals
1 parent 51ea680 commit d79c87d

39 files changed

Lines changed: 1002 additions & 203 deletions

apps/geolibre-desktop/src/components/layout/BasemapExtractPanel.tsx

Lines changed: 13 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,11 @@
1-
import {
2-
DEFAULT_BASEMAP,
3-
DEFAULT_LAYER_STYLE,
4-
type GeoLibreLayer,
5-
useAppStore,
6-
} from "@geolibre/core";
1+
import { DEFAULT_BASEMAP, useAppStore } from "@geolibre/core";
72
import {
83
buildProtomapsBasemapStyle,
4+
createPMTilesStoreLayer,
95
evictOfflineBasemapStyle,
106
hasPMTilesArchive,
117
type MapController,
128
OFFLINE_BASEMAP_SENTINEL_PREFIX,
13-
pmtilesNativeLayerIds,
149
PROTOMAPS_FLAVORS,
1510
type ProtomapsFlavor,
1611
readPMTilesArchiveInfo,
@@ -708,39 +703,19 @@ export function BasemapExtractPanel({ open, onClose, mapControllerRef }: Basemap
708703
setBasemapStyleUrl(registerOfflineBasemapStyle(layerId, style));
709704
trackStyledBasemap(layerId, `${layerId}.pmtiles`);
710705
} else {
711-
const fillColor = DEFAULT_LAYER_STYLE.fillColor;
712-
const layer: GeoLibreLayer = {
713-
id: layerId,
714-
name: fileName,
715-
type: "pmtiles",
716-
source: {
717-
sourceId: layerId,
718-
sourceLayers: info.sourceLayers,
719-
tileType: info.tileType,
720-
type: info.tileType === "raster" ? "raster" : "vector",
706+
addLayer(
707+
createPMTilesStoreLayer({
708+
id: layerId,
709+
name: fileName,
721710
url: layerUrl,
722-
},
723-
visible: true,
724-
// Raster basemaps render dimmed (raster-opacity reads the layer-level
725-
// `opacity`, not style.fillOpacity); vector renders fully opaque.
726-
opacity: info.tileType === "raster" ? 0.6 : 1,
727-
style: {
728-
...DEFAULT_LAYER_STYLE,
729-
fillColor,
730-
strokeColor: fillColor,
731-
},
732-
metadata: {
733-
externalNativeLayer: true,
734-
nativeLayerIds: pmtilesNativeLayerIds(layerId, info.tileType, info.sourceLayers),
735-
pickable: true,
736-
sourceId: layerId,
737-
sourceKind: "pmtiles-url",
738-
sourceLayers: info.sourceLayers,
739711
tileType: info.tileType,
740-
},
741-
sourcePath: layerUrl,
742-
};
743-
addLayer(layer);
712+
...(info.encoding ? { encoding: info.encoding } : {}),
713+
sourceLayers: info.sourceLayers,
714+
// Raster basemaps render dimmed (raster-opacity reads the layer-level
715+
// `opacity`, not style.fillOpacity); vector renders fully opaque.
716+
opacity: info.tileType === "raster" ? 0.6 : 1,
717+
}),
718+
);
744719
}
745720
setPhase("done");
746721

apps/geolibre-desktop/src/components/layout/TopToolbar.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -933,6 +933,7 @@ export function TopToolbar({
933933
added: (asset) => t("stacPlugin.added", { asset }),
934934
addUnsupported: t("stacPlugin.addUnsupported"),
935935
addFailed: t("stacPlugin.addFailed"),
936+
addNoSourceLayers: t("stacPlugin.addNoSourceLayers"),
936937
cogUnsupported: t("stacPlugin.cogUnsupported"),
937938
});
938939
}, [t]);

apps/geolibre-desktop/src/i18n/locales/ar.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3641,8 +3641,9 @@
36413641
"download": "تنزيل",
36423642
"adding": "جارٍ إضافة {{asset}}…",
36433643
"added": "تمت إضافة {{asset}} إلى الخريطة.",
3644-
"addUnsupported": "يمكن إضافة أصول GeoTIFF/COG وGeoJSON فقط إلى الخريطة",
3644+
"addUnsupported": "يمكن إضافة أصول GeoTIFF/COG وGeoJSON وPMTiles فقط إلى الخريطة",
36453645
"addFailed": "تعذّرت إضافة الأصل",
3646+
"addNoSourceLayers": "لا يسرد هذا الأرشيف أي طبقات لرسمها",
36463647
"cogUnsupported": "لا يستطيع مضيف GeoLibre هذا عرض أصول GeoTIFF البعيدة"
36473648
},
36483649
"earthdataGis": {

apps/geolibre-desktop/src/i18n/locales/de.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3418,8 +3418,9 @@
34183418
"download": "Herunterladen",
34193419
"adding": "{{asset}} wird hinzugefügt…",
34203420
"added": "{{asset}} zur Karte hinzugefügt.",
3421-
"addUnsupported": "Nur GeoTIFF/COG- und GeoJSON-Assets können zur Karte hinzugefügt werden",
3421+
"addUnsupported": "Nur GeoTIFF/COG-, GeoJSON- und PMTiles-Assets können zur Karte hinzugefügt werden",
34223422
"addFailed": "Asset konnte nicht hinzugefügt werden",
3423+
"addNoSourceLayers": "Dieses Archiv führt keine zeichenbaren Ebenen auf",
34233424
"cogUnsupported": "Dieser GeoLibre-Host kann entfernte GeoTIFF-Assets nicht darstellen"
34243425
},
34253426
"earthdataGis": {

apps/geolibre-desktop/src/i18n/locales/en.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3428,8 +3428,9 @@
34283428
"download": "Download",
34293429
"adding": "Adding {{asset}}…",
34303430
"added": "Added {{asset}} to the map.",
3431-
"addUnsupported": "Only GeoTIFF/COG and GeoJSON assets can be added to the map",
3431+
"addUnsupported": "Only GeoTIFF/COG, GeoJSON, and PMTiles assets can be added to the map",
34323432
"addFailed": "Could not add asset",
3433+
"addNoSourceLayers": "This archive lists no layers to draw",
34333434
"cogUnsupported": "This GeoLibre host cannot visualize remote GeoTIFF assets"
34343435
},
34353436
"earthdataGis": {

apps/geolibre-desktop/src/i18n/locales/es.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3418,8 +3418,9 @@
34183418
"download": "Descargar",
34193419
"adding": "Añadiendo {{asset}}…",
34203420
"added": "{{asset}} añadido al mapa.",
3421-
"addUnsupported": "Solo se pueden añadir al mapa recursos GeoTIFF/COG y GeoJSON",
3421+
"addUnsupported": "Solo se pueden añadir al mapa recursos GeoTIFF/COG, GeoJSON y PMTiles",
34223422
"addFailed": "No se pudo añadir el recurso",
3423+
"addNoSourceLayers": "Este archivo no incluye capas que dibujar",
34233424
"cogUnsupported": "Este host de GeoLibre no puede visualizar recursos GeoTIFF remotos"
34243425
},
34253426
"earthdataGis": {

apps/geolibre-desktop/src/i18n/locales/fa.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3418,8 +3418,9 @@
34183418
"download": "دانلود",
34193419
"adding": "در حال افزودن {{asset}}…",
34203420
"added": "{{asset}} به نقشه افزوده شد.",
3421-
"addUnsupported": "تنها دارایی‌های GeoTIFF/COG و GeoJSON را می‌توان به نقشه افزود",
3421+
"addUnsupported": "تنها دارایی‌های GeoTIFF/COG، GeoJSON و PMTiles را می‌توان به نقشه افزود",
34223422
"addFailed": "افزودن دارایی با شکست مواجه شد",
3423+
"addNoSourceLayers": "این بایگانی هیچ لایه‌ای برای ترسیم فهرست نکرده است",
34233424
"cogUnsupported": "این میزبان GeoLibre نمی‌تواند دارایی‌های GeoTIFF دوردست را نمایش دهد"
34243425
},
34253426
"earthdataGis": {

apps/geolibre-desktop/src/i18n/locales/fr.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3418,8 +3418,9 @@
34183418
"download": "Télécharger",
34193419
"adding": "Ajout de {{asset}}…",
34203420
"added": "{{asset}} ajouté à la carte.",
3421-
"addUnsupported": "Seules les ressources GeoTIFF/COG et GeoJSON peuvent être ajoutées à la carte",
3421+
"addUnsupported": "Seules les ressources GeoTIFF/COG, GeoJSON et PMTiles peuvent être ajoutées à la carte",
34223422
"addFailed": "Impossible d'ajouter la ressource",
3423+
"addNoSourceLayers": "Cette archive ne répertorie aucune couche à dessiner",
34233424
"cogUnsupported": "Cet hôte GeoLibre ne peut pas visualiser les ressources GeoTIFF distantes"
34243425
},
34253426
"earthdataGis": {

apps/geolibre-desktop/src/i18n/locales/hi.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3418,8 +3418,9 @@
34183418
"download": "डाउनलोड करें",
34193419
"adding": "{{asset}} जोड़ा जा रहा है…",
34203420
"added": "{{asset}} मानचित्र में जोड़ा गया।",
3421-
"addUnsupported": "मानचित्र में केवल GeoTIFF/COG और GeoJSON एसेट जोड़ी जा सकती हैं",
3421+
"addUnsupported": "मानचित्र में केवल GeoTIFF/COG, GeoJSON और PMTiles एसेट जोड़ी जा सकती हैं",
34223422
"addFailed": "एसेट नहीं जोड़ी जा सकी",
3423+
"addNoSourceLayers": "इस संग्रह में बनाने के लिए कोई लेयर सूचीबद्ध नहीं है",
34233424
"cogUnsupported": "यह GeoLibre होस्ट दूरस्थ GeoTIFF एसेट प्रदर्शित नहीं कर सकता"
34243425
},
34253426
"earthdataGis": {

apps/geolibre-desktop/src/i18n/locales/id.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3362,8 +3362,9 @@
33623362
"download": "Unduh",
33633363
"adding": "Menambahkan {{asset}}…",
33643364
"added": "{{asset}} ditambahkan ke peta.",
3365-
"addUnsupported": "Hanya aset GeoTIFF/COG dan GeoJSON yang dapat ditambahkan ke peta",
3365+
"addUnsupported": "Hanya aset GeoTIFF/COG, GeoJSON, dan PMTiles yang dapat ditambahkan ke peta",
33663366
"addFailed": "Tidak dapat menambahkan aset",
3367+
"addNoSourceLayers": "Arsip ini tidak mencantumkan lapisan untuk digambar",
33673368
"cogUnsupported": "Host GeoLibre ini tidak dapat memvisualisasikan aset GeoTIFF jarak jauh"
33683369
},
33693370
"earthdataGis": {

0 commit comments

Comments
 (0)