Skip to content

Commit

Permalink
Some backports (#446)
Browse files Browse the repository at this point in the history
* update versions in README.md

* backport #435

* backport #439

* backport #445
  • Loading branch information
vcloarec committed Feb 28, 2023
1 parent 06c59ac commit a84bd13
Show file tree
Hide file tree
Showing 15 changed files with 270 additions and 74 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/coverage_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ on: [push, pull_request]
jobs:
coverage_tests:
if: github.repository == 'lutraconsulting/MDAL'
runs-on: ubuntu-18.04
runs-on: ubuntu-latest
steps:
- name: Checkout MDAL
uses: actions/checkout@v2
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/linux_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Linux Tests
on: [push, pull_request]
jobs:
linux_tests:
runs-on: ubuntu-18.04
runs-on: ubuntu-latest
steps:
- name: Checkout MDAL
uses: actions/checkout@v2
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/memcheck_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: MemCheck Tests
on: [push, pull_request]
jobs:
memcheck_tests:
runs-on: ubuntu-18.04
runs-on: ubuntu-latest
steps:
- name: Checkout MDAL
uses: actions/checkout@v2
Expand Down
22 changes: 9 additions & 13 deletions .github/workflows/windows_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,17 @@ on: [push, pull_request]

jobs:
windows_tests:
runs-on: windows-2022
runs-on: windows-latest

steps:
- name: Checkout MDAL
uses: actions/checkout@v2
uses: actions/checkout@v3

- name: config env variables
run: echo "OSGEO4W_ROOT=${{github.workspace}}\OSGEO4W" >> $env:GITHUB_ENV

- name: Choco install qgis
uses: crazy-max/ghaction-chocolatey@v1
with:
args: install qgis -y --verbose --version=3.16.3

- name: Move SDK to OSGeo4W folder
shell: pwsh
run: |
mv "C:\Program Files\QGIS 3.16" "C:\OSGeo4W64"
- name: load OSGEO dependencies
run: ${{github.workspace}}/scripts/load_osgeo.ps1

- name: Set compiler environment
shell: cmd
Expand All @@ -38,7 +34,7 @@ jobs:
cd $env:GITHUB_WORKSPACE
mkdir build
cd build
exec { cmake -G "Visual Studio 17 2022" -DCMAKE_BUILD_TYPE=Rel -DENABLE_TESTS=ON -DEXTERNAL_DRIVER_DHI_DFS=OFF -DNETCDF_PREFIX="C:\OSGeo4W64" -DHDF5_ROOT="C:\OSGeo4W64" -DGDAL_DIR="C:\OSGeo4W64" -DGDAL_LIBRARY="C:\OSGeo4W64\lib\gdal_i.lib" -DGDAL_INCLUDE_DIR="C:\OSGeo4W64\include" -DLIBXML2_LIBRARIES="C:\OSGeo4W64\lib\libxml2.lib" -DLIBXML2_INCLUDE_DIR="C:\OSGeo4W64\include\libxml2" .. }
exec { cmake -G "Visual Studio 17 2022" -DCMAKE_BUILD_TYPE=Rel -DENABLE_TESTS=ON -DEXTERNAL_DRIVER_DHI_DFS=OFF -DNETCDF_PREFIX=${{env.OSGEO4W_ROOT}} -DHDF5_ROOT=${{env.OSGEO4W_ROOT}} -DGDAL_DIR=${{env.OSGEO4W_ROOT}} -DGDAL_LIBRARY="${{env.OSGEO4W_ROOT}}\lib\gdal_i.lib" -DGDAL_INCLUDE_DIR="${{env.OSGEO4W_ROOT}}\include" -DLIBXML2_LIBRARIES="${{env.OSGEO4W_ROOT}}\lib\libxml2.lib" -DLIBXML2_INCLUDE_DIR="${{env.OSGEO4W_ROOT}}\include\libxml2" .. }
exec { cmake --build . }
- name: Run tests
Expand All @@ -52,7 +48,7 @@ jobs:
if ($LastExitCode -ne 0) { exit $LastExitCode }
}
$env:PATH="C:\OSGeo4W64\bin;$env:GITHUB_WORKSPACE\build\tool\Debug\;$env:GITHUB_WORKSPACE\build\mdal\Debug;$env:PATH"
$env:PATH="${{env.OSGEO4W_ROOT}}\bin;$env:GITHUB_WORKSPACE\build\tool\Debug\;$env:GITHUB_WORKSPACE\build\mdal\Debug;$env:PATH"
$env:MDAL_DRIVER_PATH="$env:GITHUB_WORKSPACE\build\external_drivers\minimal_example\Debug"
cd $env:GITHUB_WORKSPACE\build
exec { ctest -VV --exclude-regex "mdalinfo_test" }
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,11 @@ QGIS contains internal copy of MDAL library in following versions:
| 3.18.0 | 0.8.0 | Dynamic drivers, DFSU format |
| 3.20.0 | 0.8.1 | |
| 3.22.0 | 0.9.x | DFS2, DFSU 3D, PLY write |
| 3.24.0 | 1.0.x | TBD |
| 3.24.0 | 0.9.4 | |
| 3.24.1 | 0.9.90 | H2i format |
| 3.28.0 | 1.0.0 | write dataset capability for UGRID format |
| 3.28.2 | 1.0.1 | |


