Skip to content

Commit

Permalink
[wms] Pass some large types by reference
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Jan 17, 2021
1 parent f16c256 commit 5dd69c0
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 23 deletions.
27 changes: 14 additions & 13 deletions src/providers/wms/qgswmscapabilities.cpp
Expand Up @@ -88,10 +88,10 @@ bool QgsWmsSettings::parseUri( const QString &uriString )
mTemporalExtent = uri.param( QStringLiteral( "timeDimensionExtent" ) );
mTimeDimensionExtent = parseTemporalExtent( mTemporalExtent );

if ( mTimeDimensionExtent.datesResolutionList.first().dates.dateTimes.size() > 0 )
if ( mTimeDimensionExtent.datesResolutionList.constFirst().dates.dateTimes.size() > 0 )
{
QDateTime begin = mTimeDimensionExtent.datesResolutionList.first().dates.dateTimes.first();
QDateTime end = mTimeDimensionExtent.datesResolutionList.last().dates.dateTimes.last();
QDateTime begin = mTimeDimensionExtent.datesResolutionList.constFirst().dates.dateTimes.first();
QDateTime end = mTimeDimensionExtent.datesResolutionList.constLast().dates.dateTimes.last();

mFixedRange = QgsDateTimeRange( begin, end );
}
Expand All @@ -104,10 +104,10 @@ bool QgsWmsSettings::parseUri( const QString &uriString )

mReferenceTimeDimensionExtent = parseTemporalExtent( referenceExtent );

if ( mReferenceTimeDimensionExtent.datesResolutionList.first().dates.dateTimes.size() > 0 )
if ( mReferenceTimeDimensionExtent.datesResolutionList.constFirst().dates.dateTimes.size() > 0 )
{
QDateTime begin = mReferenceTimeDimensionExtent.datesResolutionList.first().dates.dateTimes.first();
QDateTime end = mReferenceTimeDimensionExtent.datesResolutionList.last().dates.dateTimes.last();
QDateTime begin = mReferenceTimeDimensionExtent.datesResolutionList.constFirst().dates.dateTimes.first();
QDateTime end = mReferenceTimeDimensionExtent.datesResolutionList.constLast().dates.dateTimes.last();

mFixedReferenceRange = QgsDateTimeRange( begin, end );
}
Expand Down Expand Up @@ -188,7 +188,7 @@ bool QgsWmsSettings::parseUri( const QString &uriString )
if ( uri.hasParam( QStringLiteral( "tileDimensions" ) ) )
{
mTiled = true;
const auto tileDimensions = uri.param( "tileDimensions" ).split( ';' );
const auto tileDimensions = uri.param( QStringLiteral( "tileDimensions" ) ).split( ';' );
for ( const QString &param : tileDimensions )
{
QStringList kv = param.split( '=' );
Expand Down Expand Up @@ -217,7 +217,7 @@ bool QgsWmsSettings::parseUri( const QString &uriString )
return true;
}

QgsWmstDimensionExtent QgsWmsSettings::parseTemporalExtent( QString extent )
QgsWmstDimensionExtent QgsWmsSettings::parseTemporalExtent( const QString &extent )
{
QgsWmstDimensionExtent dimensionExtent;
if ( extent.isNull() )
Expand Down Expand Up @@ -299,7 +299,7 @@ QgsWmstDimensionExtent QgsWmsSettings::parseTemporalExtent( QString extent )
return dimensionExtent;
}

void QgsWmsSettings::setTimeDimensionExtent( QgsWmstDimensionExtent timeDimensionExtent )
void QgsWmsSettings::setTimeDimensionExtent( const QgsWmstDimensionExtent &timeDimensionExtent )
{
mTimeDimensionExtent = timeDimensionExtent;
}
Expand All @@ -309,7 +309,7 @@ QgsWmstDimensionExtent QgsWmsSettings::timeDimensionExtent() const
return mTimeDimensionExtent;
}

