From 5d4efa80c3833aad9fd5d24fde548eac1ff201c9 Mon Sep 17 00:00:00 2001 From: Sylvie Lamy-Thepaut Date: Tue, 26 Sep 2023 11:21:47 +0100 Subject: [PATCH] CAMS Addtion: adding few options for CAMS symbol plottings --- src/attributes/SymbolPlottingAttributes.cc | 65 ++++++++++++++- src/attributes/SymbolPlottingAttributes.h | 9 ++ src/attributes/SymbolPlottingWrapper.cc | 38 +++++++++ src/params/SymbolPlotting.xml | 77 ++++++++++++++++- src/visualisers/SymbolPlotting.cc | 97 ++++++++++++++++++++++ src/visualisers/SymbolPlotting.h | 1 + 6 files changed, 285 insertions(+), 2 deletions(-) diff --git a/src/attributes/SymbolPlottingAttributes.cc b/src/attributes/SymbolPlottingAttributes.cc index 2d1fbd6df..1c11550b0 100644 --- a/src/attributes/SymbolPlottingAttributes.cc +++ b/src/attributes/SymbolPlottingAttributes.cc @@ -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().magics("symbol_table_mode")), outline_colour_(MagTranslator().magics("symbol_outline_colour")), @@ -72,6 +81,15 @@ void SymbolPlottingAttributes::set(const std::map& 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); @@ -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(other.mode_->clone()); outline_colour_ = unique_ptr(other.outline_colour_->clone()); outline_style_ = other.outline_style_; @@ -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_; @@ -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\":"; @@ -215,6 +269,15 @@ static MagicsParameter symbol_connect_line("symbol_connect_line", "off") static MagicsParameter symbol_connect_automatic_line_colour("symbol_connect_automatic_line_colour", "on"); static MagicsParameter symbol_connect_line_thickness("symbol_connect_line_thickness", 1); static MagicsParameter symbol_legend_only("symbol_legend_only", "off"); +static MagicsParameter symbol_property_colour_name("symbol_property_colour_name", "colour"); +static MagicsParameter symbol_property_colour_list("symbol_property_colour_list", stringarray()); +static MagicsParameter symbol_property_colour_values_list("symbol_property_colour_values_list", floatarray()); +static MagicsParameter symbol_property_height_name("symbol_property_height_name", "colour"); +static MagicsParameter symbol_property_height_scaling_factor("symbol_property_height_scaling_factor", 1); +static MagicsParameter symbol_property_filter_name("symbol_property_filter_name", ""); +static MagicsParameter symbol_property_filter_min_value("symbol_property_filter_min_value", LLONG_MIN); +static MagicsParameter symbol_property_filter_max_value("symbol_property_filter_max_value", LLONG_MAX); +static MagicsParameter symbol_marker_index("symbol_marker_index", 1); static MagicsParameter symbol_table_mode("symbol_table_mode", "OFF"); static MagicsParameter symbol_outline_colour("symbol_outline_colour", "black"); static MagicsParameter symbol_outline_style("symbol_outline_style", "solid"); diff --git a/src/attributes/SymbolPlottingAttributes.h b/src/attributes/SymbolPlottingAttributes.h index ea7239de8..23655451a 100644 --- a/src/attributes/SymbolPlottingAttributes.h +++ b/src/attributes/SymbolPlottingAttributes.h @@ -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 mode_; unique_ptr outline_colour_; LineStyle outline_style_; diff --git a/src/attributes/SymbolPlottingWrapper.cc b/src/attributes/SymbolPlottingWrapper.cc index f643d7423..d2520cd10 100644 --- a/src/attributes/SymbolPlottingWrapper.cc +++ b/src/attributes/SymbolPlottingWrapper.cc @@ -115,6 +115,44 @@ void SymbolPlottingWrapper::set(const MagRequest& request) symbolplotting_->legend_only_ = MagTranslator()(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"; diff --git a/src/params/SymbolPlotting.xml b/src/params/SymbolPlotting.xml index 9168e5276..525edfe79 100644 --- a/src/params/SymbolPlotting.xml +++ b/src/params/SymbolPlotting.xml @@ -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"> Defines the type of symbol plotting required @@ -251,5 +251,80 @@ does it submit to any jurisdiction. visible='off'> Inform the contour object do generate only the legend and not the plot .. [Web sdpecific] + + + With GeoSon : property name to use to set the colour + + + With GeoSon : list of colours to use + + + With GeoSon : list of heights to use + + + + With GeoSon : property name to use to set the colour + + + With GeoSon : property name to use to set the colour + + + + With GeoSon : property name to use to set the colour + + + With GeoSon : property name to use to set the colour + + + With GeoSon : property name to use to set the colour + + + Marker indice: An integer between 1 and 28 + + diff --git a/src/visualisers/SymbolPlotting.cc b/src/visualisers/SymbolPlotting.cc index 834b0dd06..b9d44a47c 100644 --- a/src/visualisers/SymbolPlotting.cc +++ b/src/visualisers/SymbolPlotting.cc @@ -28,6 +28,8 @@ #include "LegendVisitor.h" #include "MagicsGlobal.h" +#include "IntervalMap.h" + using namespace magics; @@ -117,10 +119,99 @@ struct SortHelper { }; + +void SymbolPlotting::by_property(Data& data, BasicGraphicsObjectContainer& out) { + + const Transformation& transformation = out.transformation(); + + std::set 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 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 check; check.push_back("text"); check.push_back("number"); @@ -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::iterator c = check.begin(); c != check.end(); ++c) { diff --git a/src/visualisers/SymbolPlotting.h b/src/visualisers/SymbolPlotting.h index 0005acdf7..3811571ca 100644 --- a/src/visualisers/SymbolPlotting.h +++ b/src/visualisers/SymbolPlotting.h @@ -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;