Skip to content

Commit

Permalink
Merge pull request #1073 from geonetwork/GSIGNGPF-27-tms
Browse files Browse the repository at this point in the history
Datahub: Tms support for basemap
  • Loading branch information
AlitaBernachot authored Jan 8, 2025
2 parents 16f1367 + 4f88923 commit 17894ab
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 3 deletions.
3 changes: 3 additions & 0 deletions conf/default.toml
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,9 @@ background_color = "#fdfbff"
# Each layer is defined in its own [[map_layer]] section.
# Example:
# [[map_layer]]
# type = "maplibre-style"
# styleUrl = "https://data.geopf.fr/annexes/ressources/vectorTiles/styles/PLAN.IGN/gris.json"
# [[map_layer]]
# type = "xyz"
# url = "https://{a-c}.basemaps.cartocdn.com/light_all/{z}/{x}/{y}.png"
# [[map_layer]]
Expand Down
7 changes: 7 additions & 0 deletions docs/guide/configure.md
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,8 @@ The map section lets you customize how maps appear and behave across GeoNetwork-
- `url` (mandatory for "xyz", "wms" and "wfs" types): Layer endpoint URL.
- `name` (mandatory for "wms" and "wfs" types): indicates the layer name or feature type.
- `data` (for "geojson" type only): inline GeoJSON data as string.
- `styleUrl` (mandatory for "maplibre-style" type only): Maplibre style URL.
- `accessToken` (optional for "maplibre-style" type only): credential to access the basemap styles service

Layer order in the config is the same as in the map, the foreground layer being the last defined one.

Expand All @@ -254,6 +256,11 @@ The map section lets you customize how maps appear and behave across GeoNetwork-
"features": [{"type": "Feature", "geometry": {"type": "Point", "coordinates": [125.6, 10.1]}}]
}
"""

[[map_layer]]
type = "maplibre-style"
styleUrl = "https://data.geopf.fr/annexes/ressources/vectorTiles/styles/PLAN.IGN/gris.json"
accessToken = "token_if_needed" # optional
```

- `external_viewer_url_template` (optional)
Expand Down
12 changes: 11 additions & 1 deletion libs/util/app-config/src/lib/app-config.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,11 @@ describe('app config utils', () => {
[[map_layer]]
type = "wfs"
url = "https://www.geo2france.fr/geoserver/cr_hdf/ows"
name = "masque_hdf_ign_carto_latin1"`
name = "masque_hdf_ign_carto_latin1"
[[map_layer]]
type = "maplibre-style"
styleUrl = "https://data.geopf.fr/annexes/ressources/vectorTiles/styles/PLAN.IGN/standard.json"
accessToken = "any_token"`
)
await loadAppConfig()
})
Expand All @@ -303,6 +307,12 @@ describe('app config utils', () => {
URL: 'https://www.geo2france.fr/geoserver/cr_hdf/ows',
NAME: 'masque_hdf_ign_carto_latin1',
},
{
TYPE: 'maplibre-style',
STYLE_URL:
'https://data.geopf.fr/annexes/ressources/vectorTiles/styles/PLAN.IGN/standard.json',
ACCESS_TOKEN: 'any_token',
},
],
})
})
Expand Down
4 changes: 3 additions & 1 deletion libs/util/app-config/src/lib/app-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ export function loadAppConfig() {
parsed,
'map_layer',
['type'],
['name', 'url', 'data'],
['name', 'url', 'data', 'styleUrl', 'accessToken'],
warnings,
errors
)
Expand Down Expand Up @@ -177,6 +177,8 @@ export function loadAppConfig() {
URL: map_layer.url,
NAME: map_layer.name,
DATA: map_layer.data,
STYLE_URL: map_layer.styleUrl,
ACCESS_TOKEN: map_layer.accessToken,
} as LayerConfig)
),
} as MapConfig)
Expand Down
6 changes: 6 additions & 0 deletions libs/util/app-config/src/lib/map-layers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,11 @@ export function getMapContextLayerFromConfig(
type: config.TYPE,
...(config.DATA ? { data: config.DATA } : { url: config.URL }),
}
case 'maplibre-style':
return {
type: config.TYPE,
styleUrl: config.STYLE_URL,
accessToken: config.ACCESS_TOKEN,
}
}
}
4 changes: 3 additions & 1 deletion libs/util/app-config/src/lib/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,12 @@ export interface GlobalConfig {
}

export interface LayerConfig {
TYPE: 'xyz' | 'wms' | 'wfs' | 'geojson'
TYPE: 'xyz' | 'wms' | 'wfs' | 'geojson' | 'maplibre-style'
URL?: string
NAME?: string
DATA?: string
STYLE_URL?: string
ACCESS_TOKEN?: string
}

export interface MapConfig {
Expand Down

0 comments on commit 17894ab

Please sign in to comment.