QDateTime QgsWmsSettings::addTime( QDateTime dateTime, QgsWmstResolution resolution )
QDateTime QgsWmsSettings::addTime( const QDateTime &dateTime, const QgsWmstResolution &resolution )
{
QDateTime resultDateTime = QDateTime( dateTime );

Expand All @@ -329,7 +329,7 @@ QDateTime QgsWmsSettings::addTime( QDateTime dateTime, QgsWmstResolution resolut
return resultDateTime;
}

QDateTime QgsWmsSettings::findLeastClosestDateTime( QDateTime dateTime, bool dateOnly ) const
QDateTime QgsWmsSettings::findLeastClosestDateTime( const QDateTime &dateTime, bool dateOnly ) const
{
QDateTime closest = dateTime;

Expand Down Expand Up @@ -367,8 +367,9 @@ QDateTime QgsWmsSettings::findLeastClosestDateTime( QDateTime dateTime, bool dat
return closest;
}

QgsWmstResolution QgsWmsSettings::parseWmstResolution( QString item )
QgsWmstResolution QgsWmsSettings::parseWmstResolution( const QString &itemText )
{
QString item = itemText;
QgsWmstResolution resolution;
bool found = false;

Expand Down Expand Up @@ -447,7 +448,7 @@ QgsWmstResolution QgsWmsSettings::parseWmstResolution( QString item )
return resolution;
}

QDateTime QgsWmsSettings::parseWmstDateTimes( QString item )
QDateTime QgsWmsSettings::parseWmstDateTimes( const QString &item )
{
// Standard item will have YYYY-MM-DDTHH:mm:ss.SSSZ
// format a Qt::ISODateWithMs
Expand Down
20 changes: 10 additions & 10 deletions src/providers/wms/qgswmscapabilities.h
Expand Up @@ -436,7 +436,7 @@ struct QgsWmstResolution
int minutes = -1;
int seconds = -1;

long long interval()
long long interval() const
{
long long secs = 0.0;

Expand All @@ -456,13 +456,13 @@ struct QgsWmstResolution
return secs;
}

bool active()
bool active() const
{
return year != -1 || month != -1 || day != -1 ||
hour != -1 || minutes != -1 || seconds != -1;
}

QString text()
QString text() const
{
QString text( "P" );

Expand Down Expand Up @@ -506,7 +506,7 @@ struct QgsWmstResolution
return text;
}

bool operator== ( const QgsWmstResolution &other )
bool operator==( const QgsWmstResolution &other ) const
{
return year == other.year && month == other.month &&
day == other.day && hour == other.hour &&
Expand Down Expand Up @@ -815,15 +815,15 @@ class QgsWmsSettings
*
* \since QGIS 3.14
*/
QgsWmstDimensionExtent parseTemporalExtent( QString extent );
QgsWmstDimensionExtent parseTemporalExtent( const QString &extent );

/**
* Sets the dimension extent property
*
* \see timeDimensionExtent()
* \since QGIS 3.14
*/
void setTimeDimensionExtent( QgsWmstDimensionExtent timeDimensionExtent );
void setTimeDimensionExtent( const QgsWmstDimensionExtent &timeDimensionExtent );

/**
* Returns the dimension extent property.
Expand All @@ -838,21 +838,21 @@ class QgsWmsSettings
*
* \since QGIS 3.14
*/
QgsWmstResolution parseWmstResolution( QString item );
QgsWmstResolution parseWmstResolution( const QString &item );

/**
* Parse the given string item into QDateTime instant.
*
* \since QGIS 3.14
*/
QDateTime parseWmstDateTimes( QString item );
QDateTime parseWmstDateTimes( const QString &item );

/**
* Returns the datetime with the sum of passed \a dateTime and the \a resolution time.
*
* \since QGIS 3.14
*/
QDateTime addTime( QDateTime dateTime, QgsWmstResolution resolution );
QDateTime addTime( const QDateTime &dateTime, const QgsWmstResolution &resolution );

/**
* Finds the least closest datetime from list of available dimension temporal ranges
Expand All @@ -862,7 +862,7 @@ class QgsWmsSettings
*
* \since QGIS 3.14
*/
QDateTime findLeastClosestDateTime( QDateTime dateTime, bool dateOnly = false ) const;
QDateTime findLeastClosestDateTime( const QDateTime &dateTime, bool dateOnly = false ) const;

protected:
QgsWmsParserSettings mParserSettings;
Expand Down

0 comments on commit 5dd69c0

Please sign in to comment.