diff --git a/modules/renderer/photos.js b/modules/renderer/photos.js index 4050ff42c..f2a8de21c 100644 --- a/modules/renderer/photos.js +++ b/modules/renderer/photos.js @@ -119,12 +119,12 @@ export function rendererPhotos(context) { } photos.shouldFilterByDate = function() { - return showsLayer('mapillary') || showsLayer('kartaview') || showsLayer('streetside') || showsLayer('vegbilder'); + return showsLayer('mapillary') || showsLayer('kartaview') || showsLayer('streetside') || showsLayer('vegbilder') || showsLayer('panoramax'); }; photos.shouldFilterByPhotoType = function() { return showsLayer('mapillary') || - (showsLayer('streetside') && showsLayer('kartaview')) || showsLayer('vegbilder'); + (showsLayer('streetside') && showsLayer('kartaview')) || showsLayer('vegbilder') || showsLayer('panoramax'); }; photos.shouldFilterByUsername = function() { diff --git a/modules/services/panoramax.js b/modules/services/panoramax.js index c2367591a..fb8637dd8 100644 --- a/modules/services/panoramax.js +++ b/modules/services/panoramax.js @@ -162,7 +162,7 @@ function loadTileDataToCache(data, tile) { sequence_id: feature.properties.sequences.split("\"")[1], heading: feature.properties.heading, resolution: feature.properties.resolution, - type: feature.properties.type, + isPano: feature.properties.type === "equirectangular", model: feature.properties.model, }; cache.forImageId[d.id] = d; @@ -317,7 +317,7 @@ export default { function viewfieldPath() { let d = this.parentNode.__data__; - if (d.type == "equirectangular" && d.id !== selectedImageId) { + if (d.isPano && d.id !== selectedImageId) { return 'M 8,13 m -10,0 a 10,10 0 1,0 20,0 a 10,10 0 1,0 -20,0'; } else { return 'M 6,9 C 8,8.4 8,8.4 10,9 L 16,-2 C 12,-5 4,-5 0,-2 z'; @@ -471,7 +471,7 @@ export default { .selectAll('button.forward') .classed('hide', _currentScene.nextImage == null); - if (d.type == "equirectangular") { + if (d.isPano) { _sceneOptions.type = "equirectangular"; if (!_pannellumViewer) { that.initViewer(); @@ -568,7 +568,7 @@ export default { // continue dispatching events for a few seconds, in case viewer has inertia. let t = d3_timer(elapsed => { dispatch.call('viewerChanged'); - if (elapsed > 2000) { + if (elapsed > 1000) { t.stop(); } }); diff --git a/modules/svg/panoramax_images.js b/modules/svg/panoramax_images.js index 5437242d8..ea0ab96cb 100644 --- a/modules/svg/panoramax_images.js +++ b/modules/svg/panoramax_images.js @@ -34,6 +34,57 @@ export function svgPanoramaxImages(projection, context, dispatch) { return _panoramax; } + function filterImages(images) { + const showsPano = context.photos().showsPanoramic(); + const showsFlat = context.photos().showsFlat(); + const fromDate = context.photos().fromDate(); + const toDate = context.photos().toDate(); + + if (!showsPano || !showsFlat) { + images = images.filter(function(image) { + if (image.isPano) return showsPano; + return showsFlat; + }); + } + if (fromDate) { + images = images.filter(function(image) { + return new Date(image.capture_time).getTime() >= new Date(fromDate).getTime(); + }); + } + if (toDate) { + images = images.filter(function(image) { + return new Date(image.capture_time).getTime() <= new Date(toDate).getTime(); + }); + } + + return images; + } + + function filterSequences(sequences) { + const showsPano = context.photos().showsPanoramic(); + const showsFlat = context.photos().showsFlat(); + const fromDate = context.photos().fromDate(); + const toDate = context.photos().toDate(); + + if (!showsPano || !showsFlat) { + sequences = sequences.filter(function(sequence) { + if (sequence.properties.type === "equirectangular") return showsPano; + return showsFlat; + }); + } + if (fromDate) { + sequences = sequences.filter(function(sequence) { + return new Date(sequence.properties.date).getTime() >= new Date(fromDate).getTime().toString(); + }); + } + if (toDate) { + sequences = sequences.filter(function(sequence) { + return new Date(sequence.properties.date).getTime() <= new Date(toDate).getTime().toString(); + }); + } + + return sequences; + } function showLayer() { const service = getService(); @@ -122,6 +173,9 @@ export function svgPanoramaxImages(projection, context, dispatch) { let sequences = (service ? service.sequences(projection) : []); let images = (service ? service.images(projection) : []); + images = filterImages(images); + sequences = filterSequences(sequences, service); + let traces = layer.selectAll('.sequences').selectAll('.sequence') .data(sequences, function(d) { return d.id; }); @@ -186,7 +240,7 @@ export function svgPanoramaxImages(projection, context, dispatch) { .attr('d', viewfieldPath); function viewfieldPath() { - if (this.parentNode.__data__.type == "equirectangular") { + if (this.parentNode.__data__.isPano) { return 'M 8,13 m -10,0 a 10,10 0 1,0 20,0 a 10,10 0 1,0 -20,0'; } else { return 'M 6,9 C 8,8.4 8,8.4 10,9 L 16,-2 C 12,-5 4,-5 0,-2 z';