From f1561efcbe1e8fa8ab893daa1312d3fc911bf07d Mon Sep 17 00:00:00 2001 From: Matthias Mohr Date: Fri, 4 Apr 2025 02:17:10 +0200 Subject: [PATCH 1/7] Improve CRS, layer switcher and basemap handling --- basemaps.config.js | 7 +-- config.js | 3 +- config.schema.json | 5 +++ docs/options.md | 18 ++++++++ src/components/Map.vue | 4 -- src/components/maps/LayerControl.vue | 65 ++++++++++++++++++++-------- src/components/maps/MapMixin.js | 29 +++++++++---- src/components/maps/MapSelect.vue | 4 -- 8 files changed, 98 insertions(+), 37 deletions(-) diff --git a/basemaps.config.js b/basemaps.config.js index 68336682c..717d97901 100644 --- a/basemaps.config.js +++ b/basemaps.config.js @@ -6,6 +6,7 @@ const WMS = 'TileWMS'; const XYZ = 'XYZ'; // All options (except for 'is') follow the OpenLayers options for the respective source class. +// Projections (except for EPSG:3857 and EPSG:4326) must be listed in the `crs` array in the config.js. const BASEMAPS = { earth: [ { @@ -22,7 +23,7 @@ const BASEMAPS = { is: WMS, title: 'USGS Europa', attributions: USGS_ATTRIBUTION, - projection: "EPSG:4326", + projection: 'EPSG:4326', params: { FORMAT: 'image/png', LAYERS: 'GALILEO_VOYAGER' @@ -35,7 +36,7 @@ const BASEMAPS = { is: WMS, title: 'USGS Mars', attributions: USGS_ATTRIBUTION, - projection: "EPSG:4326", + projection: 'EPSG:4326', params: { FORMAT: 'image/png', LAYERS: 'MDIM21' @@ -48,7 +49,7 @@ const BASEMAPS = { is: WMS, title: 'USGS Moon', attributions: USGS_ATTRIBUTION, - projection: "EPSG:4326", + projection: 'EPSG:4326', params: { FORMAT: 'image/png', LAYERS: 'LROC_WAC' diff --git a/config.js b/config.js index 6112b7d1e..e5c561490 100644 --- a/config.js +++ b/config.js @@ -46,5 +46,6 @@ module.exports = { requestQueryParameters: {}, socialSharing: ['email', 'bsky', 'mastodon', 'x'], preprocessSTAC: null, - authConfig: null + authConfig: null, + crs: {} }; diff --git a/config.schema.json b/config.schema.json index 283cfbaf4..1716a0919 100644 --- a/config.schema.json +++ b/config.schema.json @@ -231,6 +231,11 @@ "$ref": "https://stac-extensions.github.io/authentication/v1.1.0/schema.json" } ] + }, + "crs": { + "type": [ + "object" + ] } } } diff --git a/docs/options.md b/docs/options.md index c3cc7771a..90d20512b 100644 --- a/docs/options.md +++ b/docs/options.md @@ -45,6 +45,7 @@ The following ways to set config options are possible: - [buildTileUrlTemplate](#buildtileurltemplate) - [useTileLayerAsFallback](#usetilelayerasfallback) - [displayGeoTiffByDefault](#displaygeotiffbydefault) + - [crs](#crs) - [User Interface](#user-interface) - [itemsPerPage](#itemsperpage) - [maxItemsPerPage](#maxitemsperpage) @@ -373,6 +374,23 @@ To clarify the behavior, please have a look at the following table: If set to `true`, the map also shows non-cloud-optimized GeoTiff files by default. Otherwise (`false`, default), it only shows COGs and you can only enforce showing GeoTiffs to be loaded with the "Show on map" button but they are never loaded automatically. Loading non-cloud-optimized GeoTiffs only works reliably for smaller files (< 1MB). It may also work for larger files, but it is depending a lot on the underlying client hardware and software. +### crs + +An object of coordinate reference systems that the system needs to know. +The key is the code for the CRS, the value is the CRS definition as OGC WKT string (WKT2 is not supported). +`EPSG:3857` (Web Mercator) and `EPSG:4326` (WGS 84) don't need to be registered, they are included by default. + +This is primarily useful for CRS that are used for the basemaps (see `basemaps.config.js`). +All CRS not listed here will be requested from an external service over HTTP, which is slower. + +Example for EPSG:2056: + +```js +{ + 'EPSG:2056': 'PROJCS["CH1903+ / LV95",GEOGCS["CH1903+",DATUM["CH1903+",SPHEROID["Bessel 1841",6377397.155,299.1528128,AUTHORITY["EPSG","7004"]],AUTHORITY["EPSG","6150"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.0174532925199433,AUTHORITY["EPSG","9122"]],AUTHORITY["EPSG","4150"]],PROJECTION["Hotine_Oblique_Mercator_Azimuth_Center"],PARAMETER["latitude_of_center",46.9524055555556],PARAMETER["longitude_of_center",7.43958333333333],PARAMETER["azimuth",90],PARAMETER["rectified_grid_angle",90],PARAMETER["scale_factor",1],PARAMETER["false_easting",2600000],PARAMETER["false_northing",1200000],UNIT["metre",1,AUTHORITY["EPSG","9001"]],AXIS["Easting",EAST],AXIS["Northing",NORTH],AUTHORITY["EPSG","2056"]]' +} +``` + ## User Interface ### itemsPerPage diff --git a/src/components/Map.vue b/src/components/Map.vue index 442a610ce..460cb9704 100644 --- a/src/components/Map.vue +++ b/src/components/Map.vue @@ -27,14 +27,10 @@ import LayerControl from './maps/LayerControl.vue'; import TextControl from './maps/TextControl.vue'; import { mapGetters } from 'vuex'; import { BPopover } from 'bootstrap-vue'; -import proj4 from 'proj4'; import Select from 'ol/interaction/Select'; -import {register} from 'ol/proj/proj4.js'; import StacLayer from 'ol-stac'; import { getStacObjectsForEvent, getStyle } from 'ol-stac/util.js'; -register(proj4); // required to support source reprojection - const selectStyle = getStyle('#ff0000', 2, null); export default { diff --git a/src/components/maps/LayerControl.vue b/src/components/maps/LayerControl.vue index 792aa6bab..f8a88a378 100644 --- a/src/components/maps/LayerControl.vue +++ b/src/components/maps/LayerControl.vue @@ -6,10 +6,6 @@ :target="id" container="#stac-browser" >
-
-
{{ $t('mapping.layers.title') }}
- -
{{ $t('mapping.layers.base') }}
{{ $t('mapping.nobasemap') }} @@ -19,17 +15,23 @@
+
+
{{ $t('mapping.layers.title') }}
+ +