diff --git a/src/attributes/SymbolPlottingAttributes.cc b/src/attributes/SymbolPlottingAttributes.cc index 1c11550b..72b0c0f6 100644 --- a/src/attributes/SymbolPlottingAttributes.cc +++ b/src/attributes/SymbolPlottingAttributes.cc @@ -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")), @@ -81,9 +85,13 @@ 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_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); @@ -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_; @@ -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_; @@ -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\":"; @@ -269,9 +293,13 @@ 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_hue_name("symbol_property_hue_name", "colour"); +static MagicsParameter symbol_property_hue_list("symbol_property_hue_list", floatarray()); +static MagicsParameter symbol_property_hue_values_list("symbol_property_hue_values_list", floatarray()); +static MagicsParameter symbol_property_lightness_name("symbol_property_lightness_name", "colour"); +static MagicsParameter symbol_property_lightness_list("symbol_property_lightness_list", floatarray()); +static MagicsParameter symbol_property_lightness_values_list("symbol_property_lightness_values_list", floatarray()); +static MagicsParameter symbol_property_saturation_value("symbol_property_saturation_value", 1); 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", ""); diff --git a/src/attributes/SymbolPlottingAttributes.h b/src/attributes/SymbolPlottingAttributes.h index 23655451..d41a0492 100644 --- a/src/attributes/SymbolPlottingAttributes.h +++ b/src/attributes/SymbolPlottingAttributes.h @@ -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_; diff --git a/src/attributes/SymbolPlottingWrapper.cc b/src/attributes/SymbolPlottingWrapper.cc index d2520cd1..bdd41661 100644 --- a/src/attributes/SymbolPlottingWrapper.cc +++ b/src/attributes/SymbolPlottingWrapper.cc @@ -115,20 +115,38 @@ 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_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; diff --git a/src/params/SymbolPlotting.xml b/src/params/SymbolPlotting.xml index 525edfe7..571a3d49 100644 --- a/src/params/SymbolPlotting.xml +++ b/src/params/SymbolPlotting.xml @@ -252,31 +252,65 @@ does it submit to any jurisdiction. 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 : list of colours to use + + + With GeoSon : list of heights to use + + + + With GeoSon : list of colours to use + + 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 colourFinder; - auto value = property_colour_values_list_.begin(); - auto colour = property_colour_list_.begin(); + IntervalMap hueFinder; + auto value_hue = property_hue_values_list_.begin(); + auto hue = property_hue_list_.begin(); + IntervalMap 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; } @@ -154,8 +168,7 @@ void SymbolPlotting::by_property(Data& data, BasicGraphicsObjectContainer& out) 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; @@ -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 ) { @@ -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::iterator c = check.begin(); c != check.end(); ++c) {