Skip to content

Commit 34ee525

Browse files
authored
Merge pull request #535 from radiantearth/ol-stac
ol-stac and stac-js migration
2 parents 6927a15 + 71552f2 commit 34ee525

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+2602
-6347
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,8 +181,8 @@ If you need even more flexibility, you need to dig into the Vue files and their
181181
### Basemaps
182182

183183
The file `basemaps.config.js` contains the configuration for the basemaps.
184-
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/).
185-
[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.
184+
You can update either just the `BASEMAPS` object or you can write a custom function `configureBasemap` that returns the desired options for OpenLayers.
185+
XYZ, WMTS, and WMS basemaps are supported and have different options that you can set.
186186

187187
### Actions
188188

basemaps.config.js

Lines changed: 75 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -1,74 +1,91 @@
1-
import { CRS } from 'leaflet';
2-
import STAC from './src/models/stac';
1+
import { Collection, Item } from './src/models/stac';
32
import Utils from './src/utils';
43

54
const USGS_ATTRIBUTION = 'USGS Astrogeology';
6-
const WMS = 'LWMSTileLayer';
7-
const XYZ = 'LTileLayer';
5+
const WMS = 'TileWMS';
6+
const XYZ = 'XYZ';
87

8+
// All options (except for 'is') follow the OpenLayers options for the respective source class.
9+
// Projections (except for EPSG:3857 and EPSG:4326) must be listed in the `crs` array in the config.js.
10+
//
11+
// There's a layerCreated callback that can be used to modify the layer and source after it has been created:
12+
// async layerCreated(Layer layer, Source source) => Layer
913
const BASEMAPS = {
10-
earth: {
11-
url: 'https://tile.openstreetmap.org/{z}/{x}/{y}.png',
12-
name: 'OpenStreetMap',
13-
is: XYZ,
14-
attribution: '&copy; <a href="https://www.openstreetmap.org/copyright" target="_blank">OpenStreetMap</a> contributors.'
15-
},
16-
europa: {
17-
baseUrl: 'https://planetarymaps.usgs.gov/cgi-bin/mapserv?map=/maps/jupiter/europa_simp_cyl.map',
18-
is: WMS,
19-
name: 'USGS Europa',
20-
attribution: USGS_ATTRIBUTION,
21-
crs: CRS.EPSG4326,
22-
format: 'image/png',
23-
layers: 'GALILEO_VOYAGER'
24-
},
25-
mars: {
26-
baseUrl: 'https://planetarymaps.usgs.gov/cgi-bin/mapserv?map=/maps/mars/mars_simp_cyl.map',
27-
is: WMS,
28-
name: 'USGS Mars',
29-
attribution: USGS_ATTRIBUTION,
30-
crs: CRS.EPSG4326,
31-
format: 'image/png',
32-
layers: 'MDIM21'
33-
},
34-
moon: {
35-
baseUrl: 'https://planetarymaps.usgs.gov/cgi-bin/mapserv?map=/maps/earth/moon_simp_cyl.map',
36-
is: WMS,
37-
name: 'USGS Moon',
38-
attribution: USGS_ATTRIBUTION,
39-
crs: CRS.EPSG4326,
40-
format: 'image/png',
41-
layers: 'LROC_WAC'
42-
}
14+
earth: [
15+
{
16+
url: 'https://tile.openstreetmap.org/{z}/{x}/{y}.png',
17+
is: XYZ,
18+
title: 'OpenStreetMap',
19+
attributions: '&copy; <a href="https://www.openstreetmap.org/copyright" target="_blank">OpenStreetMap</a> contributors.',
20+
projection: "EPSG:3857"
21+
}
22+
],
23+
europa: [
24+
{
25+
url: 'https://planetarymaps.usgs.gov/cgi-bin/mapserv?map=/maps/jupiter/europa_simp_cyl.map',
26+
is: WMS,
27+
title: 'USGS Europa',
28+
attributions: USGS_ATTRIBUTION,
29+
projection: 'EPSG:4326',
30+
params: {
31+
FORMAT: 'image/png',
32+
LAYERS: 'GALILEO_VOYAGER'
33+
}
34+
},
35+
],
36+
mars: [
37+
{
38+
url: 'https://planetarymaps.usgs.gov/cgi-bin/mapserv?map=/maps/mars/mars_simp_cyl.map',
39+
is: WMS,
40+
title: 'USGS Mars',
41+
attributions: USGS_ATTRIBUTION,
42+
projection: 'EPSG:4326',
43+
params: {
44+
FORMAT: 'image/png',
45+
LAYERS: 'MDIM21'
46+
}
47+
}
48+
],
49+
moon: [
50+
{
51+
url: 'https://planetarymaps.usgs.gov/cgi-bin/mapserv?map=/maps/earth/moon_simp_cyl.map',
52+
is: WMS,
53+
title: 'USGS Moon',
54+
attributions: USGS_ATTRIBUTION,
55+
projection: 'EPSG:4326',
56+
params: {
57+
FORMAT: 'image/png',
58+
LAYERS: 'LROC_WAC'
59+
}
60+
}
61+
],
4362
};
4463

45-
/**
46-
* @typedef BasemapOptions
47-
* @type {Object}
48-
* @property {string} is Component: LWMSTileLayer or LTileLayer
49-
* @see https://vue2-leaflet.netlify.app/components/
50-
*/
51-
5264
/**
5365
*
5466
* @param {Object} stac The STAC object
55-
* @param {Object} map The Leaflet map object
5667
* @param {Object} i18n Vue I18N object
5768
* @returns {Array.<BasemapOptions>}
5869
*/
59-
export default function configureBasemap(stac, map, i18n) {
60-
let targets = ['earth'];
61-
if (stac instanceof STAC) {
62-
if (stac.isCollection() && Utils.isObject(stac.summaries) && Array.isArray(stac.summaries['ssys:targets'])) {
63-
targets = stac.summaries['ssys:targets'];
64-
}
65-
else if (stac.isCollection() && Array.isArray(stac['ssys:targets'])) {
66-
targets = stac['ssys:targets'];
67-
}
68-
else if (stac.isItem() && Array.isArray(stac.properties['ssys:targets'])) {
69-
targets = stac.properties['ssys:targets'];
70-
}
70+
export default function configureBasemap(stac, i18n) {
71+
let targets;
72+
if (stac instanceof Collection) {
73+
targets = stac.getSummary('ssys:targets');
74+
}
75+
if (!targets) {
76+
targets = stac.getMetadata('ssys:targets');
77+
}
78+
if (!targets) {
79+
targets = ['earth'];
7180
}
7281

73-
return targets.map(target => BASEMAPS[target.toLowerCase()]);
82+
let layers = [];
83+
for (const target of targets) {
84+
const maps = BASEMAPS[target.toLowerCase()];
85+
if (!Array.isArray(maps)) {
86+
continue;
87+
}
88+
layers = layers.concat(maps);
89+
}
90+
return layers;
7491
};

config.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ module.exports = {
2727
"id"
2828
],
2929
apiCatalogPriority: null,
30-
useTileLayerAsFallback: true,
30+
useTileLayerAsFallback: false,
3131
displayGeoTiffByDefault: false,
32-
buildTileUrlTemplate: ({href, asset}) => "https://tiles.rdnt.io/tiles/{z}/{x}/{y}@2x?url=" + encodeURIComponent(href),
32+
buildTileUrlTemplate: null,
3333
stacProxyUrl: null,
3434
pathPrefix: "/",
3535
historyMode: "history",
@@ -38,16 +38,15 @@ module.exports = {
3838
showKeywordsInItemCards: false,
3939
showKeywordsInCatalogCards: false,
4040
showThumbnailsAsAssets: false,
41-
geoTiffResolution: 128,
4241
redirectLegacyUrls: false,
4342
itemsPerPage: 12,
4443
maxItemsPerPage: 1000,
4544
defaultThumbnailSize: null,
46-
maxPreviewsOnMap: 50,
4745
crossOriginMedia: null,
4846
requestHeaders: {},
4947
requestQueryParameters: {},
5048
socialSharing: ['email', 'bsky', 'mastodon', 'x'],
5149
preprocessSTAC: null,
52-
authConfig: null
50+
authConfig: null,
51+
crs: {}
5352
};

config.schema.json

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -152,12 +152,6 @@
152152
"boolean"
153153
]
154154
},
155-
"geoTiffResolution": {
156-
"type": [
157-
"integer"
158-
],
159-
"minimum": 1
160-
},
161155
"redirectLegacyUrls": {
162156
"type": [
163157
"boolean"
@@ -188,12 +182,6 @@
188182
]
189183
}
190184
},
191-
"maxPreviewsOnMap": {
192-
"type": [
193-
"integer"
194-
],
195-
"minimum": 1
196-
},
197185
"crossOriginMedia": {
198186
"type": [
199187
"string",
@@ -243,6 +231,11 @@
243231
"$ref": "https://stac-extensions.github.io/authentication/v1.1.0/schema.json"
244232
}
245233
]
234+
},
235+
"crs": {
236+
"type": [
237+
"object"
238+
]
246239
}
247240
}
248241
}

0 commit comments

Comments
 (0)