diff --git a/data/core.yaml b/data/core.yaml index 435a08fba..82df21868 100644 --- a/data/core.yaml +++ b/data/core.yaml @@ -279,6 +279,9 @@ en: zoom: Zoom vintage: Vintage source: Source + description: Description + resolution: Resolution + accuracy: Accuracy unknown: Unknown show_tiles: Show Tiles hide_tiles: Hide Tiles diff --git a/modules/renderer/background_source.js b/modules/renderer/background_source.js index 6a4bcb2f1..1a0814f21 100644 --- a/modules/renderer/background_source.js +++ b/modules/renderer/background_source.js @@ -133,7 +133,7 @@ export function rendererBackgroundSource(data) { source.copyrightNotices = function() {}; - source.getVintage = function(center, tileCoord, callback) { + source.getMetadata = function(center, tileCoord, callback) { var vintage = { start: localeDateString(source.startDate), end: localeDateString(source.endDate) @@ -190,7 +190,7 @@ rendererBackgroundSource.Bing = function(data, dispatch) { }; - bing.getVintage = function(center, tileCoord, callback) { + bing.getMetadata = function(center, tileCoord, callback) { var tileId = tileCoord.slice(0, 3).join('/'), zoom = Math.min(tileCoord[2], 21), centerPoint = center[1] + ',' + center[0], // lat,lng @@ -240,7 +240,7 @@ rendererBackgroundSource.Esri = function(data) { var esri = rendererBackgroundSource(data), cache = {}; - esri.getVintage = function(center, tileCoord, callback) { + esri.getMetadata = function(center, tileCoord, callback) { var tileId = tileCoord.slice(0, 3).join('/'), zoom = Math.min(tileCoord[2], esri.scaleExtent[1]), centerPoint = center[0] + ',' + center[1], // long, lat (as it should be) @@ -268,9 +268,15 @@ rendererBackgroundSource.Esri = function(data) { return callback(null, cache[tileId].vintage); } - // accurate metadata is only available at zoom 13 and closer + // accurate metadata is only available >= 13 if (metadataLayer === 99) { - callback(null, { range: '', source: ' '}); + callback(null, { + range: 'Unknown', + source: 'Unknown', + description: 'Unknown', + resolution: 'Unknown', + accuracy: 'Unknown' + }); } else { jsonpRequest(url, function(result) { var err = !result || result.features.length < 1; @@ -280,9 +286,13 @@ rendererBackgroundSource.Esri = function(data) { var vintage = { // pass through the discrete capture date from metadata range: localeDateString(result.features[0].attributes.SRC_DATE2), - source: result.features[0].attributes.NICE_DESC + source: result.features[0].attributes.NICE_NAME, + description: result.features[0].attributes.NICE_DESC, + resolution: result.features[0].attributes.SRC_RES, + accuracy: result.features[0].attributes.SRC_ACC, + }; - + cache[tileId].vintage = vintage; return callback(null, vintage); } diff --git a/modules/renderer/tile_layer.js b/modules/renderer/tile_layer.js index 4a1735fa4..1e9927be2 100644 --- a/modules/renderer/tile_layer.js +++ b/modules/renderer/tile_layer.js @@ -255,7 +255,7 @@ export function rendererTileLayer(context) { .each(function(d) { var span = d3.select(this); var center = context.projection.invert(tileCenter(d)); - source.getVintage(center, d, function(err, result) { + source.getMetadata(center, d, function(err, result) { span.text((result && result.range) || t('info_panels.background.vintage') + ': ' + t('info_panels.background.unknown') ); diff --git a/modules/ui/panels/background.js b/modules/ui/panels/background.js index 9b5f6d303..393e5e8f4 100644 --- a/modules/ui/panels/background.js +++ b/modules/ui/panels/background.js @@ -8,7 +8,11 @@ export function uiPanelBackground(context) { var currSource = null; var currZoom = ''; var currVintage = ''; - var currEsriSource = ''; + + var currProvider = ''; + var currDescription = ''; + var currResolution = ''; + var currAccuracy = ''; function redraw(selection) { if (currSource !== background.baseLayerSource().name()) { @@ -42,7 +46,7 @@ export function uiPanelBackground(context) { .text(currVintage); if (!currVintage) { - debouncedGetVintage(selection); + debouncedGetMetadata(selection); } if (currSource === 'Esri World Imagery') { @@ -51,7 +55,25 @@ export function uiPanelBackground(context) { .text(t('info_panels.background.source') + ': ') .append('span') .attr('class', 'source') - .text(currEsriSource); + .text(currProvider); + list + .append('li') + .text(t('info_panels.background.description') + ': ') + .append('span') + .attr('class', 'description') + .text(currDescription); + list + .append('li') + .text(t('info_panels.background.resolution') + ': ') + .append('span') + .attr('class', 'resolution') + .text(currResolution); + list + .append('li') + .text(t('info_panels.background.accuracy') + ': ') + .append('span') + .attr('class', 'accuracy') + .text(currAccuracy); } var toggle = context.getDebug('tile') ? 'hide_tiles' : 'show_tiles'; @@ -68,8 +90,8 @@ export function uiPanelBackground(context) { } - var debouncedGetVintage = _.debounce(getVintage, 250); - function getVintage(selection) { + var debouncedGetMetadata = _.debounce(getMetadata, 250); + function getMetadata(selection) { var tile = d3.select('.layer-background img.tile-center'); // tile near viewport center if (tile.empty()) return; @@ -82,15 +104,24 @@ export function uiPanelBackground(context) { .text(currZoom); if (!d || !d.length >= 3) return; - background.baseLayerSource().getVintage(center, d, function(err, result) { + background.baseLayerSource().getMetadata(center, d, function(err, result) { currVintage = (result && result.range) || t('info_panels.background.unknown'); selection.selectAll('.vintage') .text(currVintage); // metadata from Esri can tell us the specific provider if (result.source) { - currEsriSource = result.source; + currSource = result.source; selection.selectAll('.source') - .text(currEsriSource); + .text(currSource); + currDescription = result.description; + selection.selectAll('.description') + .text(currDescription); + currResolution = result.resolution; + selection.selectAll('.resolution') + .text(currResolution + ' (m)'); + currAccuracy = result.accuracy; + selection.selectAll('.accuracy') + .text(currAccuracy + ' (m)'); } }); } @@ -104,7 +135,7 @@ export function uiPanelBackground(context) { selection.call(redraw); }) .on('move.info-background', function() { - selection.call(debouncedGetVintage); + selection.call(debouncedGetMetadata); }); }; diff --git a/modules/ui/status.js b/modules/ui/status.js index d9ba2bd0e..9d9dbc3e2 100644 --- a/modules/ui/status.js +++ b/modules/ui/status.js @@ -29,6 +29,7 @@ export function uiStatus(context) { osm.authenticate(); }); } else { + // eslint-disable-next-line no-warning-comments // TODO: nice messages for different error types selection.text(t('status.error')); } diff --git a/test/spec/spec_helpers.js b/test/spec/spec_helpers.js index 50fba97a4..083969397 100644 --- a/test/spec/spec_helpers.js +++ b/test/spec/spec_helpers.js @@ -20,4 +20,5 @@ mocha.setup({ }); expect = chai.expect; -var d3 = iD.d3; +// eslint-disable-next-line no-unused-vars +var d3 = iD.d3; \ No newline at end of file