versions `X.Y.9Z` are development versions or alpha/beta releases (e.g. `0.4.90`, `0.4.91`, ...)

Expand Down
72 changes: 46 additions & 26 deletions mdal/frmts/mdal_gdal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ bool MDAL::DriverGdal::initVertices( Vertices &vertices )
return is_longitude_shifted;
}

void MDAL::DriverGdal::initFaces( Vertices &Vertexs, Faces &Faces, bool is_longitude_shifted )
void MDAL::DriverGdal::initFaces( const Vertices &Vertexs, Faces &Faces, bool is_longitude_shifted )
{
int reconnected = 0;
unsigned int mXSize = meshGDALDataset()->mXSize;
Expand Down Expand Up @@ -587,7 +587,7 @@ std::unique_ptr<MDAL::Mesh> MDAL::DriverGdal::load( const std::string &fileName,
}
}

for ( std::shared_ptr<MDAL::GdalDataset> ds : datasets )
for ( std::shared_ptr<MDAL::GdalDataset> &ds : datasets )
if ( gdal_datasets.empty() || meshes_equals( meshGDALDataset(), ds.get() ) )
gdal_datasets.push_back( ds );

Expand Down Expand Up @@ -645,26 +645,28 @@ void MDAL::DriverGdal::parseBandIsVector( std::string &band_name, bool *is_vecto
{
band_name = MDAL::trim( band_name );

if ( MDAL::startsWith( band_name, "u-", MDAL::CaseInsensitive ) ||
MDAL::startsWith( band_name, "x-", MDAL::CaseInsensitive ) ||
if ( MDAL::contains( band_name, "U wind component", MDAL::CaseInsensitive ) ||
MDAL::contains( band_name, "u-component", MDAL::CaseInsensitive ) ||
MDAL::contains( band_name, "u component", MDAL::CaseInsensitive ) ||
MDAL::contains( band_name, "U wind component", MDAL::CaseInsensitive ) ||
MDAL::startsWith( band_name, "Northward", MDAL::CaseInsensitive ) ||
MDAL::startsWith( band_name, "u-", MDAL::CaseInsensitive ) ||
MDAL::contains( band_name, "x-component", MDAL::CaseInsensitive ) ||
MDAL::contains( band_name, "x component", MDAL::CaseInsensitive ) )
MDAL::contains( band_name, "x component", MDAL::CaseInsensitive ) ||
MDAL::startsWith( band_name, "x-", MDAL::CaseInsensitive ) ||
MDAL::contains( band_name, "eastward", MDAL::CaseInsensitive ) ||
MDAL::contains( band_name, "zonal", MDAL::CaseInsensitive ) )
{
*is_vector = true; // vector
*is_x = true; //X-Axis
}
else if ( MDAL::startsWith( band_name, "v-", MDAL::CaseInsensitive ) ||
MDAL::startsWith( band_name, "y-", MDAL::CaseInsensitive ) ||
else if ( MDAL::contains( band_name, "V wind component", MDAL::CaseInsensitive ) ||
MDAL::contains( band_name, "v-component", MDAL::CaseInsensitive ) ||
MDAL::contains( band_name, "v component", MDAL::CaseInsensitive ) ||
MDAL::contains( band_name, "V wind component", MDAL::CaseInsensitive ) ||
MDAL::startsWith( band_name, "Eastward", MDAL::CaseInsensitive ) ||
MDAL::startsWith( band_name, "v-", MDAL::CaseInsensitive ) ||
MDAL::contains( band_name, "y-component", MDAL::CaseInsensitive ) ||
MDAL::contains( band_name, "y component", MDAL::CaseInsensitive ) )
MDAL::contains( band_name, "y component", MDAL::CaseInsensitive ) ||
MDAL::startsWith( band_name, "y-", MDAL::CaseInsensitive ) ||
MDAL::contains( band_name, "northward", MDAL::CaseInsensitive ) ||
MDAL::contains( band_name, "meridional", MDAL::CaseInsensitive ) )
{
*is_vector = true; // vector
*is_x = false; //Y-Axis
Expand All @@ -677,30 +679,48 @@ void MDAL::DriverGdal::parseBandIsVector( std::string &band_name, bool *is_vecto

if ( *is_vector )
{
band_name = MDAL::replace( band_name, "u-component of", "", MDAL::CaseInsensitive );
band_name = MDAL::replace( band_name, "v-component of", "", MDAL::CaseInsensitive );

band_name = MDAL::replace( band_name, "U wind component", "wind", MDAL::CaseInsensitive );
band_name = MDAL::replace( band_name, "V wind component", "wind", MDAL::CaseInsensitive );
band_name = MDAL::replace( band_name, "Northward", "", MDAL::CaseInsensitive );
band_name = MDAL::replace( band_name, "Eastward", "", MDAL::CaseInsensitive );
band_name = MDAL::replace( band_name, "x-component of", "", MDAL::CaseInsensitive );
band_name = MDAL::replace( band_name, "y-component of", "", MDAL::CaseInsensitive );

band_name = MDAL::replace( band_name, "u-component of", "", MDAL::CaseInsensitive );
band_name = MDAL::replace( band_name, "v-component of", "", MDAL::CaseInsensitive );
band_name = MDAL::replace( band_name, "u-component", "", MDAL::CaseInsensitive );
band_name = MDAL::replace( band_name, "v-component", "", MDAL::CaseInsensitive );
band_name = MDAL::replace( band_name, "x-component", "", MDAL::CaseInsensitive );
band_name = MDAL::replace( band_name, "y-component", "", MDAL::CaseInsensitive );
band_name = MDAL::replace( band_name, "u-", "", MDAL::CaseInsensitive );
band_name = MDAL::replace( band_name, "v-", "", MDAL::CaseInsensitive );

band_name = MDAL::replace( band_name, "u component of", "", MDAL::CaseInsensitive );
band_name = MDAL::replace( band_name, "v component of", "", MDAL::CaseInsensitive );
band_name = MDAL::replace( band_name, "x component of", "", MDAL::CaseInsensitive );
band_name = MDAL::replace( band_name, "y component of", "", MDAL::CaseInsensitive );
band_name = MDAL::replace( band_name, "u component", "", MDAL::CaseInsensitive );
band_name = MDAL::replace( band_name, "v component", "", MDAL::CaseInsensitive );
band_name = MDAL::replace( band_name, "x component", "", MDAL::CaseInsensitive );
band_name = MDAL::replace( band_name, "y component", "", MDAL::CaseInsensitive );
band_name = MDAL::replace( band_name, "u-", "", MDAL::CaseInsensitive );
band_name = MDAL::replace( band_name, "v-", "", MDAL::CaseInsensitive );

band_name = MDAL::replace( band_name, "x-component of", "", MDAL::CaseInsensitive );
band_name = MDAL::replace( band_name, "y-component of", "", MDAL::CaseInsensitive );
band_name = MDAL::replace( band_name, "x-component", "", MDAL::CaseInsensitive );
band_name = MDAL::replace( band_name, "y-component", "", MDAL::CaseInsensitive );
band_name = MDAL::replace( band_name, "x-", "", MDAL::CaseInsensitive );
band_name = MDAL::replace( band_name, "y-", "", MDAL::CaseInsensitive );

band_name = MDAL::replace( band_name, "x component of", "", MDAL::CaseInsensitive );
band_name = MDAL::replace( band_name, "y component of", "", MDAL::CaseInsensitive );
band_name = MDAL::replace( band_name, "x component", "", MDAL::CaseInsensitive );
band_name = MDAL::replace( band_name, "y component", "", MDAL::CaseInsensitive );

band_name = MDAL::replace( band_name, "eastward component of", "", MDAL::CaseInsensitive );
band_name = MDAL::replace( band_name, "northward component of", "", MDAL::CaseInsensitive );
band_name = MDAL::replace( band_name, "eastward component", "", MDAL::CaseInsensitive );
band_name = MDAL::replace( band_name, "northward component", "", MDAL::CaseInsensitive );
band_name = MDAL::replace( band_name, "eastward", "", MDAL::CaseInsensitive );
band_name = MDAL::replace( band_name, "northward", "", MDAL::CaseInsensitive );

band_name = MDAL::replace( band_name, "zonal component of", "", MDAL::CaseInsensitive );
band_name = MDAL::replace( band_name, "meridional component of", "", MDAL::CaseInsensitive );
band_name = MDAL::replace( band_name, "zonal component", "", MDAL::CaseInsensitive );
band_name = MDAL::replace( band_name, "meridional component", "", MDAL::CaseInsensitive );
band_name = MDAL::replace( band_name, "zonal", "", MDAL::CaseInsensitive );
band_name = MDAL::replace( band_name, "meridional", "", MDAL::CaseInsensitive );

band_name = MDAL::trim( band_name );
}
}
2 changes: 1 addition & 1 deletion mdal/frmts/mdal_gdal.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ namespace MDAL

void registerDriver();

void initFaces( Vertices &nodes, Faces &Faces, bool is_longitude_shifted );
void initFaces( const Vertices &nodes, Faces &Faces, bool is_longitude_shifted );
bool initVertices( Vertices &vertices ); //returns is_longitude_shifted

const GdalDataset *meshGDALDataset();
Expand Down
34 changes: 18 additions & 16 deletions mdal/frmts/mdal_hec2d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -738,7 +738,7 @@ bool MDAL::DriverHec2D::canReadMesh( const std::string &uri )
{
HdfFile hdfFile = openHdfFile( uri );
std::string fileType = openHdfAttribute( hdfFile, "File Type" );
return canReadFormat( fileType ) || canReadFormat505( fileType );
return canReadFormat( fileType );
}
catch ( MDAL_Status )
{
Expand All @@ -752,17 +752,12 @@ bool MDAL::DriverHec2D::canReadMesh( const std::string &uri )

bool MDAL::DriverHec2D::canReadFormat( const std::string &fileType ) const
{
return fileType == "HEC-RAS Results";
return fileType == "HEC-RAS Results" || fileType == "HEC-RAS Geometry";
}

bool MDAL::DriverHec2D::canReadFormat505( const std::string &fileType ) const
std::unique_ptr<MDAL::Mesh> MDAL::DriverHec2D::load( const std::string &fileName, const std::string & )
{
return fileType == "HEC-RAS Geometry";
}

std::unique_ptr<MDAL::Mesh> MDAL::DriverHec2D::load( const std::string &resultsFile, const std::string & )
{
mFileName = resultsFile;
mFileName = fileName;
MDAL::Log::resetLastStatus();
mMesh.reset();

Expand All @@ -787,22 +782,29 @@ std::unique_ptr<MDAL::Mesh> MDAL::DriverHec2D::load( const std::string &resultsF
parseMesh( gGeom2DFlowAreas, areaElemStartIndex, flowAreaNames );
setProjection( hdfFile );

mTimes = readTimes( hdfFile );
mReferenceTime = readReferenceDateTime( hdfFile );
bool hasResults = hdfFile.pathExists( "Results" );
if ( hasResults )
{
mTimes = readTimes( hdfFile );
mReferenceTime = readReferenceDateTime( hdfFile );
}

//Elevation
std::shared_ptr<MDAL::MemoryDataset2D> bed_elevation = readBedElevation( gGeom2DFlowAreas, areaElemStartIndex, flowAreaNames );

// Element centered Values
readElemResults( hdfFile, bed_elevation, areaElemStartIndex, flowAreaNames );
if ( hasResults )
{
// Element centered Values
readElemResults( hdfFile, bed_elevation, areaElemStartIndex, flowAreaNames );

// Face centered Values
readFaceResults( hdfFile, areaElemStartIndex, flowAreaNames );
// Face centered Values
readFaceResults( hdfFile, areaElemStartIndex, flowAreaNames );
}

}
catch ( MDAL_Status error )
{
MDAL::Log::error( error, name(), "Error occurred while loading file " + resultsFile );
MDAL::Log::error( error, name(), "Error occurred while loading file " + fileName );
mMesh.reset();
}
catch ( MDAL::Error err )
Expand Down
6 changes: 1 addition & 5 deletions mdal/frmts/mdal_hec2d.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ namespace MDAL
DriverHec2D *create() override;

bool canReadMesh( const std::string &uri ) override;
std::unique_ptr< Mesh > load( const std::string &resultsFile, const std::string &meshName = "" ) override;
std::unique_ptr< Mesh > load( const std::string &fileName, const std::string &meshName = "" ) override;

private:
std::unique_ptr< MDAL::MemoryMesh > mMesh;
Expand All @@ -52,12 +52,8 @@ namespace MDAL
std::vector<MDAL::RelativeTimestamp> mTimes ;
DateTime mReferenceTime;

// Regular format
bool canReadFormat( const std::string &fileType ) const;

// 5.0.5 format
bool canReadFormat505( const std::string &fileType ) const;

std::vector<std::string> read2DFlowAreasNamesFromNameDataset( HdfGroup gGeom2DFlowAreas ) const;
std::vector<std::string> read2DFlowAreasNamesFromAttributesDataset( HdfGroup gGeom2DFlowAreas ) const;

Expand Down
64 changes: 58 additions & 6 deletions mdal/frmts/mdal_ugrid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -531,16 +531,22 @@ void MDAL::DriverUgrid::parseNetCDFVariableMetadata( int varid,
else
{
variableName = standardName;
if ( MDAL::contains( standardName, "_x_" ) )
if ( MDAL::contains( standardName, "_x_" ) ||
MDAL::contains( standardName, "eastward_" ) )
{
*isVector = true;
name = MDAL::replace( standardName, "_x_", "" );
name = MDAL::replace( name, "_eastward_", "" );
name = MDAL::replace( name, "eastward_", "" );
}
else if ( MDAL::contains( standardName, "_y_" ) )
else if ( MDAL::contains( standardName, "_y_" ) ||
MDAL::contains( standardName, "northward_" ) )
{
*isVector = true;
*isX = false;
name = MDAL::replace( standardName, "_y_", "" );
name = MDAL::replace( name, "_northward_", "" );
name = MDAL::replace( name, "northward_", "" );
}
else if ( MDAL::contains( standardName, "_from_direction" ) )
{
Expand Down Expand Up @@ -568,18 +574,64 @@ void MDAL::DriverUgrid::parseNetCDFVariableMetadata( int varid,
else
{
variableName = longName;
if ( MDAL::contains( longName, ", x-component" ) || MDAL::contains( longName, "u component of " ) )
if ( MDAL::contains( longName, "x-component" ) ||
MDAL::contains( longName, "x component" ) ||
MDAL::contains( longName, "u-component" ) ||
MDAL::contains( longName, "u component" ) ||
MDAL::contains( longName, "eastward" ) ||
MDAL::contains( longName, "zonal" ) )
{
*isVector = true;
name = MDAL::replace( longName, ", x-component", "" );
name = MDAL::replace( name, "u component of ", "" );
name = MDAL::replace( name, "x-component of", "" );
name = MDAL::replace( name, "x-component", "" );
name = MDAL::replace( name, "x component of", "" );
name = MDAL::replace( name, "x component", "" );

name = MDAL::replace( name, "u-component of", "" );
name = MDAL::replace( name, "u-component", "" );
name = MDAL::replace( name, "u component of", "" );
name = MDAL::replace( name, "u component", "" );

name = MDAL::replace( name, "eastward component of", "" );
name = MDAL::replace( name, "eastward component", "" );
name = MDAL::replace( name, "eastward", "" );

name = MDAL::replace( name, "zonal component of", "" );
name = MDAL::replace( name, "zonal component", "" );
name = MDAL::replace( name, "zonal", "" );

name = MDAL::trim( name );
}
else if ( MDAL::contains( longName, ", y-component" ) || MDAL::contains( longName, "v component of " ) )
else if ( MDAL::contains( longName, "y-component" ) ||
MDAL::contains( longName, "y component" ) ||
MDAL::contains( longName, "v-component" ) ||
MDAL::contains( longName, "v component" ) ||
MDAL::contains( longName, "northward" ) ||
MDAL::contains( longName, "meridional" ) )
{
*isVector = true;
*isX = false;
name = MDAL::replace( longName, ", y-component", "" );
name = MDAL::replace( name, "v component of ", "" );
name = MDAL::replace( name, "y-component of", "" );
name = MDAL::replace( name, "y-component", "" );
name = MDAL::replace( name, "y component of", "" );
name = MDAL::replace( name, "y component", "" );

name = MDAL::replace( name, "v-component of", "" );
name = MDAL::replace( name, "v-component", "" );
name = MDAL::replace( name, "v component of", "" );
name = MDAL::replace( name, "v component", "" );

name = MDAL::replace( name, "northward component of", "" );
name = MDAL::replace( name, "northward component", "" );
name = MDAL::replace( name, "northward", "" );

name = MDAL::replace( name, "meridional component of", "" );
name = MDAL::replace( name, "meridional component", "" );
name = MDAL::replace( name, "meridional", "" );

name = MDAL::trim( name );
}
else if ( MDAL::contains( longName, " magnitude" ) )
{
Expand Down

0 comments on commit a84bd13

Please sign in to comment.