Skip to content

Commit

Permalink
Use https for references to openstreetmap.org.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
manthey committed Mar 7, 2018
1 parent 825206e commit b14f69c
Show file tree
Hide file tree
Showing 11 changed files with 21 additions and 20 deletions.
4 changes: 2 additions & 2 deletions examples/geoJSON/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ $(function () {
url: 'http://tile.stamen.com/toner-lite/{z}/{x}/{y}.png',
attribution: ['Map tiles by <a href="http://stamen.com">Stamen Design</a>,',
'under <a href="http://creativecommons.org/licenses/by/3.0">CC BY 3.0</a>.',
'Data by <a href="http://openstreetmap.org">OpenStreetMap</a>, under',
'<a href="http://www.openstreetmap.org/copyright">ODbL</a>.'
'Data by <a href="https://openstreetmap.org">OpenStreetMap</a>, under',
'<a href="https://openstreetmap.org/copyright">ODbL</a>.'
].join(' ')
}
);
Expand Down
2 changes: 1 addition & 1 deletion examples/lines/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions examples/osm/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ $(function () {
url: 'http://tile.stamen.com/toner-lite/{z}/{x}/{y}.png',
attribution: ['Map tiles by <a href="http://stamen.com">Stamen Design</a>,',
'under <a href="http://creativecommons.org/licenses/by/3.0">CC BY 3.0</a>.',
'Data by <a href="http://openstreetmap.org">OpenStreetMap</a>, under',
'<a href="http://www.openstreetmap.org/copyright">ODbL</a>.'
'Data by <a href="https://openstreetmap.org">OpenStreetMap</a>, under',
'<a href="https://openstreetmap.org/copyright">ODbL</a>.'
].join(' ')
}
);
Expand Down
6 changes: 3 additions & 3 deletions examples/reprojection/index.pug
Original file line number Diff line number Diff line change
Expand Up @@ -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 <a href="http://stamen.com">Stamen Design</a>, under <a href="http://creativecommons.org/licenses/by/3.0">CC BY 3.0</a>. Data by <a href="http://openstreetmap.org">OpenStreetMap</a>, under <a href="http://www.openstreetmap.org/copyright">ODbL</a>.') Toner Lite
option(value="http://tile.stamen.com/toner-lite/{z}/{x}/{y}.png", credit='Map tiles by <a href="http://stamen.com">Stamen Design</a>, under <a href="http://creativecommons.org/licenses/by/3.0">CC BY 3.0</a>. Data by <a href="https://openstreetmap.org">OpenStreetMap</a>, under <a href="https://openstreetmap.org/copyright">ODbL</a>.') 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")
Expand Down
2 changes: 1 addition & 1 deletion examples/reprojection/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
6 changes: 3 additions & 3 deletions examples/tiles/index.pug
Original file line number Diff line number Diff line change
Expand Up @@ -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 <a href="http://stamen.com">Stamen Design</a>, under <a href="http://creativecommons.org/licenses/by/3.0">CC BY 3.0</a>. Data by <a href="http://openstreetmap.org">OpenStreetMap</a>, under <a href="http://www.openstreetmap.org/copyright">ODbL</a>.') Toner Lite
option(value="http://tile.stamen.com/toner-lite/{z}/{x}/{y}.png", credit='Map tiles by <a href="http://stamen.com">Stamen Design</a>, under <a href="http://creativecommons.org/licenses/by/3.0">CC BY 3.0</a>. Data by <a href="https://openstreetmap.org">OpenStreetMap</a>, under <a href="https://openstreetmap.org/copyright">ODbL</a>.') 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")
Expand Down
4 changes: 2 additions & 2 deletions examples/tiles/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion karma-base.js
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down
2 changes: 1 addition & 1 deletion src/osmLayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 &copy; <a href="http://osm.org/copyright">' +
'OpenStreetMap</a> contributors'
});
Expand Down
3 changes: 2 additions & 1 deletion tests/headed-cases/lines.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
6 changes: 3 additions & 3 deletions tutorials/tile_source/index.pug
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ block mainTutorial
layer.attribution(
'Map tiles by <a href="http://stamen.com">Stamen Design</a>, ' +
'under <a href="http://creativecommons.org/licenses/by/3.0">CC BY 3.0</a>. ' +
'Data by <a href="http://openstreetmap.org">OpenStreetMap</a>, ' +
'under <a href="http://www.openstreetmap.org/copyright">ODbL</a>.')
'Data by <a href="https://openstreetmap.org">OpenStreetMap</a>, ' +
'under <a href="https://openstreetmap.org/copyright">ODbL</a>.')
+codeblock_test('url is from stamen.com',
'layer.url().match(/stamen/)'
)
Expand All @@ -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 <a href="http://stamen.com">Stamen Design</a>, under <a href="http://creativecommons.org/licenses/by/3.0">CC BY 3.0</a>. Data by <a href="http://openstreetmap.org">OpenStreetMap</a>, under <a href="http://www.openstreetmap.org/copyright">ODbL</a>.'
attribution: 'Map tiles by <a href="http://stamen.com">Stamen Design</a>, under <a href="http://creativecommons.org/licenses/by/3.0">CC BY 3.0</a>. Data by <a href="https://openstreetmap.org">OpenStreetMap</a>, under <a href="https://openstreetmap.org/copyright">ODbL</a>.'
});
+codeblock_test('map has one osm layer from stamen', [
'map.layers().length === 1',
Expand Down

0 comments on commit b14f69c

Please sign in to comment.