From b14f69ceb87c4f410d1139d8acb91d324c3fa2e2 Mon Sep 17 00:00:00 2001 From: David Manthey Date: Wed, 21 Feb 2018 09:57:06 -0500 Subject: [PATCH] Use https for references to openstreetmap.org. Recently, all http requests get a 307 response to forward them to the https server. It is more efficient to access the https server directly. OSM has been running https servers for several years now (at least since 2014), so this should be as stable as OSM is in general. I haven't figured out how to proxy https requests to karma. Perhaps we'd have to run karma in https mode, but my first foray into that didn't work. For now, the one test (the lines example) just uses the http openstreetmap.org reference in the test. --- examples/geoJSON/main.js | 4 ++-- examples/lines/main.js | 2 +- examples/osm/main.js | 4 ++-- examples/reprojection/index.pug | 6 +++--- examples/reprojection/main.js | 2 +- examples/tiles/index.pug | 6 +++--- examples/tiles/main.js | 4 ++-- karma-base.js | 2 +- src/osmLayer.js | 2 +- tests/headed-cases/lines.js | 3 ++- tutorials/tile_source/index.pug | 6 +++--- 11 files changed, 21 insertions(+), 20 deletions(-) diff --git a/examples/geoJSON/main.js b/examples/geoJSON/main.js index e624d8765d..43cac8ccfe 100644 --- a/examples/geoJSON/main.js +++ b/examples/geoJSON/main.js @@ -19,8 +19,8 @@ $(function () { url: 'http://tile.stamen.com/toner-lite/{z}/{x}/{y}.png', attribution: ['Map tiles by Stamen Design,', 'under CC BY 3.0.', - 'Data by OpenStreetMap, under', - 'ODbL.' + 'Data by OpenStreetMap, under', + 'ODbL.' ].join(' ') } ); diff --git a/examples/lines/main.js b/examples/lines/main.js index eddcde5c4b..9cae11654f 100644 --- a/examples/lines/main.js +++ b/examples/lines/main.js @@ -330,7 +330,7 @@ $(function () { } // Create a tile layer - osm = map.createLayer('osm'); + osm = map.createLayer('osm', {url: query.url || undefined}); set_osm_url(query.showmap); // Create a feature layer for the lines layer = map.createLayer('feature', layerOptions); diff --git a/examples/osm/main.js b/examples/osm/main.js index a6a2960897..78ad9c3c63 100644 --- a/examples/osm/main.js +++ b/examples/osm/main.js @@ -19,8 +19,8 @@ $(function () { url: 'http://tile.stamen.com/toner-lite/{z}/{x}/{y}.png', attribution: ['Map tiles by Stamen Design,', 'under CC BY 3.0.', - 'Data by OpenStreetMap, under', - 'ODbL.' + 'Data by OpenStreetMap, under', + 'ODbL.' ].join(' ') } ); diff --git a/examples/reprojection/index.pug b/examples/reprojection/index.pug index c9a9d9639c..73510810b2 100644 --- a/examples/reprojection/index.pug +++ b/examples/reprojection/index.pug @@ -4,10 +4,10 @@ block append mainContent #controls .form-group(title="The url used to fetch tiles. Use {x}, {y}, {z}, and {s} for templating.") label(for="layer-url") Tile URL - select#layer-url.layerparam(param-name="url", list="url-list", placeholder="http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png") - option(value="http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png", credit="© OpenStreetMap contributors") OpenStreetMap + select#layer-url.layerparam(param-name="url", list="url-list", placeholder="https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png") + option(value="https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png", credit="© OpenStreetMap contributors") OpenStreetMap option(value="../../data/tilefancy.png", credit="") Fancy Test Tile - option(value="http://tile.stamen.com/toner-lite/{z}/{x}/{y}.png", credit='Map tiles by Stamen Design, under CC BY 3.0. Data by OpenStreetMap, under ODbL.') Toner Lite + option(value="http://tile.stamen.com/toner-lite/{z}/{x}/{y}.png", credit='Map tiles by Stamen Design, under CC BY 3.0. Data by OpenStreetMap, under ODbL.') Toner Lite .form-group(title="Web maps are most often rendered using a Mercator geographic coordinate system, but other projections can be used. See spatialreference.org for more information on projections.") label(for="map-gcs") Map GCS select#map-gcs.mapparam(param-name="gcs", placeholder="EPSG:3857 - Web Mercator", reload="true") diff --git a/examples/reprojection/main.js b/examples/reprojection/main.js index b3c3cba10e..ebe82c5c9d 100644 --- a/examples/reprojection/main.js +++ b/examples/reprojection/main.js @@ -140,7 +140,7 @@ $(function () { if (query.url) { layerParams.url = query.url; } else { - layerParams.url = 'http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png'; + layerParams.url = 'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png'; } // Create a map object var map = geo.map(mapParams); diff --git a/examples/tiles/index.pug b/examples/tiles/index.pug index 2912f71ddb..a0de4d3d67 100644 --- a/examples/tiles/index.pug +++ b/examples/tiles/index.pug @@ -56,11 +56,11 @@ block append mainContent .form-group(title="The url used to fetch tiles. Use {x}, {y}, {z}, and {s} for templating.") label(for="layer-url") Tile URL - input#layer-url.layerparam(param-name="url", list="url-list", placeholder="http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png") + input#layer-url.layerparam(param-name="url", list="url-list", placeholder="https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png") datalist#url-list - option(value="http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png", credit="© OpenStreetMap contributors") OSM + option(value="https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png", credit="© OpenStreetMap contributors") OSM option(value="../../data/tilefancy.png", credit="") Fancy Test Tile - option(value="http://tile.stamen.com/toner-lite/{z}/{x}/{y}.png", credit='Map tiles by Stamen Design, under CC BY 3.0. Data by OpenStreetMap, under ODbL.') Toner Lite + option(value="http://tile.stamen.com/toner-lite/{z}/{x}/{y}.png", credit='Map tiles by Stamen Design, under CC BY 3.0. Data by OpenStreetMap, under ODbL.') Toner Lite .form-group(title="The subdomains used to fetch tiles. This can be a comma-separated list or a string of single-letter subdomains.") label(for="layer-subdomains") URL Subdomains input#layer-subdomains.layerparam(param-name="subdomains", placeholder="abc") diff --git a/examples/tiles/main.js b/examples/tiles/main.js index cb1cb11c69..f242505340 100644 --- a/examples/tiles/main.js +++ b/examples/tiles/main.js @@ -36,7 +36,7 @@ * is used by itself (e.g., 'abc' is the same as 'a,b,c'). * unitsPerPixel: set the units per pixel at zoom level 0. * url: url to use for the map files. Placeholders are allowed. Default is - * http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png . Other useful + * https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png . Other useful * urls are are: /data/tilefancy.png * http://tile.stamen.com/toner-lite/{z}/{x}/{y}.png * w: width of a tiled image (at max zoom). If w and h are specified, a @@ -122,7 +122,7 @@ $(function () { if (query.url) { layerParams.url = query.url; } else { - layerParams.url = 'http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png'; + layerParams.url = 'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png'; } if (query.subdomains) { if (query.subdomains.indexOf(',') >= 0) { diff --git a/karma-base.js b/karma-base.js index 15e73bf581..f0f90ad93b 100644 --- a/karma-base.js +++ b/karma-base.js @@ -189,7 +189,7 @@ var notes_middleware = function (config) { */ var osmtiles_middleware = function (config) { return function (request, response, next) { - var match = request.url.match(/.*http:\/\/[a-c]\.tile.openstreetmap.org\/([0-9]+\/[0-9]+\/[0-9]+.png)$/); + var match = request.url.match(/.*https?:\/\/[a-c]\.tile.openstreetmap.org\/([0-9]+\/[0-9]+\/[0-9]+.png)$/); /* Serve tiles if they have been proxied */ if (match && request.method === 'GET') { var imagePath = 'dist/data/tiles/' + match[1]; diff --git a/src/osmLayer.js b/src/osmLayer.js index b5f2d9f22b..0cb5cbc1f8 100644 --- a/src/osmLayer.js +++ b/src/osmLayer.js @@ -77,7 +77,7 @@ module.exports = (function () { }, wrapX: true, wrapY: false, - url: 'http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', + url: 'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', attribution: 'Tile data © ' + 'OpenStreetMap contributors' }); diff --git a/tests/headed-cases/lines.js b/tests/headed-cases/lines.js index 7546cfe40d..17063f262f 100644 --- a/tests/headed-cases/lines.js +++ b/tests/headed-cases/lines.js @@ -9,7 +9,8 @@ describe('lines example', function () { }); it('basic', function (done) { - $('#map').attr('src', '/examples/lines/index.html'); + // use an http url for the map so we can proxy it for the test + $('#map').attr('src', '/examples/lines/index.html?url=http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png'); imageTest.imageTest('exampleLines', '#map', 0.0015, done, null, 0, 2, '#map.ready'); }, 10000); it('more lines', function (done) { diff --git a/tutorials/tile_source/index.pug b/tutorials/tile_source/index.pug index 90607223da..85cf532ed7 100644 --- a/tutorials/tile_source/index.pug +++ b/tutorials/tile_source/index.pug @@ -24,8 +24,8 @@ block mainTutorial layer.attribution( 'Map tiles by Stamen Design, ' + 'under CC BY 3.0. ' + - 'Data by OpenStreetMap, ' + - 'under ODbL.') + 'Data by OpenStreetMap, ' + + 'under ODbL.') +codeblock_test('url is from stamen.com', 'layer.url().match(/stamen/)' ) @@ -39,7 +39,7 @@ block mainTutorial }); var layer = map.createLayer('osm', { url: 'http://tile.stamen.com/toner-lite/{z}/{x}/{y}.png', - attribution: 'Map tiles by Stamen Design, under CC BY 3.0. Data by OpenStreetMap, under ODbL.' + attribution: 'Map tiles by Stamen Design, under CC BY 3.0. Data by OpenStreetMap, under ODbL.' }); +codeblock_test('map has one osm layer from stamen', [ 'map.layers().length === 1',