Skip to content
Permalink
Browse files

fix for additional review comments

  • Loading branch information
Samweli authored and nyalldawson committed Jan 6, 2021
1 parent 21c28bc commit a75211cc5a0d0e45bc0af5e7f34a3e091a44290a
@@ -35,9 +35,7 @@ returns the maximal combined temporal extent of these layers.
{
QgsDateTimeRange animationRange;

double frameTimeStep;

QgsUnitTypes::TemporalUnit frameTimeStepUnit;
QgsInterval frameDuration;

QString outputDirectory;

@@ -230,16 +230,6 @@ QgsInterval QgsAnimationExportDialog::frameInterval() const
return QgsInterval( mFrameDurationSpinBox->value(), static_cast< QgsUnitTypes::TemporalUnit>( mTimeStepsComboBox->currentData().toInt() ) );
}

double QgsAnimationExportDialog::frameTimeStep() const
{
return mFrameDurationSpinBox->value();
}

QgsUnitTypes::TemporalUnit QgsAnimationExportDialog::frameTimeStepUnit() const
{
return static_cast< QgsUnitTypes::TemporalUnit>( mTimeStepsComboBox->currentData().toInt() );
}

void QgsAnimationExportDialog::applyMapSettings( QgsMapSettings &mapSettings )
{
QgsSettings settings;
@@ -66,12 +66,6 @@ class APP_EXPORT QgsAnimationExportDialog: public QDialog, private Ui::QgsAnimat
//! Returns the duration of each individual frame
QgsInterval frameInterval() const;

//! Returns the time step of each individual frame
double frameTimeStep() const;

//! Returns the time step unit of each individual frame
QgsUnitTypes::TemporalUnit frameTimeStepUnit() const;

//! configure a map settings object
void applyMapSettings( QgsMapSettings &mapSettings );

@@ -60,8 +60,7 @@ void QgsTemporalControllerDockWidget::exportAnimation()
dlg->applyMapSettings( s );

const QgsDateTimeRange animationRange = dlg->animationRange();
const double frameTimeStep = dlg->frameTimeStep();
const QgsUnitTypes::TemporalUnit frameTimeStepUnit = dlg->frameTimeStepUnit();
const QgsInterval frameDuration = dlg->frameInterval();
const QString outputDir = dlg->outputDirectory();
const QString fileNameExpression = dlg->fileNameExpression();

@@ -90,8 +89,7 @@ void QgsTemporalControllerDockWidget::exportAnimation()
decorations = QgisApp::instance()->activeDecorations();

QgsTemporalUtils::AnimationExportSettings animationSettings;
animationSettings.frameTimeStep = frameTimeStep;
animationSettings.frameTimeStepUnit = frameTimeStepUnit;
animationSettings.frameDuration = frameDuration;
animationSettings.animationRange = animationRange;
animationSettings.outputDirectory = outputDir;
animationSettings.fileNameTemplate = fileNameExpression;
@@ -75,6 +75,7 @@ QgsExpressionContextScope *QgsTemporalNavigationObject::createExpressionContextS
std::unique_ptr< QgsExpressionContextScope > scope = qgis::make_unique< QgsExpressionContextScope >( QStringLiteral( "temporal" ) );
scope->setVariable( QStringLiteral( "frame_rate" ), mFramesPerSecond, true );
scope->setVariable( QStringLiteral( "frame_number" ), mCurrentFrameNumber, true );
scope->setVariable( QStringLiteral( "frame_duration" ), mFrameDuration, true );
scope->setVariable( QStringLiteral( "frame_timestep" ), mFrameDuration.originalDuration(), true );
scope->setVariable( QStringLiteral( "frame_timestep_unit" ), mFrameDuration.originalUnit(), true );
scope->setVariable( QStringLiteral( "animation_start_time" ), mTemporalExtents.begin(), true );
@@ -92,8 +93,8 @@ QgsDateTimeRange QgsTemporalNavigationObject::dateTimeRangeForFrameNumber( long

const long long nextFrame = frame + 1;

QDateTime begin = QgsTemporalUtils::calculateFrameTime( start, frame, mFrameDuration );
QDateTime end = QgsTemporalUtils::calculateFrameTime( start, nextFrame, mFrameDuration );
const QDateTime begin = QgsTemporalUtils::calculateFrameTime( start, frame, mFrameDuration );
const QDateTime end = QgsTemporalUtils::calculateFrameTime( start, nextFrame, mFrameDuration );

QDateTime frameStart = begin;

@@ -80,7 +80,7 @@ bool QgsTemporalUtils::exportAnimation( const QgsMapSettings &mapSettings, const

QgsTemporalNavigationObject navigator;
navigator.setTemporalExtents( settings.animationRange );
navigator.setFrameDuration( QgsInterval( settings.frameTimeStep, settings.frameTimeStepUnit ) );
navigator.setFrameDuration( settings.frameDuration );
QgsMapSettings ms = mapSettings;
const QgsExpressionContext context = ms.expressionContext();

@@ -51,11 +51,8 @@ class CORE_EXPORT QgsTemporalUtils
//! Dictates the overall temporal range of the animation.
QgsDateTimeRange animationRange;

//! Time step of individual export frames
double frameTimeStep;

//! Time step unit of individual export frames
QgsUnitTypes::TemporalUnit frameTimeStepUnit;
//! Duration of individual export frames
QgsInterval frameDuration;

//! Destination directory for created image files.
QString outputDirectory;
@@ -196,6 +196,9 @@ void TestQgsTemporalNavigationObject::frameSettings()
QCOMPARE( temporalRangeSignal.count(), 1 );

navigationObject->setFrameDuration( QgsInterval( 1, QgsUnitTypes::TemporalHours ) );
QCOMPARE( navigationObject->frameDuration(), QgsInterval( 1, QgsUnitTypes::TemporalHours ) );
QCOMPARE( temporalRangeSignal.count(), 2 );

QCOMPARE( navigationObject->frameDuration().originalDuration(), 1.0 );
QCOMPARE( navigationObject->frameDuration().originalUnit(), QgsUnitTypes::TemporalHours );

@@ -248,6 +251,7 @@ void TestQgsTemporalNavigationObject::expressionContext()

std::unique_ptr< QgsExpressionContextScope > scope( object.createExpressionContextScope() );
QCOMPARE( scope->variable( QStringLiteral( "frame_rate" ) ).toDouble(), 30.0 );
QCOMPARE( scope->variable( QStringLiteral( "frame_duration" ) ).value< QgsInterval >().seconds(), 3600.0 );
QCOMPARE( scope->variable( QStringLiteral( "frame_timestep" ) ).value< double >(), 1.0 );
QCOMPARE( scope->variable( QStringLiteral( "frame_timestep_unit" ) ).value< QgsUnitTypes::TemporalUnit >(), QgsUnitTypes::TemporalUnit::TemporalHours );
QCOMPARE( scope->variable( QStringLiteral( "frame_number" ) ).toInt(), 1 );

0 comments on commit a75211c

Please sign in to comment.
You can’t perform that action at this time.