diff --git a/modules/services/mapillary.js b/modules/services/mapillary.js index c140dacf9..c6866dd08 100644 --- a/modules/services/mapillary.js +++ b/modules/services/mapillary.js @@ -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 }; diff --git a/modules/svg/mapillary_images.js b/modules/svg/mapillary_images.js index 19792db63..41f0eac0f 100644 --- a/modules/svg/mapillary_images.js +++ b/modules/svg/mapillary_images.js @@ -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; diff --git a/modules/svg/mapillary_map_features.js b/modules/svg/mapillary_map_features.js index 814e8a742..c6ef91442 100644 --- a/modules/svg/mapillary_map_features.js +++ b/modules/svg/mapillary_map_features.js @@ -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; diff --git a/modules/svg/mapillary_signs.js b/modules/svg/mapillary_signs.js index b2cf6da89..4e3906b11 100644 --- a/modules/svg/mapillary_signs.js +++ b/modules/svg/mapillary_signs.js @@ -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; diff --git a/modules/svg/openstreetcam_images.js b/modules/svg/openstreetcam_images.js index 786ac4a79..e0a96667f 100644 --- a/modules/svg/openstreetcam_images.js +++ b/modules/svg/openstreetcam_images.js @@ -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; diff --git a/modules/svg/streetside.js b/modules/svg/streetside.js index ab1bc4a15..36649189f 100644 --- a/modules/svg/streetside.js +++ b/modules/svg/streetside.js @@ -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;