mirror of
https://github.com/FoggedLens/iD.git
synced 2026-04-21 19:26:41 +02:00
feat: filter sequences from openstreetcam and streetside
This commit is contained in:
@@ -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) {
|
||||
|
||||
@@ -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
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
@@ -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)
|
||||
};
|
||||
|
||||
|
||||
@@ -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; });
|
||||
|
||||
|
||||
@@ -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; });
|
||||
|
||||
|
||||
Reference in New Issue
Block a user