Skip to content
Permalink
Browse files

[wms] Pass some large types by reference

(cherry picked from commit 5dd69c0)
  • Loading branch information
nyalldawson committed Feb 19, 2021
1 parent af4fb3f commit b7b43a34eeccf23d99fb6e79c84b8b35080d17c7
Showing with 24 additions and 23 deletions.
  1. +14 −13 src/providers/wms/qgswmscapabilities.cpp
  2. +10 −10 src/providers/wms/qgswmscapabilities.h
@@ -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 );
}
@@ -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 );
}
@@ -189,7 +189,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( '=' );
@@ -218,7 +218,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() )
@@ -300,7 +300,7 @@ QgsWmstDimensionExtent QgsWmsSettings::parseTemporalExtent( QString extent )
return dimensionExtent;
}

void QgsWmsSettings::setTimeDimensionExtent( QgsWmstDimensionExtent timeDimensionExtent )
void QgsWmsSettings::setTimeDimensionExtent( const QgsWmstDimensionExtent &timeDimensionExtent )
{
mTimeDimensionExtent = timeDimensionExtent;
}
@@ -310,7 +310,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 );

@@ -330,7 +330,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;

@@ -368,8 +368,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;

@@ -448,7 +449,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
@@ -436,7 +436,7 @@ struct QgsWmstResolution
int minutes = -1;
int seconds = -1;

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

@@ -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" );

@@ -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 &&
@@ -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.
@@ -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
@@ -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;

0 comments on commit b7b43a3

Please sign in to comment.