mirror of
https://github.com/qgis/QGIS.git
synced 2025-10-08 00:05:09 -04:00
update MDAL to 0.4.94
This commit is contained in:
parent
51c2f0ffad
commit
a2a80976c2
2
external/mdal/frmts/mdal_2dm.cpp
vendored
2
external/mdal/frmts/mdal_2dm.cpp
vendored
@ -98,7 +98,7 @@ bool MDAL::Driver2dm::canReadMesh( const std::string &uri )
|
||||
{
|
||||
std::ifstream in( uri, std::ifstream::in );
|
||||
std::string line;
|
||||
if ( !std::getline( in, line ) || !startsWith( line, "MESH2D" ) )
|
||||
if ( !MDAL::getHeaderLine( in, line ) || !startsWith( line, "MESH2D" ) )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
13
external/mdal/frmts/mdal_ascii_dat.cpp
vendored
13
external/mdal/frmts/mdal_ascii_dat.cpp
vendored
@ -44,7 +44,7 @@ bool MDAL::DriverAsciiDat::canReadDatasets( const std::string &uri )
|
||||
{
|
||||
std::ifstream in( uri, std::ifstream::in );
|
||||
std::string line;
|
||||
if ( !std::getline( in, line ) )
|
||||
if ( !MDAL::getHeaderLine( in, line ) )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@ -57,7 +57,8 @@ bool MDAL::DriverAsciiDat::canReadOldFormat( const std::string &line ) const
|
||||
{
|
||||
return MDAL::contains( line, "SCALAR" ) ||
|
||||
MDAL::contains( line, "VECTOR" ) ||
|
||||
MDAL::contains( line, "TS" );
|
||||
MDAL::contains( line, "TS" ) ||
|
||||
MDAL::contains( line, "TIMEUNITS" );
|
||||
}
|
||||
|
||||
bool MDAL::DriverAsciiDat::canReadNewFormat( const std::string &line ) const
|
||||
@ -85,7 +86,7 @@ void MDAL::DriverAsciiDat::loadOldFormat( std::ifstream &in,
|
||||
);
|
||||
group->setIsScalar( !isVector );
|
||||
group->setDataLocation( MDAL_DataLocation::DataOnVertices2D );
|
||||
|
||||
MDAL::RelativeTimestamp::Unit timeUnits = MDAL::RelativeTimestamp::hours;
|
||||
do
|
||||
{
|
||||
// Replace tabs by spaces,
|
||||
@ -114,10 +115,14 @@ void MDAL::DriverAsciiDat::loadOldFormat( std::ifstream &in,
|
||||
{
|
||||
// just ignore - we know the type from earlier...
|
||||
}
|
||||
else if ( cardType == "TIMEUNITS" && items.size() >= 2 )
|
||||
{
|
||||
timeUnits = MDAL::parseDurationTimeUnit( items[1] );
|
||||
}
|
||||
else if ( cardType == "TS" && items.size() >= 2 )
|
||||
{
|
||||
double rawTime = toDouble( items[ 1 ] );
|
||||
MDAL::RelativeTimestamp t( rawTime, MDAL::RelativeTimestamp::hours );
|
||||
MDAL::RelativeTimestamp t( rawTime, timeUnits );
|
||||
readVertexTimestep( mesh, group, t, isVector, false, in );
|
||||
}
|
||||
else
|
||||
|
4
external/mdal/frmts/mdal_gdal.cpp
vendored
4
external/mdal/frmts/mdal_gdal.cpp
vendored
@ -628,6 +628,7 @@ void MDAL::DriverGdal::parseBandIsVector( std::string &band_name, bool *is_vecto
|
||||
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::contains( band_name, "x-component", MDAL::CaseInsensitive ) ||
|
||||
MDAL::contains( band_name, "x component", MDAL::CaseInsensitive ) )
|
||||
{
|
||||
@ -639,6 +640,7 @@ void MDAL::DriverGdal::parseBandIsVector( std::string &band_name, bool *is_vecto
|
||||
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::contains( band_name, "y-component", MDAL::CaseInsensitive ) ||
|
||||
MDAL::contains( band_name, "y component", MDAL::CaseInsensitive ) )
|
||||
{
|
||||
@ -657,6 +659,8 @@ void MDAL::DriverGdal::parseBandIsVector( std::string &band_name, bool *is_vecto
|
||||
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", "", MDAL::CaseInsensitive );
|
||||
|
2
external/mdal/frmts/mdal_gdal_grib.cpp
vendored
2
external/mdal/frmts/mdal_gdal_grib.cpp
vendored
@ -30,7 +30,7 @@ bool MDAL::DriverGdalGrib::parseBandInfo( const MDAL::GdalDataset *cfGDALDataset
|
||||
MDAL::RelativeTimestamp *time, bool *is_vector, bool *is_x
|
||||
)
|
||||
{
|
||||
MDAL_UNUSED( cfGDALDataset );
|
||||
MDAL_UNUSED( cfGDALDataset )
|
||||
|
||||
metadata_hash::const_iterator iter;
|
||||
|
||||
|
2
external/mdal/frmts/mdal_tuflowfv.cpp
vendored
2
external/mdal/frmts/mdal_tuflowfv.cpp
vendored
@ -457,7 +457,7 @@ void MDAL::DriverTuflowFV::parseNetCDFVariableMetadata( int varid, const std::st
|
||||
*is_x = true;
|
||||
|
||||
std::string long_name = mNcFile->getAttrStr( "long_name", varid );
|
||||
if ( long_name.empty() )
|
||||
if ( long_name.empty() || ( long_name == "??????" ) )
|
||||
{
|
||||
name = variableName;
|
||||
}
|
||||
|
2
external/mdal/mdal.cpp
vendored
2
external/mdal/mdal.cpp
vendored
@ -22,7 +22,7 @@ static MDAL_Status sLastStatus;
|
||||
|
||||
const char *MDAL_Version()
|
||||
{
|
||||
return "0.4.93";
|
||||
return "0.4.94";
|
||||
}
|
||||
|
||||
MDAL_Status MDAL_LastStatus()
|
||||
|
30
external/mdal/mdal_utils.cpp
vendored
30
external/mdal/mdal_utils.cpp
vendored
@ -296,7 +296,16 @@ std::string MDAL::ltrim( const std::string &s, const std::string &delimiters )
|
||||
if ( s.empty() )
|
||||
return s;
|
||||
|
||||
return s.substr( s.find_first_not_of( delimiters ) );
|
||||
size_t found = s.find_first_not_of( delimiters );
|
||||
|
||||
if ( found == std::string::npos )
|
||||
{
|
||||
return "";
|
||||
}
|
||||
else
|
||||
{
|
||||
return s.substr( found );
|
||||
}
|
||||
}
|
||||
|
||||
// http://www.cplusplus.com/faq/sequences/strings/trim/
|
||||
@ -305,7 +314,15 @@ std::string MDAL::rtrim( const std::string &s, const std::string &delimiters )
|
||||
if ( s.empty() )
|
||||
return s;
|
||||
|
||||
return s.substr( 0, s.find_last_not_of( delimiters ) + 1 );
|
||||
size_t found = s.find_last_not_of( delimiters );
|
||||
if ( found == std::string::npos )
|
||||
{
|
||||
return "";
|
||||
}
|
||||
else
|
||||
{
|
||||
return s.substr( 0, found + 1 );
|
||||
}
|
||||
}
|
||||
|
||||
MDAL::BBox MDAL::computeExtent( const MDAL::Vertices &vertices )
|
||||
@ -772,3 +789,12 @@ MDAL::DateTime MDAL::parseCFReferenceTime( const std::string &timeInformation, c
|
||||
|
||||
return MDAL::DateTime( year, month, day, hours, minutes, seconds, calendar );
|
||||
}
|
||||
|
||||
bool MDAL::getHeaderLine( std::ifstream &stream, std::string &line )
|
||||
{
|
||||
if ( !stream.is_open() ) return false;
|
||||
char b[100] = "";
|
||||
if ( ! stream.get( b, sizeof( b ) - 1, '\n' ) ) return false;
|
||||
line = std::string( b );
|
||||
return true;
|
||||
}
|
||||
|
4
external/mdal/mdal_utils.hpp
vendored
4
external/mdal/mdal_utils.hpp
vendored
@ -12,6 +12,7 @@
|
||||
#include <limits>
|
||||
#include <sstream>
|
||||
#include <fstream>
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
#include "mdal_data_model.hpp"
|
||||
@ -60,6 +61,9 @@ namespace MDAL
|
||||
|
||||
std::string toLower( const std::string &std );
|
||||
|
||||
//! Get a first line from stream clipped to first 100 characters
|
||||
bool getHeaderLine( std::ifstream &stream, std::string &line );
|
||||
|
||||
/** Return 0 if not possible to convert */
|
||||
size_t toSizeT( const std::string &str );
|
||||
size_t toSizeT( const char &str );
|
||||
|
Loading…
x
Reference in New Issue
Block a user