OSGeo / gdal

GDAL is an open source MIT licensed translator library for raster and vector geospatial data formats.
https://gdal.org
Other
4.9k stars 2.55k forks source link

gdal2tiles.py, openlayers.html broken because of dead CDN links #8325

Closed velle closed 1 year ago

velle commented 1 year ago

Expected behavior and actual behavior.

gdal2tiles.py creates a folder with tiles, and with a few different webviewers (LeafLet, Google Maps and OpenLayers). The resulting openlayers.html does not work; instead giving various javascript errors.

Steps to reproduce the problem.

Here is what I tried:

Run on any tif:

$ gdal2tiles.py input.tif tilefolder

Go to tilefolder and open openlayers.html in browser (I used Chromium)

Dead link issue

First of all it seems like it tries to import OpenLayers from dead links.

<!-- DEAD -->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/openlayers/openlayers.github.io@master/en/v6.3.1/css/ol.css" type="text/css">
<script src="https://cdn.jsdelivr.net/gh/openlayers/openlayers.github.io@master/en/v6.3.1/build/ol.js"></script>

Those links give HTTP 403, with the following error message:

Package size exceeded the configured limit of 50 MB. Try https://github.com/openlayers/openlayers.github.io/tree/master/en/v6.3.1/css/ol.css instead.

The github link suggested in the error message requires authentication. I tried with more recent versions of OpenLayers, like 8.0.0, but that caused other JavaScript errors.

Workaround, use version 6.5.0:

<!-- DOES THE JOB FOR ME-->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/openlayers/openlayers.github.io@master/en/v6.5.0/css/ol.css" type="text/css">
<script src="https://cdn.jsdelivr.net/gh/openlayers/openlayers.github.io@master/en/v6.5.0/build/ol.js"></script>

System

Ubuntu 22.04.3 64 bit GDAL 3.4.1, released 2021/12/27 (installed via apt) Chromium Version 116.0.5845.110 (Official Build) snap (64-bit)

jratike80 commented 1 year ago

The current version https://github.com/OSGeo/gdal/blob/master/swig/python/gdal-utils/osgeo_utils/gdal2tiles.py is using

<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/openlayers/openlayers.github.io@main/dist/en/v7.0.0/legacy/ol.css" type="text/css">
    <script src="https://cdn.jsdelivr.net/gh/openlayers/openlayers.github.io@main/dist/en/v7.0.0/legacy/ol.js"></script>

The OpenLayers client that GDAL 3.7.1 creates works for me. GDAL project supports only the newest version so backport to 3.4.1 is not expected. Updating GDAL is the preferred action but your own fix is also good. Alternatively you can get the new gdal2tiles.py from the link above and try if it works well with your GDAL 3.4.1. That is not at all impossible.