feat: filter sequences from openstreetcam and streetside

This commit is contained in:
Nikola Plesa
2020-07-24 17:13:18 +02:00
parent d7aa6f920b
commit 8a5002aa15
5 changed files with 80 additions and 13 deletions
+1 -1
View File
@@ -75,7 +75,7 @@ export function rendererPhotos(context) {
};
photos.shouldFilterByUsername = function() {
return showsLayer('mapillary') || showsLayer('openstreetcam');
return showsLayer('mapillary') || showsLayer('openstreetcam') || showsLayer('streetside');
};
photos.showsPhotoType = function(val) {
+6 -1
View File
@@ -217,11 +217,16 @@ export default {
.forEach(function(sequenceKey) {
var seq = _oscCache.sequences[sequenceKey];
var images = seq && seq.images;
if (images) {
lineStrings.push({
type: 'LineString',
coordinates: images.map(function (d) { return d.loc; }).filter(Boolean),
properties: { key: sequenceKey }
properties: {
captured_at: images[0] ? images[0].captured_at: null,
captured_by: images[0] ? images[0].captured_by: null,
key: sequenceKey
}
});
}
});
+5 -1
View File
@@ -177,7 +177,11 @@ function connectSequences() {
// create a GeoJSON LineString
sequence.geojson = {
type: 'LineString',
properties: { key: sequence.key },
properties: {
captured_at: sequence.bubbles[0] ? sequence.bubbles[0].captured_at : null,
captured_by: sequence.bubbles[0] ? sequence.bubbles[0].captured_by : null,
key: sequence.key
},
coordinates: sequence.bubbles.map(d => d.loc)
};
+34 -8
View File
@@ -112,25 +112,51 @@ export function svgOpenstreetcamImages(projection, context, dispatch) {
if (fromDate) {
var fromTimestamp = new Date(fromDate).getTime();
images = images.filter(function(image) {
return new Date(image.captured_at).getTime() >= fromTimestamp;
images = images.filter(function(item) {
return new Date(item.captured_at).getTime() >= fromTimestamp;
});
}
if (toDate) {
var toTimestamp = new Date(toDate).getTime();
images = images.filter(function(image) {
return new Date(image.captured_at).getTime() <= toTimestamp;
images = images.filter(function(item) {
return new Date(item.captured_at).getTime() <= toTimestamp;
});
}
if (username) {
images = images.filter(function(image) {
return image.captured_by === username;
images = images.filter(function(item) {
return item.captured_by === username;
});
}
return images;
}
function filterSequences(sequences) {
var fromDate = context.photos().fromDate();
var toDate = context.photos().toDate();
var username = context.photos().username();
if (fromDate) {
var fromTimestamp = new Date(fromDate).getTime();
sequences = sequences.filter(function(image) {
return new Date(image.properties.captured_at).getTime() >= fromTimestamp;
});
}
if (toDate) {
var toTimestamp = new Date(toDate).getTime();
sequences = sequences.filter(function(image) {
return new Date(image.properties.captured_at).getTime() <= toTimestamp;
});
}
if (username) {
sequences = sequences.filter(function(image) {
return image.properties.captured_by === username;
});
}
return sequences;
}
function update() {
var viewer = context.container().select('.photoviewer');
var selected = viewer.empty() ? undefined : viewer.datum();
@@ -146,10 +172,10 @@ export function svgOpenstreetcamImages(projection, context, dispatch) {
if (context.photos().showsFlat()) {
sequences = (service ? service.sequences(projection) : []);
images = (service && showMarkers ? service.images(projection) : []);
sequences = filterSequences(sequences);
images = filterImages(images);
}
images = filterImages(images);
var traces = layer.selectAll('.sequences').selectAll('.sequence')
.data(sequences, function(d) { return d.properties.key; });
+34 -2
View File
@@ -162,6 +162,7 @@ export function svgStreetside(projection, context, dispatch) {
function filterBubbles(bubbles) {
var fromDate = context.photos().fromDate();
var toDate = context.photos().toDate();
var username = context.photos().username();
if (fromDate) {
var fromTimestamp = new Date(fromDate).getTime();
@@ -175,10 +176,41 @@ export function svgStreetside(projection, context, dispatch) {
return new Date(bubble.captured_at).getTime() <= toTimestamp;
});
}
if (username) {
bubbles = bubbles.filter(function(bubble) {
return bubble.captured_by === username;
});
}
return bubbles;
}
function filterSequences(sequences) {
var fromDate = context.photos().fromDate();
var toDate = context.photos().toDate();
var username = context.photos().username();
if (fromDate) {
var fromTimestamp = new Date(fromDate).getTime();
sequences = sequences.filter(function(sequences) {
return new Date(sequences.properties.captured_at).getTime() >= fromTimestamp;
});
}
if (toDate) {
var toTimestamp = new Date(toDate).getTime();
sequences = sequences.filter(function(sequences) {
return new Date(sequences.properties.captured_at).getTime() <= toTimestamp;
});
}
if (username) {
sequences = sequences.filter(function(sequences) {
return sequences.properties.captured_by === username;
});
}
return sequences;
}
/**
* update().
*/
@@ -196,10 +228,10 @@ export function svgStreetside(projection, context, dispatch) {
if (context.photos().showsPanoramic()) {
sequences = (service ? service.sequences(projection) : []);
bubbles = (service && showMarkers ? service.bubbles(projection) : []);
sequences = filterSequences(sequences);
bubbles = filterBubbles(bubbles);
}
bubbles = filterBubbles(bubbles);
var traces = layer.selectAll('.sequences').selectAll('.sequence')
.data(sequences, function(d) { return d.properties.key; });