Skip to content
Permalink
Browse files

Correctly populate all available temporal ranges for WMS-T services

which report available times using ISO8601 style duration strings
  • Loading branch information
nyalldawson committed Mar 25, 2021
1 parent 1bb042b commit 2cf7a56d1b403e50cd095bbc07f2977e0bda59e2
@@ -29,6 +29,7 @@
#include "qgsunittypes.h"
#include "qgsexception.h"
#include "qgsapplication.h"
#include "qgstemporalutils.h"

// %%% copied from qgswmsprovider.cpp
static QString DEFAULT_LATLON_CRS = QStringLiteral( "CRS:84" );
@@ -107,7 +108,19 @@ bool QgsWmsSettings::parseUri( const QString &uriString )

const QDateTime begin = extent.dates.dateTimes.first();
const QDateTime end = extent.dates.dateTimes.last();
mAllRanges.append( QgsDateTimeRange( begin, end ) );

bool ok = false;
bool maxValuesExceeded = false;
const QList< QDateTime > dates = QgsTemporalUtils::calculateDateTimesFromISO8601( extent.originalString, ok, maxValuesExceeded );
if ( ok )
{
for ( const QDateTime &dt : dates )
mAllRanges.append( QgsDateTimeRange( dt, dt ) );
}
else
{
mAllRanges.append( QgsDateTimeRange( begin, end ) );
}
}

if ( uri.param( QStringLiteral( "referenceTimeDimensionExtent" ) ) != QString() )
@@ -263,7 +276,7 @@ QgsWmstDimensionExtent QgsWmsSettings::parseTemporalExtent( const QString &exten
}
}

dimensionExtent.datesResolutionList.append( QgsWmstExtentPair( itemDatesList, itemResolution ) );
dimensionExtent.datesResolutionList.append( QgsWmstExtentPair( itemDatesList, itemResolution, item ) );
}
else
{
@@ -278,7 +291,7 @@ QgsWmstDimensionExtent QgsWmsSettings::parseTemporalExtent( const QString &exten
datesList.dateTimes.append( parseWmstDateTimes( item ) );
}

dimensionExtent.datesResolutionList.append( QgsWmstExtentPair( datesList, resolution ) );
dimensionExtent.datesResolutionList.append( QgsWmstExtentPair( datesList, resolution, item ) );
}
}

@@ -525,7 +525,10 @@ struct QgsWmstExtentPair
{
}

QgsWmstExtentPair( QgsWmstDates otherDates, QgsWmstResolution otherResolution )
QgsWmstExtentPair( QgsWmstDates otherDates, QgsWmstResolution otherResolution, const QString &originalString )
: dates( otherDates )
, resolution( otherResolution )
, originalString( originalString )
{
dates = otherDates;
resolution = otherResolution;
@@ -539,6 +542,8 @@ struct QgsWmstExtentPair

QgsWmstDates dates;
QgsWmstResolution resolution;
QString originalString;

};


@@ -96,7 +96,7 @@ void QgsWmstSettingsWidget::syncToLayer( QgsMapLayer *layer )

const QList< QgsDateTimeRange > allAvailableRanges = mRasterLayer->dataProvider()->temporalCapabilities()->allAvailableTemporalRanges();
// determine if available ranges are a set of non-contiguous instants, and if so, we show a combobox to users instead of the free-form date widgets
if ( std::all_of( allAvailableRanges.cbegin(), allAvailableRanges.cend(), []( const QgsDateTimeRange & range ) { return range.isInstant(); } ) )
if ( allAvailableRanges.size() < 50 && std::all_of( allAvailableRanges.cbegin(), allAvailableRanges.cend(), []( const QgsDateTimeRange & range ) { return range.isInstant(); } ) )
{
mStaticWmstRangeFrame->hide();
mStaticWmstChoiceFrame->show();

0 comments on commit 2cf7a56

Please sign in to comment.