Skip to content

Commit

Permalink
removed wmst specific logis in temporal tab
Browse files Browse the repository at this point in the history
  • Loading branch information
Samweli authored and nyalldawson committed Mar 29, 2020
1 parent 8cd1c0f commit 76fcdf1
Show file tree
Hide file tree
Showing 7 changed files with 234 additions and 411 deletions.
2 changes: 0 additions & 2 deletions src/core/raster/qgsrasterdataprovider.cpp
Expand Up @@ -527,8 +527,6 @@ void QgsRasterDataProvider::copyBaseSettings( const QgsRasterDataProvider &other
{
*mTemporalCapabilities = *other.mTemporalCapabilities;
}

setDataSourceUri( other.dataSourceUri() );
}

// ENDS
162 changes: 127 additions & 35 deletions src/gui/raster/qgsrasterlayerproperties.cpp
Expand Up @@ -117,6 +117,8 @@ QgsRasterLayerProperties::QgsRasterLayerProperties( QgsMapLayer *lyr, QgsMapCanv
connect( buttonBox, &QDialogButtonBox::helpRequested, this, &QgsRasterLayerProperties::showHelp );

connect( mSetEndAsStartStaticButton, &QPushButton::clicked, this, &QgsRasterLayerProperties::setEndAsStartStaticButton_clicked );
connect( mProjectTemporalRange, &QRadioButton::toggled, this, &QgsRasterLayerProperties::passProjectTemporalRange_toggled );
connect( mStaticTemporalRange, &QRadioButton::toggled, this, &QgsRasterLayerProperties::staticTemporalRange_toggled );

mBtnStyle = new QPushButton( tr( "Style" ) );
QMenu *menuStyle = new QMenu( this );
Expand Down Expand Up @@ -279,14 +281,7 @@ QgsRasterLayerProperties::QgsRasterLayerProperties( QgsMapLayer *lyr, QgsMapCanv
mTemporalWidget = new QgsRasterLayerTemporalPropertiesWidget( this, mRasterLayer );
temporalLayout->addWidget( mTemporalWidget );

QLocale locale;

mStartStaticDateTimeEdit->setDisplayFormat(
locale.dateTimeFormat( QLocale::ShortFormat ) );
mEndStaticDateTimeEdit->setDisplayFormat(
locale.dateTimeFormat( QLocale::ShortFormat ) );
mReferenceDateTimeEdit->setDisplayFormat(
locale.dateTimeFormat( QLocale::ShortFormat ) );
setSourceStaticTimeState();

QgsDebugMsg( "Setting crs to " + mRasterLayer->crs().toWkt( QgsCoordinateReferenceSystem::WKT2_2018 ) );
QgsDebugMsg( "Setting crs to " + mRasterLayer->crs().userFriendlyIdentifier() );
Expand Down Expand Up @@ -1084,12 +1079,13 @@ void QgsRasterLayerProperties::apply()
mTemporalWidget->saveTemporalProperties();

updateSourceStaticTime();
mRasterLayer->triggerRepaint();

//get the thumbnail for the layer
QPixmap thumbnail = QPixmap::fromImage( mRasterLayer->previewAsImage( pixmapThumbnail->size() ) );
pixmapThumbnail->setPixmap( thumbnail );

mRasterLayer->triggerRepaint();

if ( mRasterLayer->shortName() != mLayerShortNameLineEdit->text() )
mMetadataFilled = false;
mRasterLayer->setShortName( mLayerShortNameLineEdit->text() );
Expand Down Expand Up @@ -1165,50 +1161,146 @@ void QgsRasterLayerProperties::updateSourceStaticTime()
{
if ( mTimeGroup->isEnabled() &&
mRasterLayer &&
mRasterLayer->dataProvider() )
mRasterLayer->dataProvider() &&
mRasterLayer->temporalProperties() )
{
QgsDataSourceUri uri( mRasterLayer->dataProvider()->dataSourceUri() );
if ( mStaticTemporalRange->isChecked() )
{
QString time = mStartStaticDateTimeEdit->dateTime().toString( Qt::ISODateWithMs ) + "/" +
mEndStaticDateTimeEdit->dateTime().toString( Qt::ISODateWithMs );
uri.setParam( QLatin1String( "time" ), time );
}
QgsDataSourceUri uri( mRasterLayer->dataProvider()->dataSourceUri() );
if ( mStaticTemporalRange->isChecked() )
{
QString time = mStartStaticDateTimeEdit->dateTime().toString( Qt::ISODateWithMs ) + "/" +
mEndStaticDateTimeEdit->dateTime().toString( Qt::ISODateWithMs );
uri.setParam( QLatin1String( "time" ), time );
mRasterLayer->temporalProperties()->setTemporalSource(
QgsRasterLayerTemporalProperties::Layer );
}

if ( mProjectTemporalRange->isChecked() )
{
QgsDateTimeRange range;
if ( mProjectTemporalRange->isChecked() )
{
QgsDateTimeRange range;

if ( QgsProject::instance()->timeSettings() )
range = QgsProject::instance()->timeSettings()->temporalRange();
if ( range.begin().isValid() && range.end().isValid() )
{
QString time = range.begin().toString( Qt::ISODateWithMs ) + "/" +
range.end().toString( Qt::ISODateWithMs );
if ( QgsProject::instance()->timeSettings() )
range = QgsProject::instance()->timeSettings()->temporalRange();
if ( range.begin().isValid() && range.end().isValid() )
{
QString time = range.begin().toString( Qt::ISODateWithMs ) + "/" +
range.end().toString( Qt::ISODateWithMs );

uri.setParam( QLatin1String( "time" ), time );
}
else
mLabel->setText( tr( "Project temporal range is not valid, can't use it here" ) );
uri.setParam( QLatin1String( "time" ), time );
mRasterLayer->temporalProperties()->setTemporalSource(
QgsRasterLayerTemporalProperties::Project );
}
}

if ( mReferenceTime->isChecked() )
{
QString reference_time = mReferenceDateTimeEdit->dateTime().toString( Qt::ISODateWithMs );
uri.setParam( QLatin1String( "reference_time" ), reference_time );
}
if ( mRasterLayer->dataProvider()->temporalCapabilities() )
mRasterLayer->dataProvider()->temporalCapabilities()->setEnableTime(
mDisableTime->isChecked() );
mRasterLayer->dataProvider()->temporalCapabilities()->setEnableTime(
!mDisableTime->isChecked() );

mRasterLayer->dataProvider()->setDataSourceUri( uri.uri() );

mRasterLayer->temporalProperties()->setIntervalHandlingMethod( static_cast< QgsRasterDataProviderTemporalCapabilities::IntervalHandlingMethod >(
mFetchModeComboBox->currentData().toInt() ) );
}
}

//void QgsRasterLayerProperties::updateSourceStaticTimeState()
//{
void QgsRasterLayerProperties::setSourceStaticTimeState()
{
QLocale locale;

mStartStaticDateTimeEdit->setDisplayFormat(
locale.dateTimeFormat( QLocale::ShortFormat ) );
mEndStaticDateTimeEdit->setDisplayFormat(
locale.dateTimeFormat( QLocale::ShortFormat ) );
mReferenceDateTimeEdit->setDisplayFormat(
locale.dateTimeFormat( QLocale::ShortFormat ) );

//}
if ( mRasterLayer && mRasterLayer->temporalProperties() )
{
QgsDateTimeRange layerRange = mRasterLayer->temporalProperties()->fixedTemporalRange();
QgsDateTimeRange layerReferenceRange = mRasterLayer->temporalProperties()->fixedReferenceTemporalRange();
QgsDataSourceUri uri( mRasterLayer->dataProvider()->dataSourceUri() );

QString time = uri.param( QLatin1String( "time" ) );
QString referenceTime = uri.param( QLatin1String( "reference_time" ) );

if ( layerRange.begin().isValid() && layerRange.end().isValid() )
{
mStartStaticDateTimeEdit->setDateTimeRange( layerRange.begin(),
layerRange.end() );
mStartStaticDateTimeEdit->setDateTime( layerRange.begin() );
mEndStaticDateTimeEdit->setDateTimeRange( layerRange.begin(),
layerRange.end() );
mEndStaticDateTimeEdit->setDateTime( layerRange.end() );
}
if ( layerReferenceRange.begin().isValid() && layerReferenceRange.end().isValid() )
{
mReferenceDateTimeEdit->setDateTimeRange( layerReferenceRange.begin(),
layerReferenceRange.end() );
mReferenceDateTimeEdit->setDateTime( layerReferenceRange.begin() );
}

if ( time != QLatin1String( "" ) )
{
QStringList parts = time.split( '/' );
mStartStaticDateTimeEdit->setDateTime( QDateTime::fromString( parts.at( 0 ), Qt::ISODateWithMs ) );
mEndStaticDateTimeEdit->setDateTime( QDateTime::fromString( parts.at( 1 ), Qt::ISODateWithMs ) );
}

if ( referenceTime != QLatin1String( "" ) )
{
if ( referenceTime.contains( '/' ) )
{
QStringList parts = time.split( '/' );
mReferenceDateTimeEdit->setDateTime( QDateTime::fromString( parts.at( 0 ), Qt::ISODateWithMs ) );
}
else
mReferenceDateTimeEdit->setDateTime( QDateTime::fromString( referenceTime, Qt::ISODateWithMs ) );
}

mFetchModeComboBox->addItem( tr( "Use Whole Temporal Range" ), QgsRasterDataProviderTemporalCapabilities::MatchUsingWholeRange );
mFetchModeComboBox->addItem( tr( "Match to Start of Range" ), QgsRasterDataProviderTemporalCapabilities::MatchExactUsingStartOfRange );
mFetchModeComboBox->addItem( tr( "Match to End of Range" ), QgsRasterDataProviderTemporalCapabilities::MatchExactUsingEndOfRange );
mFetchModeComboBox->setCurrentIndex( mFetchModeComboBox->findData( mRasterLayer->temporalProperties()->intervalHandlingMethod() ) );

if ( mRasterLayer->temporalProperties()->temporalSource() == QgsRasterLayerTemporalProperties::Layer )
mStaticTemporalRange->setChecked( true );
else if ( mRasterLayer->temporalProperties()->temporalSource() == QgsRasterLayerTemporalProperties::Project )
mProjectTemporalRange->setChecked( true );
}
}

void QgsRasterLayerProperties::staticTemporalRange_toggled( bool checked )
{
if ( checked )
{
mLabel->setText( tr( "" ) );
}
}

void QgsRasterLayerProperties::passProjectTemporalRange_toggled( bool checked )
{
if ( checked )
{
QgsDateTimeRange range;
QLocale locale;
if ( QgsProject::instance()->timeSettings() )
range = QgsProject::instance()->timeSettings()->temporalRange();

if ( range.begin().isValid() && range.end().isValid() )
mLabel->setText( tr( "Project temporal range is set from %1 to %2" ).arg(
range.begin().toString(
locale.dateTimeFormat( QLocale::ShortFormat ) ),
range.end().toString(
locale.dateTimeFormat( QLocale::ShortFormat ) )
) );
else
mLabel->setText( tr( "Project temporal range is not valid, can't use it here" ) );
}
}

void QgsRasterLayerProperties::mLayerOrigNameLineEd_textEdited( const QString &text )
{
Expand Down
12 changes: 12 additions & 0 deletions src/gui/raster/qgsrasterlayerproperties.h
Expand Up @@ -114,6 +114,12 @@ class GUI_EXPORT QgsRasterLayerProperties : public QgsOptionsDialogBase, private
//! \brief slot executed when user "Set end same as start" button on time options in source page.
void setEndAsStartStaticButton_clicked();

//! \brief slot executed when user "Pass provider temporal range" radio button on time options in source page.
void passProjectTemporalRange_toggled( bool checked );

//! \brief slot executed when user "Static time range" radio button on time options in source page.
void staticTemporalRange_toggled( bool checked );

/**
* \brief slot executed when the single band radio button is pressed.
* \brief slot executed when the reset null value to file default icon is selected
Expand Down Expand Up @@ -234,6 +240,12 @@ class GUI_EXPORT QgsRasterLayerProperties : public QgsOptionsDialogBase, private
*/
void updateSourceStaticTime();

/**
* Initialiaze the layers static time inputs state.
*
*/
void setSourceStaticTimeState();

void setupTransparencyTable( int nBands );

//! \brief Clear the current transparency table and populate the table with the correct types for current drawing mode and data type
Expand Down

0 comments on commit 76fcdf1

Please sign in to comment.