Skip to content

Commit

Permalink
[MESH] scalar color settings depending on classification (#36313)
Browse files Browse the repository at this point in the history
* [MESH] [FEATURE] Sets meh color ramp classification from metadata read by MDAL driver.
Some mesh layer formats can provide values that can be compressed by categorizing values in consecutive intervals, each represent by an integer or byte. MDAL has the capabilities to recognize this dataset type and store the bounds of each class an the units in the metadata.
QGIS uses this metadata to setup adapted color ramp shader.

* [MDAL] update to pre-release 0.5.92
  • Loading branch information
vcloarec committed May 11, 2020
1 parent b6a7a10 commit fca90a7
Show file tree
Hide file tree
Showing 23 changed files with 518 additions and 61 deletions.
16 changes: 15 additions & 1 deletion external/mdal/frmts/mdal_3di.cpp
Expand Up @@ -194,10 +194,16 @@ std::set<std::string> MDAL::Driver3Di::ignoreNetCDFVariables()
return ignore_variables;
}

void MDAL::Driver3Di::parseNetCDFVariableMetadata( int varid, const std::string &variableName, std::string &name, bool *is_vector, bool *is_x )
void MDAL::Driver3Di::parseNetCDFVariableMetadata( int varid,
std::string &variableName,
std::string &name,
bool *is_vector,
bool *isPolar,
bool *is_x )
{
*is_vector = false;
*is_x = true;
*isPolar = false;

std::string long_name = mNcFile->getAttrStr( "long_name", varid );
if ( long_name.empty() )
Expand All @@ -209,6 +215,7 @@ void MDAL::Driver3Di::parseNetCDFVariableMetadata( int varid, const std::string
}
else
{
variableName = standard_name;
if ( MDAL::contains( standard_name, "_x_" ) )
{
*is_vector = true;
Expand All @@ -228,6 +235,7 @@ void MDAL::Driver3Di::parseNetCDFVariableMetadata( int varid, const std::string
}
else
{
variableName = long_name;
if ( MDAL::contains( long_name, " in x direction" ) )
{
*is_vector = true;
Expand All @@ -245,3 +253,9 @@ void MDAL::Driver3Di::parseNetCDFVariableMetadata( int varid, const std::string
}
}
}

std::vector<std::pair<double, double>> MDAL::Driver3Di::parseClassification( int varid ) const
{
MDAL_UNUSED( varid );
return std::vector<std::pair<double, double>>();
}
9 changes: 7 additions & 2 deletions external/mdal/frmts/mdal_3di.hpp
Expand Up @@ -50,8 +50,13 @@ namespace MDAL
std::string getCoordinateSystemVariableName() override;
std::string getTimeVariableName() const override;
std::set<std::string> ignoreNetCDFVariables() override;
void parseNetCDFVariableMetadata( int varid, const std::string &variableName,
std::string &name, bool *is_vector, bool *is_x ) override;
void parseNetCDFVariableMetadata( int varid,
std::string &variableName,
std::string &name,
bool *is_vector,
bool *isPolar,
bool *is_x ) override;
std::vector<std::pair<double, double>> parseClassification( int varid ) const override;

//! Returns number of vertices
size_t parse2DMesh();
Expand Down

0 comments on commit fca90a7

Please sign in to comment.