mirror of
https://github.com/FoggedLens/iD.git
synced 2026-02-12 16:52:50 +00:00
Apply photo date and username filters to Mapillary sign and object detections (close #8133)
Don't update disabled SVG layers upon photo changes
This commit is contained in:
@@ -162,8 +162,11 @@ function loadNextTilePage(which, currZoom, url, tile) {
|
||||
loc: loc,
|
||||
key: feature.properties.key,
|
||||
value: feature.properties.value,
|
||||
package: feature.properties.package,
|
||||
detections: feature.properties.detections
|
||||
detections: feature.properties.detections,
|
||||
direction: feature.properties.direction,
|
||||
accuracy: feature.properties.accuracy,
|
||||
first_seen_at: feature.properties.first_seen_at,
|
||||
last_seen_at: feature.properties.last_seen_at
|
||||
};
|
||||
}
|
||||
|
||||
@@ -226,7 +229,6 @@ function loadData(which, url) {
|
||||
key: feature.properties.key,
|
||||
image_key: feature.properties.image_key,
|
||||
value: feature.properties.value,
|
||||
package: feature.properties.package,
|
||||
shape: feature.properties.shape
|
||||
};
|
||||
|
||||
|
||||
@@ -109,7 +109,6 @@ export function svgMapillaryImages(projection, context, dispatch) {
|
||||
return t;
|
||||
}
|
||||
|
||||
context.photos().on('change.mapillary_images', update);
|
||||
|
||||
function filterImages(images) {
|
||||
var showsPano = context.photos().showsPanoramic();
|
||||
@@ -327,8 +326,10 @@ export function svgMapillaryImages(projection, context, dispatch) {
|
||||
svgMapillaryImages.enabled = _;
|
||||
if (svgMapillaryImages.enabled) {
|
||||
showLayer();
|
||||
context.photos().on('change.mapillary_images', update);
|
||||
} else {
|
||||
hideLayer();
|
||||
context.photos().on('change.mapillary_images', null);
|
||||
}
|
||||
dispatch.call('change');
|
||||
return this;
|
||||
|
||||
@@ -89,9 +89,43 @@ export function svgMapillaryMapFeatures(projection, context, dispatch) {
|
||||
}
|
||||
|
||||
|
||||
function filterData(detectedFeatures) {
|
||||
var service = getService();
|
||||
|
||||
var fromDate = context.photos().fromDate();
|
||||
var toDate = context.photos().toDate();
|
||||
var usernames = context.photos().usernames();
|
||||
|
||||
if (fromDate) {
|
||||
var fromTimestamp = new Date(fromDate).getTime();
|
||||
detectedFeatures = detectedFeatures.filter(function(feature) {
|
||||
return new Date(feature.last_seen_at).getTime() >= fromTimestamp;
|
||||
});
|
||||
}
|
||||
if (toDate) {
|
||||
var toTimestamp = new Date(toDate).getTime();
|
||||
detectedFeatures = detectedFeatures.filter(function(feature) {
|
||||
return new Date(feature.first_seen_at).getTime() <= toTimestamp;
|
||||
});
|
||||
}
|
||||
if (usernames && service) {
|
||||
detectedFeatures = detectedFeatures.filter(function(feature) {
|
||||
return feature.detections.some(function(detection) {
|
||||
var imageKey = detection.image_key;
|
||||
var image = service.cachedImage(imageKey);
|
||||
return usernames.indexOf(image.captured_by) !== -1;
|
||||
});
|
||||
});
|
||||
}
|
||||
return detectedFeatures;
|
||||
}
|
||||
|
||||
|
||||
function update() {
|
||||
var service = getService();
|
||||
var data = (service ? service.mapFeatures(projection) : []);
|
||||
data = filterData(data);
|
||||
|
||||
var selectedImageKey = service && service.getSelectedImageKey();
|
||||
var transform = svgPointTransform(projection);
|
||||
|
||||
@@ -198,8 +232,10 @@ export function svgMapillaryMapFeatures(projection, context, dispatch) {
|
||||
svgMapillaryMapFeatures.enabled = _;
|
||||
if (svgMapillaryMapFeatures.enabled) {
|
||||
showLayer();
|
||||
context.photos().on('change.mapillary_map_features', update);
|
||||
} else {
|
||||
hideLayer();
|
||||
context.photos().on('change.mapillary_map_features', null);
|
||||
}
|
||||
dispatch.call('change');
|
||||
return this;
|
||||
|
||||
@@ -90,9 +90,43 @@ export function svgMapillarySigns(projection, context, dispatch) {
|
||||
}
|
||||
|
||||
|
||||
function filterData(detectedFeatures) {
|
||||
var service = getService();
|
||||
|
||||
var fromDate = context.photos().fromDate();
|
||||
var toDate = context.photos().toDate();
|
||||
var usernames = context.photos().usernames();
|
||||
|
||||
if (fromDate) {
|
||||
var fromTimestamp = new Date(fromDate).getTime();
|
||||
detectedFeatures = detectedFeatures.filter(function(feature) {
|
||||
return new Date(feature.last_seen_at).getTime() >= fromTimestamp;
|
||||
});
|
||||
}
|
||||
if (toDate) {
|
||||
var toTimestamp = new Date(toDate).getTime();
|
||||
detectedFeatures = detectedFeatures.filter(function(feature) {
|
||||
return new Date(feature.first_seen_at).getTime() <= toTimestamp;
|
||||
});
|
||||
}
|
||||
if (usernames && service) {
|
||||
detectedFeatures = detectedFeatures.filter(function(feature) {
|
||||
return feature.detections.some(function(detection) {
|
||||
var imageKey = detection.image_key;
|
||||
var image = service.cachedImage(imageKey);
|
||||
return usernames.indexOf(image.captured_by) !== -1;
|
||||
});
|
||||
});
|
||||
}
|
||||
return detectedFeatures;
|
||||
}
|
||||
|
||||
|
||||
function update() {
|
||||
var service = getService();
|
||||
var data = (service ? service.signs(projection) : []);
|
||||
data = filterData(data);
|
||||
|
||||
var selectedImageKey = service.getSelectedImageKey();
|
||||
var transform = svgPointTransform(projection);
|
||||
|
||||
@@ -186,8 +220,10 @@ export function svgMapillarySigns(projection, context, dispatch) {
|
||||
svgMapillarySigns.enabled = _;
|
||||
if (svgMapillarySigns.enabled) {
|
||||
showLayer();
|
||||
context.photos().on('change.mapillary_signs', update);
|
||||
} else {
|
||||
hideLayer();
|
||||
context.photos().on('change.mapillary_signs', null);
|
||||
}
|
||||
dispatch.call('change');
|
||||
return this;
|
||||
|
||||
@@ -105,8 +105,6 @@ export function svgOpenstreetcamImages(projection, context, dispatch) {
|
||||
}
|
||||
|
||||
|
||||
context.photos().on('change.openstreetcam_images', update);
|
||||
|
||||
function filterImages(images) {
|
||||
var fromDate = context.photos().fromDate();
|
||||
var toDate = context.photos().toDate();
|
||||
@@ -289,8 +287,10 @@ export function svgOpenstreetcamImages(projection, context, dispatch) {
|
||||
svgOpenstreetcamImages.enabled = _;
|
||||
if (svgOpenstreetcamImages.enabled) {
|
||||
showLayer();
|
||||
context.photos().on('change.openstreetcam_images', update);
|
||||
} else {
|
||||
hideLayer();
|
||||
context.photos().on('change.openstreetcam_images', null);
|
||||
}
|
||||
dispatch.call('change');
|
||||
return this;
|
||||
|
||||
@@ -157,8 +157,6 @@ export function svgStreetside(projection, context, dispatch) {
|
||||
}
|
||||
|
||||
|
||||
context.photos().on('change.streetside', update);
|
||||
|
||||
function filterBubbles(bubbles) {
|
||||
var fromDate = context.photos().fromDate();
|
||||
var toDate = context.photos().toDate();
|
||||
@@ -365,8 +363,10 @@ export function svgStreetside(projection, context, dispatch) {
|
||||
svgStreetside.enabled = _;
|
||||
if (svgStreetside.enabled) {
|
||||
showLayer();
|
||||
context.photos().on('change.streetside', update);
|
||||
} else {
|
||||
hideLayer();
|
||||
context.photos().on('change.streetside', null);
|
||||
}
|
||||
dispatch.call('change');
|
||||
return this;
|
||||
|
||||
Reference in New Issue
Block a user