Skip to content

Commit

Permalink
MDAL 0.8.1
Browse files Browse the repository at this point in the history
  • Loading branch information
PeterPetrik authored and nyalldawson committed Jun 6, 2021
1 parent 75e7e6c commit 25ca993
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 24 deletions.
3 changes: 1 addition & 2 deletions external/mdal/frmts/mdal_binary_dat.cpp
Expand Up @@ -333,9 +333,8 @@ bool MDAL::DriverBinaryDat::readVertexTimestep(
{
if ( readIStat( in, sflg, reinterpret_cast< char * >( &active ) ) )
return true; //error

dataset->setActive( i, active );
}
dataset->setActive( i, active );
}

for ( size_t i = 0; i < vertexCount; ++i )
Expand Down
2 changes: 1 addition & 1 deletion external/mdal/frmts/mdal_dynamic_driver.cpp
Expand Up @@ -6,7 +6,7 @@

#include "mdal_dynamic_driver.hpp"
#include "mdal_logger.hpp"
#if !defined(WIN32)
#if not defined (WIN32)
#include <dlfcn.h>
#endif
#include <string.h>
Expand Down
51 changes: 31 additions & 20 deletions external/mdal/frmts/mdal_gdal.cpp
Expand Up @@ -564,39 +564,50 @@ std::unique_ptr<MDAL::Mesh> MDAL::DriverGdal::load( const std::string &fileName,

// some formats like NETCFD has data stored in subdatasets
std::vector<std::string> subdatasets = parseDatasetNames( mFileName );

// First parse ALL datasets/bands to gather vector quantities
// if case they are splitted in different subdatasets
// Parse all the dataset
// For consistency, search the first dataset with a projection and store it first to use it as reference for the mesh
// store other dataset in a std::vector
std::vector<std::shared_ptr<MDAL::GdalDataset>> datasets;
bool firstProjFound = false;
for ( auto iter = subdatasets.begin(); iter != subdatasets.end(); ++iter )
{
std::string gdal_dataset_name = *iter;
// Parse dataset parameters and projection
std::shared_ptr<MDAL::GdalDataset> cfGDALDataset = std::make_shared<MDAL::GdalDataset>();
cfGDALDataset->init( gdal_dataset_name );

if ( !mMesh )
if ( !firstProjFound && !cfGDALDataset->mProj.empty() )
{
// If it is first dataset, create mesh from it
firstProjFound = true;
gdal_datasets.push_back( cfGDALDataset );

// Init memory for data reader
mPafScanline = new double [cfGDALDataset->mXSize];

// Create mMesh
createMesh();

// Parse bands
parseRasterBands( cfGDALDataset.get() );

}
else if ( meshes_equals( meshGDALDataset(), cfGDALDataset.get() ) )
else
{
gdal_datasets.push_back( cfGDALDataset );
// Parse bands
parseRasterBands( cfGDALDataset.get() );
datasets.push_back( cfGDALDataset );
}
}

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

// Construct the mesh with the first dataset
if ( !gdal_datasets.empty() )
{
std::shared_ptr<MDAL::GdalDataset> meshDataset = gdal_datasets.at( 0 );
// Init memory for data reader
mPafScanline = new double [meshDataset->mXSize];
// Create mMesh
createMesh();
}

// parse all datasets
for ( auto iter = gdal_datasets.begin(); iter != gdal_datasets.end(); ++iter )
{
std::shared_ptr<MDAL::GdalDataset> cfGDALDataset = std::make_shared<MDAL::GdalDataset>();
parseRasterBands( iter->get() );
}

// Fix consistency of groups
// It can happen that we thought that the
// group is vector based on name, but it could be just coicidence
Expand All @@ -621,7 +632,7 @@ std::unique_ptr<MDAL::Mesh> MDAL::DriverGdal::load( const std::string &fileName,

if ( mPafScanline ) delete[] mPafScanline;

// do not allow mesh without any valid datasets
// do not allow mesh without any valid datasets
if ( mMesh && ( mMesh->datasetGroups.empty() ) )
{
MDAL::Log::error( MDAL_Status::Err_InvalidData, name(), "Mesh does not have any valid dataset" );
Expand Down
2 changes: 1 addition & 1 deletion external/mdal/mdal.cpp
Expand Up @@ -21,7 +21,7 @@ static const char *EMPTY_STR = "";

const char *MDAL_Version()
{
return "0.8.0";
return "0.8.1";
}

MDAL_Status MDAL_LastStatus()
Expand Down

0 comments on commit 25ca993

Please sign in to comment.