Add support for DigitalGlobe imagery vintage overlays

(see https://github.com/osmlab/editor-layer-index/issues/371)
This commit is contained in:
Bryan Housel
2017-11-01 13:46:13 -04:00
parent 475db33b3f
commit a0a197a69e
8 changed files with 200 additions and 1166 deletions
+2 -2
View File
@@ -47,7 +47,7 @@ export function rendererBackground(context) {
var b = background.baseLayerSource(),
o = overlayLayers
.filter(function (d) { return !d.source().isLocatorOverlay(); })
.filter(function (d) { return !d.source().isLocatorOverlay() && !d.source().isHidden(); })
.map(function (d) { return d.source().id; })
.join(','),
meters = geoOffsetToMeters(b.offset()),
@@ -86,7 +86,7 @@ export function rendererBackground(context) {
var imageryUsed = [b.imageryUsed()];
overlayLayers
.filter(function (d) { return !d.source().isLocatorOverlay(); })
.filter(function (d) { return !d.source().isLocatorOverlay() && !d.source().isHidden(); })
.forEach(function (d) { imageryUsed.push(d.source().imageryUsed()); });
var gpx = context.layers().layer('gpx');
+7
View File
@@ -133,6 +133,13 @@ export function rendererBackgroundSource(data) {
};
/* hides a source from the list, but leaves it available for use */
source.isHidden = function() {
return source.id === 'DigitalGlobe-Premium-vintage' ||
source.id === 'DigitalGlobe-Standard-vintage';
};
source.copyrightNotices = function() {};
+2 -2
View File
@@ -206,8 +206,8 @@ export function uiBackground(context) {
function update() {
backgroundList.call(drawList, 'radio', clickSetSource, function(d) { return !d.overlay; });
overlayList.call(drawList, 'checkbox', clickSetOverlay, function(d) { return d.overlay; });
backgroundList.call(drawList, 'radio', clickSetSource, function(d) { return !d.isHidden() && !d.overlay; });
overlayList.call(drawList, 'checkbox', clickSetOverlay, function(d) { return !d.isHidden() && d.overlay; });
selectLayer();
updateOffsetVal();
+38 -4
View File
@@ -20,8 +20,11 @@ export function uiPanelBackground(context) {
var debouncedRedraw = _debounce(redraw, 250);
function redraw(selection) {
if (currSourceName !== background.baseLayerSource().name()) {
currSourceName = background.baseLayerSource().name();
var source = background.baseLayerSource(),
isDG = (source.id.match(/^DigitalGlobe/i) !== null);
if (currSourceName !== source.name()) {
currSourceName = source.name();
metadata = {};
}
@@ -36,6 +39,9 @@ export function uiPanelBackground(context) {
.text(currSourceName);
metadataKeys.forEach(function(k) {
// DigitalGlobe vintage is available in raster layers for now.
if (isDG && k === 'vintage') return;
list
.append('li')
.attr('class', 'background-info-list-' + k)
@@ -48,11 +54,11 @@ export function uiPanelBackground(context) {
debouncedGetMetadata(selection);
var toggle = context.getDebug('tile') ? 'hide_tiles' : 'show_tiles';
var toggleTiles = context.getDebug('tile') ? 'hide_tiles' : 'show_tiles';
selection
.append('a')
.text(t('info_panels.background.' + toggle))
.text(t('info_panels.background.' + toggleTiles))
.attr('href', '#')
.attr('class', 'button button-toggle-tiles')
.on('click', function() {
@@ -60,6 +66,34 @@ export function uiPanelBackground(context) {
context.setDebug('tile', !context.getDebug('tile'));
selection.call(redraw);
});
if (isDG) {
var key = source.id + '-vintage';
var sourceVintage = context.background().findSource(key);
var showsVintage = context.background().showsLayer(sourceVintage);
var toggleVintage = showsVintage ? 'hide_vintage' : 'show_vintage';
selection
.append('a')
.text(t('info_panels.background.' + toggleVintage))
.attr('href', '#')
.attr('class', 'button button-toggle-vintage')
.on('click', function() {
d3_event.preventDefault();
context.background().toggleOverlayLayer(sourceVintage);
selection.call(redraw);
});
}
// disable if necessary
['DigitalGlobe-Premium', 'DigitalGlobe-Standard'].forEach(function(layerId) {
if (source.id !== layerId) {
var key = layerId + '-vintage';
var sourceVintage = context.background().findSource(key);
if (context.background().showsLayer(sourceVintage)) {
context.background().toggleOverlayLayer(sourceVintage);
}
}
});
}