Skip to content

Commit

Permalink
CAMS Addtion: adding few options for CAMS symbol plottings
Browse files Browse the repository at this point in the history
  • Loading branch information
sylvielamythepaut committed Sep 26, 2023
1 parent b276ff6 commit 5d4efa8
Show file tree
Hide file tree
Showing 6 changed files with 285 additions and 2 deletions.
65 changes: 64 additions & 1 deletion src/attributes/SymbolPlottingAttributes.cc
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,16 @@ SymbolPlottingAttributes::SymbolPlottingAttributes():
connect_(ParameterManager::getBool("symbol_connect_line")),
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"))
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_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")),
property_filter_min_value_(ParameterManager::getDouble("symbol_property_filter_min_value")),
property_filter_max_value_(ParameterManager::getDouble("symbol_property_filter_max_value")),
marker_(ParameterManager::getInt("symbol_marker_index"))
,
mode_(MagTranslator<string, SymbolMode>().magics("symbol_table_mode")),
outline_colour_(MagTranslator<string, Colour>().magics("symbol_outline_colour")),
Expand Down Expand Up @@ -72,6 +81,15 @@ 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_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);
setAttribute(prefix, "symbol_property_filter_min_value", property_filter_min_value_, params);
setAttribute(prefix, "symbol_property_filter_max_value", property_filter_max_value_, params);
setAttribute(prefix, "symbol_marker_index", marker_, params);

setMember(prefix, "symbol_table_mode", mode_, params);
setMember(prefix, "symbol_outline_colour", outline_colour_, params);
Expand All @@ -95,6 +113,15 @@ 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_height_name_ = other.property_height_name_;
property_height_scaling_factor_ = other.property_height_scaling_factor_;
property_filter_name_ = other.property_filter_name_;
property_filter_min_value_ = other.property_filter_min_value_;
property_filter_max_value_ = other.property_filter_max_value_;
marker_ = other.marker_;
mode_ = unique_ptr<SymbolMode>(other.mode_->clone());
outline_colour_ = unique_ptr<Colour>(other.outline_colour_->clone());
outline_style_ = other.outline_style_;
Expand Down Expand Up @@ -154,6 +181,15 @@ 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_height_name = " << property_height_name_;
out << " property_height_scaling_factor = " << property_height_scaling_factor_;
out << " property_filter_name = " << property_filter_name_;
out << " property_filter_min_value = " << property_filter_min_value_;
out << " property_filter_max_value = " << property_filter_max_value_;
out << " marker = " << marker_;
out << " mode = " << *mode_;
out << " outline_colour = " << *outline_colour_;
out << " outline_style = " << outline_style_;
Expand Down Expand Up @@ -190,6 +226,24 @@ 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_height_name\":";
niceprint(out,property_height_name_);
out << ", \"symbol_property_height_scaling_factor\":";
niceprint(out,property_height_scaling_factor_);
out << ", \"symbol_property_filter_name\":";
niceprint(out,property_filter_name_);
out << ", \"symbol_property_filter_min_value\":";
niceprint(out,property_filter_min_value_);
out << ", \"symbol_property_filter_max_value\":";
niceprint(out,property_filter_max_value_);
out << ", \"symbol_marker_index\":";
niceprint(out,marker_);
out << ", \"symbol_table_mode\":";
mode_->toxml(out);
out << ", \"symbol_outline_colour\":";
Expand All @@ -215,6 +269,15 @@ 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_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", "");
static MagicsParameter<double> symbol_property_filter_min_value("symbol_property_filter_min_value", LLONG_MIN);
static MagicsParameter<double> symbol_property_filter_max_value("symbol_property_filter_max_value", LLONG_MAX);
static MagicsParameter<int> symbol_marker_index("symbol_marker_index", 1);
static MagicsParameter<string> symbol_table_mode("symbol_table_mode", "OFF");
static MagicsParameter<string> symbol_outline_colour("symbol_outline_colour", "black");
static MagicsParameter<string> symbol_outline_style("symbol_outline_style", "solid");
Expand Down
9 changes: 9 additions & 0 deletions src/attributes/SymbolPlottingAttributes.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,15 @@ 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_height_name_;
double property_height_scaling_factor_;
string property_filter_name_;
double property_filter_min_value_;
double property_filter_max_value_;
int marker_;
unique_ptr<SymbolMode> mode_;
unique_ptr<Colour> outline_colour_;
LineStyle outline_style_;
Expand Down
38 changes: 38 additions & 0 deletions src/attributes/SymbolPlottingWrapper.cc
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,44 @@ 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_HEIGHT_NAME") ) {
string property_height_name_value = request("SYMBOL_PROPERTY_HEIGHT_NAME");
symbolplotting_->property_height_name_ = property_height_name_value;
}
if (request.countValues("SYMBOL_PROPERTY_HEIGHT_SCALING_FACTOR") ) {
double property_height_scaling_factor_value = request("SYMBOL_PROPERTY_HEIGHT_SCALING_FACTOR");
symbolplotting_->property_height_scaling_factor_ = property_height_scaling_factor_value;
}
if (request.countValues("SYMBOL_PROPERTY_FILTER_NAME") ) {
string property_filter_name_value = request("SYMBOL_PROPERTY_FILTER_NAME");
symbolplotting_->property_filter_name_ = property_filter_name_value;
}
if (request.countValues("SYMBOL_PROPERTY_FILTER_MIN_VALUE") ) {
double property_filter_min_value_value = request("SYMBOL_PROPERTY_FILTER_MIN_VALUE");
symbolplotting_->property_filter_min_value_ = property_filter_min_value_value;
}
if (request.countValues("SYMBOL_PROPERTY_FILTER_MAX_VALUE") ) {
double property_filter_max_value_value = request("SYMBOL_PROPERTY_FILTER_MAX_VALUE");
symbolplotting_->property_filter_max_value_ = property_filter_max_value_value;
}
if (request.countValues("SYMBOL_MARKER_INDEX") ) {
int marker_value = request("SYMBOL_MARKER_INDEX");
symbolplotting_->marker_ = marker_value;
}


