Skip to content

Commit

Permalink
fix tests and other minors
Browse files Browse the repository at this point in the history
  • Loading branch information
vcloarec committed Nov 29, 2024
1 parent 7d235e9 commit 627d614
Show file tree
Hide file tree
Showing 8 changed files with 74 additions and 5 deletions.
1 change: 1 addition & 0 deletions Tests/core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ SET(TESTS

IF(WITH_HYDRAULIC_MODEL_SUPPORT)
SET(TESTS
${TESTS}
reos_mesh_test.cpp
)
ENDIF(WITH_HYDRAULIC_MODEL_SUPPORT)
Expand Down
24 changes: 24 additions & 0 deletions Tests/core/reos_watershed_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ class ReosWatersehdTest: public QObject

void runoffhydrograph();

void delineate_watershed();

private:
ReosModule rootModule;
ReosGisEngine gisEngine;
Expand Down Expand Up @@ -401,6 +403,28 @@ void ReosWatersehdTest::watershedDelineating()
QVERIFY( itemModel.rowCount( itemModel.index( 0, 0, QModelIndex() ) ) == 2 ); //including residual watershed
}

void ReosWatersehdTest::delineate_watershed()
{
QString layerId = gisEngine.addRasterLayer( "/home/vincent/dev/vortex/data/SRTMGL1_France_SE.tif", QStringLiteral( "raster_DEM" ) );
ReosMapExtent extent = ReosMapExtent( 661553.33, 1792732.0, 661780.44, 1792964.54 );
extent.setCrs( ReosGisEngine::crsFromEPSG( 32620 ) );

const QString directionFilePath = "/home/vincent/dev/vortex/data/SRTMGL1_France_SE_dir.tif";
QPolygonF dsLine;
dsLine << QPointF( 2.62316877380512858, 43.26591984771614818 )
<< QPointF( 2.62914772565076982, 43.26415514870655699 )
<< QPointF( 2.62914772565076982, 43.26415514870655699 );

ReosWatershedDelineating::DelineateResult res = ReosWatershedDelineating::delineateWatershed(
layerId,
directionFilePath,
dsLine,
ReosGisEngine::crsFromEPSG( 4326 ),
&gisEngine );

int a = 1;
}

void ReosWatersehdTest::delineateFromDirection()
{
QString layerId = gisEngine.addRasterLayer( test_file( "DEM_for_watershed.tif" ).c_str(), QStringLiteral( "raster_DEM" ) );
Expand Down
39 changes: 36 additions & 3 deletions Tests/dataProviders/comephore/reos_comephores_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,12 @@ class ReosComephoreTest: public QObject
void createRainfallFromNetCdf();
void netCdfFolder();
void timeWindow();

void missingIndex();
void griddedDataOnWatersed();

private:
ReosModule mRootModule;
ReosGisEngine *mGisEngine = nullptr;
};

void ReosComephoreTest::createProvider()
Expand Down Expand Up @@ -84,6 +88,7 @@ void ReosComephoreTest::createProvider()
provider->calculateMinMax( min, max );
QCOMPARE( min, 0.1 );
QCOMPARE( max, 12.4 );

}

void ReosComephoreTest::createRainfallFromTif()
Expand Down Expand Up @@ -344,11 +349,39 @@ void ReosComephoreTest::missingIndex()
ReosWatershed ws( delineating, delineating.at( 0 ), ReosGisEngine::crsFromEPSG( 2154 ) );

std::unique_ptr<ReosSeriesRainfallFromGriddedOnWatershed> onWs = std::unique_ptr<ReosSeriesRainfallFromGriddedOnWatershed>( ReosSeriesRainfallFromGriddedOnWatershed::create( & ws, rainfall.get() ) );
}

