Skip to content

Commit

Permalink
Remove GDAL VFS specifics #544 (#545)
Browse files Browse the repository at this point in the history
  • Loading branch information
m-mohr authored Jan 26, 2025
1 parent 90c53d5 commit eddcc2c
Show file tree
Hide file tree
Showing 14 changed files with 8 additions and 71 deletions.
2 changes: 1 addition & 1 deletion config.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ module.exports = {
apiCatalogPriority: null,
useTileLayerAsFallback: true,
displayGeoTiffByDefault: false,
buildTileUrlTemplate: ({href, asset}) => "https://tiles.rdnt.io/tiles/{z}/{x}/{y}@2x?url=" + encodeURIComponent(asset.href.startsWith("/vsi") ? asset.href : href),
buildTileUrlTemplate: ({href, asset}) => "https://tiles.rdnt.io/tiles/{z}/{x}/{y}@2x?url=" + encodeURIComponent(href),
stacProxyUrl: null,
pathPrefix: "/",
historyMode: "history",
Expand Down
28 changes: 5 additions & 23 deletions src/components/HrefActions.vue
Original file line number Diff line number Diff line change
Expand Up @@ -119,10 +119,6 @@ export default {
else if (this.tileRendererType === 'server' && imageMediaTypes.includes(this.data?.type)) {
return true;
}
// Don't pass GDAL VFS URIs to client-side tile renderer: https://github.com/radiantearth/stac-browser/issues/116
else if (this.isGdalVfs && this.tileRendererType === 'client') {
return false;
}
// Only http(s) links and relative links are supported
else if (!this.isBrowserProtocol) {
return false;
Expand Down Expand Up @@ -193,7 +189,7 @@ export default {
return null;
},
isBrowserProtocol() {
return (!this.protocol && !this.isGdalVfs) || browserProtocols.includes(this.protocol);
return !this.protocol || browserProtocols.includes(this.protocol);
},
isThumbnail() {
if (this.isAsset) {
Expand All @@ -203,9 +199,6 @@ export default {
return this.data.rel === 'preview' && Utils.canBrowserDisplayImage(this.data);
}
},
isGdalVfs() {
return Utils.isGdalVfsUri(this.href);
},
href() {
if (typeof this.data.href !== 'string') {
return null;
Expand All @@ -224,16 +217,10 @@ export default {
return URI(this.href);
},
from() {
if (this.isGdalVfs) {
let type = this.href.match(/^\/vsi([a-z\d]+)(_streaming)?\//);
return this.protocolName(type);
}
else {
return this.protocolName(this.protocol);
}
return this.protocolName(this.protocol);
},
browserCanOpenFile() {
if (this.isGdalVfs || this.useAltDownloadMethod) {
if (this.useAltDownloadMethod) {
return false;
}
if (Utils.canBrowserDisplayImage(this.data)) {
Expand All @@ -258,9 +245,8 @@ export default {
return this.$t(`assets.download.${where}`, {source: this.from});
},
copyButtonText() {
let what = this.isGdalVfs ? 'copyGdalVfsUrl' : 'copyUrl';
let where = (!this.isBrowserProtocol && this.from) ? 'withSource' : 'generic';
return this.$t(`assets.${what}.${where}`, {source: this.from});
return this.$t(`assets.copyUrl.${where}`, {source: this.from});
}
},
methods: {
Expand Down Expand Up @@ -379,11 +365,7 @@ export default {
return '';
},
show() {
let data = Object.assign({}, this.data);
// Override asset href with absolute URL if not a GDAL VFS
if (!this.isGdalVfs) {
data.href = this.href;
}
let data = Object.assign({}, this.data, {href: this.href});
this.$emit('show', data, this.id, this.isThumbnail);
},
handleAuthButton() {
Expand Down
4 changes: 0 additions & 4 deletions src/locales/de/texts.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,6 @@
"alternate": {
"main": "Bevorzugt"
},
"copyGdalVfsUrl": {
"generic": "Kopiere GDAL VFS Adresse",
"withSource": "Kopiere GDAL VFS Adresse für {source}"
},
"copyUrl": {
"generic": "Kopiere Adresse",
"withSource": "Kopiere Adresse für {source}"
Expand Down
1 change: 0 additions & 1 deletion src/locales/en-GB/texts.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
},
"assets": {
"alternate": {},
"copyGdalVfsUrl": {},
"copyUrl": {},
"download": {},
"role": {}
Expand Down
2 changes: 1 addition & 1 deletion src/locales/en/fields.json
Original file line number Diff line number Diff line change
Expand Up @@ -536,4 +536,4 @@
"°E": "°E",
"°N": "°N",
"μm": "μm"
}
}
4 changes: 0 additions & 4 deletions src/locales/en/texts.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,6 @@
"alternate": {
"main": "Preferred"
},
"copyGdalVfsUrl": {
"generic": "Copy GDAL VFS URL",
"withSource": "Copy GDAL VFS URL for {source}"
},
"copyUrl": {
"generic": "Copy URL",
"withSource": "Copy URL for {source}"
Expand Down
4 changes: 0 additions & 4 deletions src/locales/es/texts.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,6 @@
"alternate": {
"main": "Preferido"
},
"copyGdalVfsUrl": {
"generic": "Copiar la URL del VFS de GDAL",
"withSource": "Copiar la URL del VFS de GDAL para {source}"
},
"copyUrl": {
"generic": "Copiar la URL",
"withSource": "Copiar la URL para {source}"
Expand Down
4 changes: 0 additions & 4 deletions src/locales/fr/texts.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,6 @@
"alternate": {
"main": "Préféré"
},
"copyGdalVfsUrl": {
"generic": "Copier le lien du GDAL VFS",
"withSource": "Copier le lien du GDAL VFS de {source}"
},
"copyUrl": {
"generic": "Copier le lien",
"withSource": "Copier le lien de {source}"
Expand Down
4 changes: 0 additions & 4 deletions src/locales/it/texts.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,6 @@
"alternate": {
"main": "Preferito"
},
"copyGdalVfsUrl": {
"generic": "Copia l'URL del VFS GDAL",
"withSource": "Copia l'URL del VFS GDAL per {source}"
},
"copyUrl": {
"generic": "Copia l'URL",
"withSource": "Copia l'URL per {source}"
Expand Down
3 changes: 0 additions & 3 deletions src/locales/ja/texts.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@
"alternate": {
"main": "推奨"
},
"copyGdalVfsUrl": {
"generic": "GDAL VFS URLをコピー"
},
"copyUrl": {
"generic": "URLをコピー",
"withSource": "{source} のURLをコピー"
Expand Down
4 changes: 0 additions & 4 deletions src/locales/pt-BR/texts.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,6 @@
"alternate": {
"main": "Preferido"
},
"copyGdalVfsUrl": {
"generic": "Copiar URL GDAL VFS",
"withSource": "Copiar URL GDAL VFS para {source}"
},
"copyUrl": {
"generic": "Copiar URL",
"withSource": "Copiar URL para {source}"
Expand Down
4 changes: 0 additions & 4 deletions src/locales/pt/texts.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,6 @@
"alternate": {
"main": "Preferido"
},
"copyGdalVfsUrl": {
"generic": "Copiar URL GDAL VFS",
"withSource": "Copiar URL GDAL VFS para {source}"
},
"copyUrl": {
"generic": "Copiar URL",
"withSource": "Copiar URL para {source}"
Expand Down
4 changes: 0 additions & 4 deletions src/locales/ro/texts.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,6 @@
"alternate": {
"main": "Preferat"
},
"copyGdalVfsUrl": {
"generic": "Copiați link-ul GDAL VFS",
"withSource": "Copiați link-ul GDAL VFS al {source}"
},
"copyUrl": {
"generic": "Copiați link-ul",
"withSource": "Copiați link-ul al {source}"
Expand Down
11 changes: 1 addition & 10 deletions src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,23 +131,14 @@ export default class Utils {
fullStr.substr(fullStr.length - backChars);
}

static isGdalVfsUri(url) {
return typeof url === 'string' && url.startsWith('/vsi') && !url.startsWith('/vsicurl/');
}

static toAbsolute(href, baseUrl, stringify = true) {
return Utils.normalizeUri(href, baseUrl, false, stringify);
}

static normalizeUri(href, baseUrl = null, noParams = false, stringify = true) {
// Convert vsicurl URLs to normal URLs
if (typeof href === 'string' && href.startsWith('/vsicurl/')) {
href = href.replace(/^\/vsicurl\//, '');
}
// Parse URL and make absolute, if required
let uri = URI(href);
// Don't convert GDAL VFS URIs: https://github.com/radiantearth/stac-browser/issues/116
if (baseUrl && uri.is("relative") && !Utils.isGdalVfsUri(href)) {
if (baseUrl && uri.is("relative")) {
uri = uri.absoluteTo(baseUrl);
}
uri.normalize();
Expand Down

0 comments on commit eddcc2c

Please sign in to comment.