Skip to content

Commit

Permalink
Add few opition for CAMS symbol plotting
Browse files Browse the repository at this point in the history
  • Loading branch information
sylvielamythepaut committed Nov 15, 2023
1 parent 9c60aef commit 131bb99
Show file tree
Hide file tree
Showing 5 changed files with 167 additions and 87 deletions.
70 changes: 49 additions & 21 deletions src/attributes/SymbolPlottingAttributes.cc
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,13 @@ SymbolPlottingAttributes::SymbolPlottingAttributes():
automatic_connect_colour_(ParameterManager::getBool("symbol_connect_automatic_line_colour")),
connect_thickness_(ParameterManager::getInt("symbol_connect_line_thickness")),
legend_only_(ParameterManager::getBool("symbol_legend_only")),
property_colour_name_(ParameterManager::getString("symbol_property_colour_name")),
property_colour_list_(ParameterManager::getStringArray("symbol_property_colour_list")),
property_colour_values_list_(ParameterManager::getDoubleArray("symbol_property_colour_values_list")),
property_hue_name_(ParameterManager::getString("symbol_property_hue_name")),
property_hue_list_(ParameterManager::getDoubleArray("symbol_property_hue_list")),
property_hue_values_list_(ParameterManager::getDoubleArray("symbol_property_hue_values_list")),
property_lightness_name_(ParameterManager::getString("symbol_property_lightness_name")),
property_lightness_list_(ParameterManager::getDoubleArray("symbol_property_lightness_list")),
property_lightness_values_list_(ParameterManager::getDoubleArray("symbol_property_lightness_values_list")),
property_saturation_value_(ParameterManager::getDouble("symbol_property_saturation_value")),
property_height_name_(ParameterManager::getString("symbol_property_height_name")),
property_height_scaling_factor_(ParameterManager::getDouble("symbol_property_height_scaling_factor")),
property_filter_name_(ParameterManager::getString("symbol_property_filter_name")),
Expand Down Expand Up @@ -81,9 +85,13 @@ void SymbolPlottingAttributes::set(const std::map<string, string>& params)
setAttribute(prefix, "symbol_connect_automatic_line_colour", automatic_connect_colour_, params);
setAttribute(prefix, "symbol_connect_line_thickness", connect_thickness_, params);
setAttribute(prefix, "symbol_legend_only", legend_only_, params);
setAttribute(prefix, "symbol_property_colour_name", property_colour_name_, params);
setAttribute(prefix, "symbol_property_colour_list", property_colour_list_, params);
setAttribute(prefix, "symbol_property_colour_values_list", property_colour_values_list_, params);
setAttribute(prefix, "symbol_property_hue_name", property_hue_name_, params);
setAttribute(prefix, "symbol_property_hue_list", property_hue_list_, params);
setAttribute(prefix, "symbol_property_hue_values_list", property_hue_values_list_, params);
setAttribute(prefix, "symbol_property_lightness_name", property_lightness_name_, params);
setAttribute(prefix, "symbol_property_lightness_list", property_lightness_list_, params);
setAttribute(prefix, "symbol_property_lightness_values_list", property_lightness_values_list_, params);
setAttribute(prefix, "symbol_property_saturation_value", property_saturation_value_, params);
setAttribute(prefix, "symbol_property_height_name", property_height_name_, params);
setAttribute(prefix, "symbol_property_height_scaling_factor", property_height_scaling_factor_, params);
setAttribute(prefix, "symbol_property_filter_name", property_filter_name_, params);
Expand Down Expand Up @@ -113,9 +121,13 @@ void SymbolPlottingAttributes::copy(const SymbolPlottingAttributes& other)
automatic_connect_colour_ = other.automatic_connect_colour_;
connect_thickness_ = other.connect_thickness_;
legend_only_ = other.legend_only_;
property_colour_name_ = other.property_colour_name_;
property_colour_list_ = other.property_colour_list_;
property_colour_values_list_ = other.property_colour_values_list_;
property_hue_name_ = other.property_hue_name_;
property_hue_list_ = other.property_hue_list_;
property_hue_values_list_ = other.property_hue_values_list_;
property_lightness_name_ = other.property_lightness_name_;
property_lightness_list_ = other.property_lightness_list_;
property_lightness_values_list_ = other.property_lightness_values_list_;
property_saturation_value_ = other.property_saturation_value_;
property_height_name_ = other.property_height_name_;
property_height_scaling_factor_ = other.property_height_scaling_factor_;
property_filter_name_ = other.property_filter_name_;
Expand Down Expand Up @@ -181,9 +193,13 @@ void SymbolPlottingAttributes::print(ostream& out) const
out << " automatic_connect_colour = " << automatic_connect_colour_;
out << " connect_thickness = " << connect_thickness_;
out << " legend_only = " << legend_only_;
out << " property_colour_name = " << property_colour_name_;
out << " property_colour_list = " << property_colour_list_;
out << " property_colour_values_list = " << property_colour_values_list_;
out << " property_hue_name = " << property_hue_name_;
out << " property_hue_list = " << property_hue_list_;
out << " property_hue_values_list = " << property_hue_values_list_;
out << " property_lightness_name = " << property_lightness_name_;
out << " property_lightness_list = " << property_lightness_list_;
out << " property_lightness_values_list = " << property_lightness_values_list_;
out << " property_saturation_value = " << property_saturation_value_;
out << " property_height_name = " << property_height_name_;
out << " property_height_scaling_factor = " << property_height_scaling_factor_;
out << " property_filter_name = " << property_filter_name_;
Expand Down Expand Up @@ -226,12 +242,20 @@ void SymbolPlottingAttributes::toxml(ostream& out) const
niceprint(out,connect_thickness_);
out << ", \"symbol_legend_only\":";
niceprint(out,legend_only_);
out << ", \"symbol_property_colour_name\":";
niceprint(out,property_colour_name_);
out << ", \"symbol_property_colour_list\":";
niceprint(out,property_colour_list_);
out << ", \"symbol_property_colour_values_list\":";
niceprint(out,property_colour_values_list_);
out << ", \"symbol_property_hue_name\":";
niceprint(out,property_hue_name_);
out << ", \"symbol_property_hue_list\":";
niceprint(out,property_hue_list_);
out << ", \"symbol_property_hue_values_list\":";
niceprint(out,property_hue_values_list_);
out << ", \"symbol_property_lightness_name\":";
niceprint(out,property_lightness_name_);
out << ", \"symbol_property_lightness_list\":";
niceprint(out,property_lightness_list_);
out << ", \"symbol_property_lightness_values_list\":";
niceprint(out,property_lightness_values_list_);
out << ", \"symbol_property_saturation_value\":";
niceprint(out,property_saturation_value_);
out << ", \"symbol_property_height_name\":";
niceprint(out,property_height_name_);
out << ", \"symbol_property_height_scaling_factor\":";
Expand Down Expand Up @@ -269,9 +293,13 @@ static MagicsParameter<string> symbol_connect_line("symbol_connect_line", "off")
static MagicsParameter<string> symbol_connect_automatic_line_colour("symbol_connect_automatic_line_colour", "on");
static MagicsParameter<int> symbol_connect_line_thickness("symbol_connect_line_thickness", 1);
static MagicsParameter<string> symbol_legend_only("symbol_legend_only", "off");
static MagicsParameter<string> symbol_property_colour_name("symbol_property_colour_name", "colour");
static MagicsParameter<stringarray> symbol_property_colour_list("symbol_property_colour_list", stringarray());
static MagicsParameter<doublearray> symbol_property_colour_values_list("symbol_property_colour_values_list", floatarray());
static MagicsParameter<string> symbol_property_hue_name("symbol_property_hue_name", "colour");
static MagicsParameter<doublearray> symbol_property_hue_list("symbol_property_hue_list", floatarray());
static MagicsParameter<doublearray> symbol_property_hue_values_list("symbol_property_hue_values_list", floatarray());
static MagicsParameter<string> symbol_property_lightness_name("symbol_property_lightness_name", "colour");
static MagicsParameter<doublearray> symbol_property_lightness_list("symbol_property_lightness_list", floatarray());
static MagicsParameter<doublearray> symbol_property_lightness_values_list("symbol_property_lightness_values_list", floatarray());
static MagicsParameter<double> symbol_property_saturation_value("symbol_property_saturation_value", 1);
static MagicsParameter<string> symbol_property_height_name("symbol_property_height_name", "colour");
static MagicsParameter<double> symbol_property_height_scaling_factor("symbol_property_height_scaling_factor", 1);
static MagicsParameter<string> symbol_property_filter_name("symbol_property_filter_name", "");
Expand Down
10 changes: 7 additions & 3 deletions src/attributes/SymbolPlottingAttributes.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,13 @@ class SymbolPlottingAttributes
bool automatic_connect_colour_;
int connect_thickness_;
bool legend_only_;
string property_colour_name_;
stringarray property_colour_list_;
doublearray property_colour_values_list_;
string property_hue_name_;
doublearray property_hue_list_;
doublearray property_hue_values_list_;
string property_lightness_name_;
doublearray property_lightness_list_;
doublearray property_lightness_values_list_;
double property_saturation_value_;
string property_height_name_;
double property_height_scaling_factor_;
string property_filter_name_;
Expand Down
46 changes: 32 additions & 14 deletions src/attributes/SymbolPlottingWrapper.cc
Original file line number Diff line number Diff line change
Expand Up @@ -115,20 +115,38 @@ void SymbolPlottingWrapper::set(const MagRequest& request)
symbolplotting_->legend_only_ = MagTranslator<string, bool>()(legend_only_value);

}
if (request.countValues("SYMBOL_PROPERTY_COLOUR_NAME") ) {
string property_colour_name_value = request("SYMBOL_PROPERTY_COLOUR_NAME");
symbolplotting_->property_colour_name_ = property_colour_name_value;
}
stringarray property_colour_list_value;
for (int i = 0; i < request.countValues("SYMBOL_PROPERTY_COLOUR_LIST"); i++)
property_colour_list_value.push_back((string)request("SYMBOL_PROPERTY_COLOUR_LIST", i));
if ( !property_colour_list_value.empty() )
symbolplotting_->property_colour_list_ = property_colour_list_value;
doublearray property_colour_values_list_value;
for (int i = 0; i < request.countValues("SYMBOL_PROPERTY_COLOUR_VALUES_LIST"); i++)
property_colour_values_list_value.push_back((double)request("SYMBOL_PROPERTY_COLOUR_VALUES_LIST", i));
if ( !property_colour_values_list_value.empty() )
symbolplotting_->property_colour_values_list_ = property_colour_values_list_value;
if (request.countValues("SYMBOL_PROPERTY_HUE_NAME") ) {
string property_hue_name_value = request("SYMBOL_PROPERTY_HUE_NAME");
symbolplotting_->property_hue_name_ = property_hue_name_value;
}
doublearray property_hue_list_value;
for (int i = 0; i < request.countValues("SYMBOL_PROPERTY_HUE_LIST"); i++)
property_hue_list_value.push_back((double)request("SYMBOL_PROPERTY_HUE_LIST", i));
if ( !property_hue_list_value.empty() )
symbolplotting_->property_hue_list_ = property_hue_list_value;
doublearray property_hue_values_list_value;
for (int i = 0; i < request.countValues("SYMBOL_PROPERTY_HUE_VALUES_LIST"); i++)
property_hue_values_list_value.push_back((double)request("SYMBOL_PROPERTY_HUE_VALUES_LIST", i));
if ( !property_hue_values_list_value.empty() )
symbolplotting_->property_hue_values_list_ = property_hue_values_list_value;
if (request.countValues("SYMBOL_PROPERTY_LIGHTNESS_NAME") ) {
string property_lightness_name_value = request("SYMBOL_PROPERTY_LIGHTNESS_NAME");
symbolplotting_->property_lightness_name_ = property_lightness_name_value;
}
doublearray property_lightness_list_value;
for (int i = 0; i < request.countValues("SYMBOL_PROPERTY_LIGHTNESS_LIST"); i++)
property_lightness_list_value.push_back((double)request("SYMBOL_PROPERTY_LIGHTNESS_LIST", i));
if ( !property_lightness_list_value.empty() )
symbolplotting_->property_lightness_list_ = property_lightness_list_value;
doublearray property_lightness_values_list_value;
for (int i = 0; i < request.countValues("SYMBOL_PROPERTY_LIGHTNESS_VALUES_LIST"); i++)
property_lightness_values_list_value.push_back((double)request("SYMBOL_PROPERTY_LIGHTNESS_VALUES_LIST", i));
if ( !property_lightness_values_list_value.empty() )
symbolplotting_->property_lightness_values_list_ = property_lightness_values_list_value;
if (request.countValues("SYMBOL_PROPERTY_SATURATION_VALUE") ) {
double property_saturation_value_value = request("SYMBOL_PROPERTY_SATURATION_VALUE");
symbolplotting_->property_saturation_value_ = property_saturation_value_value;
}
if (request.countValues("SYMBOL_PROPERTY_HEIGHT_NAME") ) {
string property_height_name_value = request("SYMBOL_PROPERTY_HEIGHT_NAME");
symbolplotting_->property_height_name_ = property_height_name_value;
Expand Down
52 changes: 43 additions & 9 deletions src/params/SymbolPlotting.xml
Original file line number Diff line number Diff line change
Expand Up @@ -252,31 +252,65 @@ does it submit to any jurisdiction.
<documentation>Inform the contour object do generate only the legend and not the plot .. [Web sdpecific]</documentation>
</parameter>
<!-- For the type property for CAMS -->
<parameter member="property_colour_name"
<parameter member="property_hue_name"
to="string"
default="colour"
from="string"
name="symbol_property_colour_name"
name="symbol_property_hue_name"
visible='off'>
<documentation>With GeoSon : property name to use to set the colour</documentation>
</parameter>
<parameter member="property_colour_list"
to="stringarray"
default="stringarray()"
from="stringarray"
name="symbol_property_colour_list"
<parameter member="property_hue_list"
to="floatarray"
default="floatarray()"
from="floatarray"
name="symbol_property_hue_list"
visible='off'>
<documentation>With GeoSon : list of colours to use</documentation>
</parameter>
<parameter member="property_colour_values_list"
<parameter member="property_hue_values_list"
to="floatarray"
default="floatarray()"
from="floatarray"
name="symbol_property_colour_values_list"
name="symbol_property_hue_values_list"
visible='off'>
<documentation>With GeoSon : list of heights to use</documentation>
</parameter>

<parameter member="property_lightness_name"
to="string"
default="colour"
from="string"
name="symbol_property_lightness_name"
visible='off'>
<documentation>With GeoSon : property name to use to set the colour</documentation>
</parameter>
<parameter member="property_lightness_list"
to="floatarray"
default="floatarray()"
from="floatarray"
name="symbol_property_lightness_list"
visible='off'>
<documentation>With GeoSon : list of colours to use</documentation>
</parameter>
<parameter member="property_lightness_values_list"
to="floatarray"
default="floatarray()"
from="floatarray"
name="symbol_property_lightness_values_list"
visible='off'>
<documentation>With GeoSon : list of heights to use</documentation>
</parameter>

<parameter member="property_saturation_value"
to="float"
default="1"
from="float"
name="symbol_property_saturation_value"
visible='off'>
<documentation>With GeoSon : list of colours to use</documentation>
</parameter>

<parameter member="property_height_name"
to="string"
default="colour"
Expand Down
76 changes: 36 additions & 40 deletions src/visualisers/SymbolPlotting.cc
Original file line number Diff line number Diff line change
Expand Up @@ -127,35 +127,48 @@ void SymbolPlotting::by_property(Data& data, BasicGraphicsObjectContainer& out)
std::set<string> needs;

needs.insert(property_height_name_);
needs.insert(property_colour_name_);
if ( property_filter_name_.size() )
needs.insert(property_filter_name_);
needs.insert(property_hue_name_);
needs.insert(property_lightness_name_);


if ( property_colour_list_.empty() )
property_colour_list_.push_back("red");
if ( property_hue_list_.empty() )
property_hue_list_.push_back(1);
if ( property_lightness_list_.empty() )
property_lightness_list_.push_back(0.5);


IntervalMap<Colour> colourFinder;
auto value = property_colour_values_list_.begin();
auto colour = property_colour_list_.begin();
IntervalMap<float> hueFinder;
auto value_hue = property_hue_values_list_.begin();
auto hue = property_hue_list_.begin();
IntervalMap<float> lightnessFinder;
auto value_lightness = property_lightness_values_list_.begin();
auto lightness = property_lightness_list_.begin();

while (true) {
if (value + 1 == property_colour_values_list_.end())
if (value_hue + 1 == property_hue_values_list_.end())
break;

colourFinder[Interval(*value, *(value+1))] = Colour(*colour);
if (colour + 1 != property_colour_list_.end())
colour++;
++value;
hueFinder[Interval(*value_hue, *(value_hue+1))] = *hue;
if (hue + 1 != property_hue_list_.end())
hue++;
++value_hue;
}
while (true) {
if (value_lightness + 1 == property_lightness_values_list_.end())
break;

lightnessFinder[Interval(*value_lightness, *(value_lightness+1))] = *lightness;
if (lightness + 1 != property_lightness_list_.end())
lightness++;
++value_lightness;
}



Colour red("red");

double factor = ( out.absoluteHeight()*transformation.patchDistance(1))/(transformation.getMaxPCY()-transformation.getMinPCY()) ;
// cout << "sacle--> " << factor << endl;
// cout << "patch--> " << transformation.patchDistance(1) << endl;

factor = magCompare(unit_method_, "geographical") ?
( out.absoluteHeight()*transformation.patchDistance(1))/(transformation.getMaxPCY()-transformation.getMinPCY()) : 1;

Expand All @@ -165,22 +178,18 @@ void SymbolPlotting::by_property(Data& data, BasicGraphicsObjectContainer& out)

for (auto& point : points) {
double val = 0;
if ( property_filter_name_.size() ) {
val = (*point)[property_filter_name_];
if ( val < property_filter_min_value_ )
continue;
if ( val >= property_filter_max_value_ )
continue;

}

double colour = (*point)[property_colour_name_];
double hue = (*point)[property_hue_name_];
double lightness = (*point)[property_lightness_name_];
double height = (*point)[property_height_name_];

Symbol* symbol = new Symbol();
symbol->setMarker(marker_);

symbol->setColour(colourFinder.find(colour, red));

Hsl hsl(hueFinder.find(hue, 0), property_saturation_value_, lightnessFinder.find(lightness, 0.5));
Colour colour(hsl);
symbol->setColour(colour);


if ( height*property_height_scaling_factor_ > 2 ) {
Expand Down Expand Up @@ -221,25 +230,12 @@ void SymbolPlotting::operator()(Data& data, BasicGraphicsObjectContainer& out) {

const Transformation& transformation = out.transformation();

// cout << "absolut width " << out.absoluteWidth() << endl;
// cout << "absolut height " << out.absoluteHeight() << endl;
// cout << "pcminy " << transformation.getMinPCY() << endl;
// cout << "pcmaxy " << transformation.getMaxPCY() << endl;

// cout << "unit " << unit_method_ << endl;

double factor = ( out.absoluteHeight()*transformation.patchDistance(1))/(transformation.getMaxPCY()-transformation.getMinPCY()) ;
// cout << "sacle--> " << factor << endl;
// cout << "patch--> " << transformation.patchDistance(1) << endl;

factor = magCompare(unit_method_, "geographical") ?
( out.absoluteHeight()*transformation.patchDistance(1))/(transformation.getMaxPCY()-transformation.getMinPCY()) : 1;

// cout << "abs-height->"<< out.absoluteHeight() << endl;
// cout << "patch->" << transformation.patchDistance(1) << endl;
// cout << "pc height --> " << transformation.getMaxPCY()-transformation.getMinPCY() << endl;

// cout << "factor-->" << factor << endl;


bool valid = false;

for (vector<string>::iterator c = check.begin(); c != check.end(); ++c) {
Expand Down

0 comments on commit 131bb99

Please sign in to comment.