mirror of
https://github.com/FoggedLens/iD.git
synced 2026-05-16 05:49:16 +02:00
display additional metadata from Esri World Imagery
* getVintage() becomes getMetadata() * ignore a couple unrelated lint nags * add source description, resolution and accuracy info to debug panel
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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')
|
||||
);
|
||||
|
||||
@@ -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);
|
||||
});
|
||||
|
||||
};
|
||||
|
||||
@@ -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'));
|
||||
}
|
||||
|
||||
@@ -20,4 +20,5 @@ mocha.setup({
|
||||
});
|
||||
|
||||
expect = chai.expect;
|
||||
var d3 = iD.d3;
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
var d3 = iD.d3;
|
||||
Reference in New Issue
Block a user