Skip to content

ol-stac migration #531 #535

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 15 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 11 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,8 @@ If you need even more flexibility, you need to dig into the Vue files and their
### Basemaps

The file `basemaps.config.js` contains the configuration for the basemaps.
You can update either just the `BASEMAPS` object or you can write a custom function `configureBasemap` that returns the desired options for [vue2-leaflet](https://vue2-leaflet.netlify.app/).
[XYZ](https://vue2-leaflet.netlify.app/components/LTileLayer.html#props) and [WMS](https://vue2-leaflet.netlify.app/components/LWMSTileLayer.html#props) basemaps are supported and have different options that you can set.
You can update either just the `BASEMAPS` object or you can write a custom function `configureBasemap` that returns the desired options for OpenLayers.
XYZ, WMTS and WMS basemaps are supported and have different options that you can set.

### Actions

Expand Down
107 changes: 61 additions & 46 deletions basemaps.config.js
Original file line number Diff line number Diff line change
@@ -1,62 +1,69 @@
import { CRS } from 'leaflet';
import STAC from './src/models/stac';
import Utils from './src/utils';

const USGS_ATTRIBUTION = 'USGS Astrogeology';
const WMS = 'LWMSTileLayer';
const XYZ = 'LTileLayer';
const WMS = 'TileWMS';
const XYZ = 'XYZ';

// All options (except for 'is') follow the OpenLayers options for the respective source class.
const BASEMAPS = {
earth: {
url: 'https://tile.openstreetmap.org/{z}/{x}/{y}.png',
name: 'OpenStreetMap',
is: XYZ,
attribution: '&copy; <a href="https://www.openstreetmap.org/copyright" target="_blank">OpenStreetMap</a> contributors.'
},
europa: {
baseUrl: 'https://planetarymaps.usgs.gov/cgi-bin/mapserv?map=/maps/jupiter/europa_simp_cyl.map',
is: WMS,
name: 'USGS Europa',
attribution: USGS_ATTRIBUTION,
crs: CRS.EPSG4326,
format: 'image/png',
layers: 'GALILEO_VOYAGER'
},
mars: {
baseUrl: 'https://planetarymaps.usgs.gov/cgi-bin/mapserv?map=/maps/mars/mars_simp_cyl.map',
is: WMS,
name: 'USGS Mars',
attribution: USGS_ATTRIBUTION,
crs: CRS.EPSG4326,
format: 'image/png',
layers: 'MDIM21'
},
moon: {
baseUrl: 'https://planetarymaps.usgs.gov/cgi-bin/mapserv?map=/maps/earth/moon_simp_cyl.map',
is: WMS,
name: 'USGS Moon',
attribution: USGS_ATTRIBUTION,
crs: CRS.EPSG4326,
format: 'image/png',
layers: 'LROC_WAC'
}
earth: [
{
url: 'https://tile.openstreetmap.org/{z}/{x}/{y}.png',
is: XYZ,
title: 'OpenStreetMap',
attributions: '&copy; <a href="https://www.openstreetmap.org/copyright" target="_blank">OpenStreetMap</a> contributors.',
projection: "EPSG:3857"
}
],
europa: [
{
url: 'https://planetarymaps.usgs.gov/cgi-bin/mapserv?map=/maps/jupiter/europa_simp_cyl.map',
is: WMS,
title: 'USGS Europa',
attributions: USGS_ATTRIBUTION,
projection: "EPSG:4326",
params: {
FORMAT: 'image/png',
LAYERS: 'GALILEO_VOYAGER'
}
},
],
mars: [
{
url: 'https://planetarymaps.usgs.gov/cgi-bin/mapserv?map=/maps/mars/mars_simp_cyl.map',
is: WMS,
title: 'USGS Mars',
attributions: USGS_ATTRIBUTION,
projection: "EPSG:4326",
params: {
FORMAT: 'image/png',
LAYERS: 'MDIM21'
}
}
],
moon: [
{
url: 'https://planetarymaps.usgs.gov/cgi-bin/mapserv?map=/maps/earth/moon_simp_cyl.map',
is: WMS,
title: 'USGS Moon',
attributions: USGS_ATTRIBUTION,
projection: "EPSG:4326",
params: {
FORMAT: 'image/png',
LAYERS: 'LROC_WAC'
}
}
],
};

/**
* @typedef BasemapOptions
* @type {Object}
* @property {string} is Component: LWMSTileLayer or LTileLayer
* @see https://vue2-leaflet.netlify.app/components/
*/

/**
*
* @param {Object} stac The STAC object
* @param {Object} map The Leaflet map object
* @param {Object} i18n Vue I18N object
* @returns {Array.<BasemapOptions>}
*/
export default function configureBasemap(stac, map, i18n) {
export default function configureBasemap(stac, i18n) {
let targets = ['earth'];
if (stac instanceof STAC) {
if (stac.isCollection() && Utils.isObject(stac.summaries) && Array.isArray(stac.summaries['ssys:targets'])) {
Expand All @@ -70,5 +77,13 @@ export default function configureBasemap(stac, map, i18n) {
}
}

return targets.map(target => BASEMAPS[target.toLowerCase()]);
let layers = [];
for (const target of targets) {
const maps = BASEMAPS[target.toLowerCase()];
if (!Array.isArray(maps)) {
continue;
}
layers = layers.concat(maps);
}
return layers;
};
6 changes: 2 additions & 4 deletions config.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ module.exports = {
// "pt-BR"
],
apiCatalogPriority: null,
useTileLayerAsFallback: true,
useTileLayerAsFallback: false,
displayGeoTiffByDefault: false,
buildTileUrlTemplate: ({href, asset}) => "https://tiles.rdnt.io/tiles/{z}/{x}/{y}@2x?url=" + encodeURIComponent(href),
buildTileUrlTemplate: null,
stacProxyUrl: null,
pathPrefix: "/",
historyMode: "history",
Expand All @@ -36,12 +36,10 @@ module.exports = {
showKeywordsInItemCards: false,
showKeywordsInCatalogCards: false,
showThumbnailsAsAssets: false,
geoTiffResolution: 128,
redirectLegacyUrls: false,
itemsPerPage: 12,
maxItemsPerPage: 1000,
defaultThumbnailSize: null,
maxPreviewsOnMap: 50,
crossOriginMedia: null,
requestHeaders: {},
requestQueryParameters: {},
Expand Down
12 changes: 0 additions & 12 deletions config.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -152,12 +152,6 @@
"boolean"
]
},
"geoTiffResolution": {
"type": [
"integer"
],
"minimum": 1
},
"redirectLegacyUrls": {
"type": [
"boolean"
Expand Down Expand Up @@ -188,12 +182,6 @@
]
}
},
"maxPreviewsOnMap": {
"type": [
"integer"
],
"minimum": 1
},
"crossOriginMedia": {
"type": [
"string",
Expand Down
Loading