string mode_value = request.countValues("SYMBOL_TABLE_MODE") ? (string) request("SYMBOL_TABLE_MODE") : "OFF";
Expand Down
77 changes: 76 additions & 1 deletion src/params/SymbolPlotting.xml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ does it submit to any jurisdiction.
default="number"
member="type"
to="string"
values="number/text/marker/wind">
values="number/text/marker/wind/property">
<documentation>Defines the type of symbol plotting required</documentation>
<set name="symbol_text_list" value="text"></set>
<set name="symbol_text_position" value="text"></set>
Expand Down Expand Up @@ -251,5 +251,80 @@ does it submit to any jurisdiction.
visible='off'>
<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"
to="string"
default="colour"
from="string"
name="symbol_property_colour_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"
visible='off'>
<documentation>With GeoSon : list of colours to use</documentation>
</parameter>
<parameter member="property_colour_values_list"
to="floatarray"
default="floatarray()"
from="floatarray"
name="symbol_property_colour_values_list"
visible='off'>
<documentation>With GeoSon : list of heights to use</documentation>
</parameter>

<parameter member="property_height_name"
to="string"
default="colour"
from="string"
name="symbol_property_height_name"
visible='off'>
<documentation>With GeoSon : property name to use to set the colour</documentation>
</parameter>
<parameter member="property_height_scaling_factor"
to="float"
default="1"
from="float"
name="symbol_property_height_scaling_factor"
visible='off'>
<documentation>With GeoSon : property name to use to set the colour</documentation>
</parameter>

<parameter member="property_filter_name"
to="string"
default=""
from="string"
name="symbol_property_filter_name"
visible='off'>
<documentation>With GeoSon : property name to use to set the colour</documentation>
</parameter>
<parameter member="property_filter_min_value"
to="float"
default="LLONG_MIN"
from="float"
name="symbol_property_filter_min_value"
visible='off'>
<documentation>With GeoSon : property name to use to set the colour</documentation>
</parameter>
<parameter member="property_filter_max_value"
to="float"
default="LLONG_MAX"
from="float"
name="symbol_property_filter_max_value"
visible='off'>
<documentation>With GeoSon : property name to use to set the colour</documentation>
</parameter>
<parameter member="marker"
to="int"
default="1"
from="int"
name="symbol_marker_index">
<documentation>Marker indice: An integer between 1 and 28</documentation>
</parameter>

</class>
</magics>
97 changes: 97 additions & 0 deletions src/visualisers/SymbolPlotting.cc
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
#include "LegendVisitor.h"
#include "MagicsGlobal.h"

#include "IntervalMap.h"

using namespace magics;


Expand Down Expand Up @@ -117,10 +119,99 @@ struct SortHelper {
};



void SymbolPlotting::by_property(Data& data, BasicGraphicsObjectContainer& out) {

const Transformation& transformation = out.transformation();

std::set<string> needs;

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

if ( property_colour_list_.empty() )
property_colour_list_.push_back("red");


IntervalMap<Colour> colourFinder;
auto value = property_colour_values_list_.begin();
auto colour = property_colour_list_.begin();

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

colourFinder[Interval(*value, *(value+1))] = Colour(*colour);
if (colour + 1 != property_colour_list_.end())
colour++;
++value;
}



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;


CustomisedPointsList points;
data.customisedPoints(out.transformation(), needs, points, true);

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 height = (*point)[property_height_name_];

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

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


if ( height*property_height_scaling_factor_ > 2 ) {
height = 2*factor;
MagLog::warning() << " Symbol height reset to 2 " << endl;
}
else
height = height*property_height_scaling_factor_*factor;

symbol->setHeight(height);

symbol->push_back(transformation(PaperPoint(point->longitude(), point->latitude())));

out.push_back(symbol);

}



}


void SymbolPlotting::operator()(Data& data, BasicGraphicsObjectContainer& out) {
mode_->parent(this);
mode_->prepare();
symbols_.clear();


if ( magCompare("property", type_) )
return by_property(data, out);

vector<string> check;
check.push_back("text");
check.push_back("number");
Expand All @@ -143,6 +234,12 @@ void SymbolPlotting::operator()(Data& data, BasicGraphicsObjectContainer& out) {
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
1 change: 1 addition & 0 deletions src/visualisers/SymbolPlotting.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ class SymbolPlotting : public SymbolPlottingAttributes, public Visdef {


virtual void operator()(Data&, BasicGraphicsObjectContainer&) override;
void by_property(Data&, BasicGraphicsObjectContainer&);
virtual void visit(Data&, LegendVisitor&) override;
bool needLegend() override { return legend_; }
virtual void visit(Data&, HistoVisitor&) override;
Expand Down

0 comments on commit 5d4efa8

Please sign in to comment.