Skip to content

Commit

Permalink
Add support for DigitalGlobe imagery vintage overlays
Browse files Browse the repository at this point in the history
  • Loading branch information
bhousel committed Nov 1, 2017
1 parent 475db33 commit a0a197a
Show file tree
Hide file tree
Showing 8 changed files with 200 additions and 1,166 deletions.
5 changes: 5 additions & 0 deletions css/80_app.css
Original file line number Diff line number Diff line change
Expand Up @@ -2951,8 +2951,13 @@ img.tile-removing {
border-radius: 2px;
padding: 0 4px;
margin-top: 10px;
margin-right: 10px;
color: white;
}
[dir='rtl'] .panel-content .button {
margin-right: auto;
margin-left: 10px;
}

.panel-content-history .links a {
margin-left: 10px;
Expand Down
2 changes: 2 additions & 0 deletions data/core.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,8 @@ en:
unknown: Unknown
show_tiles: Show Tiles
hide_tiles: Hide Tiles
show_vintage: Show Vintage
hide_vintage: Hide Vintage
history:
key: H
title: History
Expand Down
1,284 changes: 127 additions & 1,157 deletions data/imagery.json

Large diffs are not rendered by default.

18 changes: 17 additions & 1 deletion dist/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,9 @@
"accuracy": "Accuracy",
"unknown": "Unknown",
"show_tiles": "Show Tiles",
"hide_tiles": "Hide Tiles"
"hide_tiles": "Hide Tiles",
"show_vintage": "Show Vintage",
"hide_vintage": "Hide Vintage"
},
"history": {
"key": "H",
Expand Down Expand Up @@ -5828,13 +5830,27 @@
"description": "Premium DigitalGlobe satellite imagery.",
"name": "DigitalGlobe Premium Imagery"
},
"DigitalGlobe-Premium-vintage": {
"attribution": {
"text": "Terms & Feedback"
},
"description": "Imagery boundaries and capture dates. Labels appear at zoom level 14 and higher.",
"name": "DigitalGlobe Premium Imagery Vintage"
},
"DigitalGlobe-Standard": {
"attribution": {
"text": "Terms & Feedback"
},
"description": "Standard DigitalGlobe satellite imagery.",
"name": "DigitalGlobe Standard Imagery"
},
"DigitalGlobe-Standard-vintage": {
"attribution": {
"text": "Terms & Feedback"
},
"description": "Imagery boundaries and capture dates. Labels appear at zoom level 14 and higher.",
"name": "DigitalGlobe Standard Imagery Vintage"
},
"EsriWorldImagery": {
"attribution": {
"text": "Terms & Feedback"
Expand Down
4 changes: 2 additions & 2 deletions modules/renderer/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()),
Expand Down Expand Up @@ -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');
Expand Down
7 changes: 7 additions & 0 deletions modules/renderer/background_source.js
Original file line number Diff line number Diff line change
Expand Up @@ -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() {};


Expand Down
4 changes: 2 additions & 2 deletions modules/ui/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
42 changes: 38 additions & 4 deletions modules/ui/panels/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {};
}

Expand All @@ -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)
Expand All @@ -48,18 +54,46 @@ 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() {
d3_event.preventDefault();
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);
}
}
});
}


Expand Down

0 comments on commit a0a197a

Please sign in to comment.