void ReosComephoreTest::griddedDataOnWatersed()
{
QVariantMap uriParam;
uriParam[QStringLiteral( "file-or-dir-path" )] = COMEPHORE_FILES_PATH + QStringLiteral( "/comephore_nc" );

bool ok = false;
const QString &uri = ReosDataProviderRegistery::instance()->buildUri( QStringLiteral( "comephore" ), ReosGriddedRainfall::staticType(), uriParam, ok );
QVERIFY( ok );

std::unique_ptr<ReosGriddedData> griddedData =
std::make_unique<ReosGriddedData>( uri, QStringLiteral( "era5" ) );


QPolygonF watershed_poly;
watershed_poly << QPointF( 279856., 6309772. )
<< QPointF( 346425., 6320051. )
<< QPointF( 348884., 6252486. )
<< QPointF( 283670., 6251741. );

ReosWatershed watershed;
mGisEngine->setCrs( ReosGisEngine::crsFromEPSG( 9794 ) );
watershed.setGeographicalContext( mGisEngine );
watershed.setDelineating( watershed_poly );

double value = onWs->valueAt( 743 );
std::unique_ptr<ReosSeriesFromGriddedDataOnWatershed> gridOnWs( ReosSeriesFromGriddedDataOnWatershed::create( &watershed, griddedData.get() ) );

int a = 1;
gridOnWs->preCalculate();

QVector<double> values = gridOnWs->constData();
QCOMPARE( values.count(), 3624 );
QCOMPARE( values.at( 58 ), 0.0001061439977543495 );
}


Expand Down
5 changes: 5 additions & 0 deletions src/core/rainfall/reosgriddedrainitem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,11 @@ ReosGriddedRainfall::~ReosGriddedRainfall()
{
}

QString ReosGriddedRainfall::type() const
{
return staticType();
}

ReosGriddedRainfall *ReosGriddedRainfall::loadGriddedRainfall( const QString &dataSource, const QString &providerKey, QObject *parent )
{
std::unique_ptr<ReosGriddedRainfall> ret = std::make_unique<ReosGriddedRainfall>( dataSource, providerKey, parent );
Expand Down
2 changes: 2 additions & 0 deletions src/core/rainfall/reosgriddedrainitem.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ class REOSCORE_EXPORT ReosGriddedRainfall : public ReosGriddedData
ReosGriddedRainfall( const QString &dataSource, const QString &providerKey, QObject *parent = nullptr );
~ReosGriddedRainfall();

QString type() const override SIP_SKIP;

static ReosGriddedRainfall *loadGriddedRainfall( const QString &dataSource, const QString &providerKey, QObject *parent = nullptr );

//! Returns a pointer to the data provider
Expand Down
2 changes: 1 addition & 1 deletion src/core/raster/reosrasterwatershed.h
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ class REOSCORE_EXPORT ReosRasterWatershedFromDirectionAndDownStreamLine: public
void start() override;
void stop( bool b ) override;

//! Returns the raster watershed defined by this class after calculation
//! Returns the raster watershed defined by this instance after calculation
ReosRasterWatershed::Watershed watershed() const;

//! Returns the first defined cells, that is on the middle of the downstream line
Expand Down
4 changes: 3 additions & 1 deletion src/dataProviders/delft-FEWS/reosdelftfewswidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,9 @@ ReosDataObject *ReosDelftFewsWidget::createData( QObject *parent ) const
std::unique_ptr<ReosTimeSeries> dataObject;
ReosDelftFewsXMLProviderInterface *provider = nullptr;

if ( dataObject->dataProvider() )
dataObject->dataProvider()->setMetadata( station.meta );

if ( station.dataType() == ReosDelftFewsXMLHydrographProvider::dataType() )
{
dataObject.reset( createHydrograph( parent ) );
Expand All @@ -108,7 +111,6 @@ ReosDataObject *ReosDelftFewsWidget::createData( QObject *parent ) const

if ( provider )
{
provider->setMetadata( station.meta );
dataObject->setName( station.meta.value( QStringLiteral( "name" ) ).toString() );
return dataObject.release();
}
Expand Down
2 changes: 2 additions & 0 deletions src/dataProviders/hec-dss/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,13 @@ SET(REOS_PROVIDER_HEC_DSS_HEADERS

IF(WITH_GUI)
SET(REOS_PROVIDER_HEC_DSS_SOURCES
${REOS_PROVIDER_HEC_DSS_SOURCES}
reosdssgriddedrainfallselector.cpp
reosdssprovideruriwidget.cpp
)

SET(REOS_PROVIDER_HEC_DSS_HEADERS
${REOS_PROVIDER_HEC_DSS_HEADERS}
reosdssgriddedrainfallselector.h
reosdssprovideruriwidget.h
)
Expand Down

0 comments on commit 627d614

Please sign in to comment.