mirror of
https://github.com/FoggedLens/iD.git
synced 2026-05-15 05:30:35 +02:00
Add photo overlays used during editing to the "source" changeset tag (close #6279)
This commit is contained in:
@@ -18,6 +18,7 @@ export function coreHistory(context) {
|
||||
var lock = utilSessionMutex('lock');
|
||||
var duration = 150;
|
||||
var _imageryUsed = [];
|
||||
var _photoOverlaysUsed = [];
|
||||
var _checkpoints = {};
|
||||
var _pausedGraph;
|
||||
var _stack;
|
||||
@@ -43,6 +44,7 @@ export function coreHistory(context) {
|
||||
graph: graph,
|
||||
annotation: annotation,
|
||||
imageryUsed: _imageryUsed,
|
||||
photoOverlaysUsed: _photoOverlaysUsed,
|
||||
transform: context.projection.transform(),
|
||||
selectedIDs: context.selectedIDs()
|
||||
};
|
||||
@@ -314,6 +316,22 @@ export function coreHistory(context) {
|
||||
},
|
||||
|
||||
|
||||
photoOverlaysUsed: function(sources) {
|
||||
if (sources) {
|
||||
_photoOverlaysUsed = sources;
|
||||
return history;
|
||||
} else {
|
||||
var s = new Set();
|
||||
_stack.slice(1, _index + 1).forEach(function(state) {
|
||||
state.photoOverlaysUsed.forEach(function(photoOverlay) {
|
||||
s.add(photoOverlay);
|
||||
});
|
||||
});
|
||||
return Array.from(s);
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
// save the current history state
|
||||
checkpoint: function(key) {
|
||||
_checkpoints[key] = {
|
||||
@@ -468,6 +486,7 @@ export function coreHistory(context) {
|
||||
if (modified.length) x.modified = modified;
|
||||
if (deleted.length) x.deleted = deleted;
|
||||
if (i.imageryUsed) x.imageryUsed = i.imageryUsed;
|
||||
if (i.photoOverlaysUsed) x.photoOverlaysUsed = i.photoOverlaysUsed;
|
||||
if (i.annotation) x.annotation = i.annotation;
|
||||
if (i.transform) x.transform = i.transform;
|
||||
if (i.selectedIDs) x.selectedIDs = i.selectedIDs;
|
||||
@@ -580,6 +599,7 @@ export function coreHistory(context) {
|
||||
graph: coreGraph(_stack[0].graph).load(entities),
|
||||
annotation: d.annotation,
|
||||
imageryUsed: d.imageryUsed,
|
||||
photoOverlaysUsed: d.photoOverlaysUsed,
|
||||
transform: d.transform,
|
||||
selectedIDs: d.selectedIDs
|
||||
};
|
||||
|
||||
@@ -175,6 +175,7 @@ export function rendererBackground(context) {
|
||||
}
|
||||
|
||||
var imageryUsed = [];
|
||||
var photoOverlaysUsed = [];
|
||||
|
||||
var current = b.imageryUsed();
|
||||
if (current && _isValid) {
|
||||
@@ -190,26 +191,22 @@ export function rendererBackground(context) {
|
||||
imageryUsed.push(data.getSrc());
|
||||
}
|
||||
|
||||
var streetside = context.layers().layer('streetside');
|
||||
if (streetside && streetside.enabled()) {
|
||||
imageryUsed.push('Bing Streetside');
|
||||
}
|
||||
|
||||
var mapillary_images = context.layers().layer('mapillary');
|
||||
if (mapillary_images && mapillary_images.enabled()) {
|
||||
imageryUsed.push('Mapillary Images');
|
||||
}
|
||||
|
||||
var mapillary_signs = context.layers().layer('mapillary-signs');
|
||||
if (mapillary_signs && mapillary_signs.enabled()) {
|
||||
imageryUsed.push('Mapillary Signs');
|
||||
}
|
||||
|
||||
var openstreetcam_images = context.layers().layer('openstreetcam');
|
||||
if (openstreetcam_images && openstreetcam_images.enabled()) {
|
||||
imageryUsed.push('OpenStreetCam Images');
|
||||
var photoOverlayLayers = {
|
||||
streetside: 'Bing Streetside',
|
||||
mapillary: 'Mapillary Images',
|
||||
'mapillary-signs': 'Mapillary Signs',
|
||||
openstreetcam: 'OpenStreetCam Images'
|
||||
};
|
||||
|
||||
for (var layerID in photoOverlayLayers) {
|
||||
var layer = context.layers().layer(layerID);
|
||||
if (layer && layer.enabled()) {
|
||||
photoOverlaysUsed.push(layerID);
|
||||
imageryUsed.push(photoOverlayLayers[layerID]);
|
||||
}
|
||||
}
|
||||
|
||||
context.history().photoOverlaysUsed(photoOverlaysUsed);
|
||||
context.history().imageryUsed(imageryUsed);
|
||||
};
|
||||
|
||||
|
||||
@@ -86,6 +86,23 @@ export function uiCommit(context) {
|
||||
if (source) {
|
||||
tags.source = source;
|
||||
}
|
||||
var existingSources = (tags.source || '').split(';');
|
||||
// add the photo overlays used during editing as sources
|
||||
var photoOverlaysUsed = context.history().photoOverlaysUsed();
|
||||
if (photoOverlaysUsed.length) {
|
||||
// include this tag for any photo layer
|
||||
if (existingSources.indexOf('streetlevel imagery') === -1) {
|
||||
existingSources.push('streetlevel imagery');
|
||||
}
|
||||
}
|
||||
photoOverlaysUsed.forEach(function(photoOverlay) {
|
||||
if (existingSources.indexOf(photoOverlay) === -1) {
|
||||
existingSources.push(photoOverlay);
|
||||
}
|
||||
});
|
||||
if (existingSources.length) {
|
||||
tags.source = existingSources.join(';').substr(0, 255);
|
||||
}
|
||||
|
||||
_changeset = new osmChangeset({ tags: tags });
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user