From 85401f76930aec3590f4d4543eff8145a2a7a277 Mon Sep 17 00:00:00 2001 From: Sylvie Lamy-Thepaut Date: Thu, 16 Nov 2023 17:24:08 +0000 Subject: [PATCH 01/18] Revert out_of_bound parameter family t Please enter the commit message for your changes. Lines starting --- src/api/MagicsCalls.cc | 18 ++ src/api/MagicsCalls.h | 2 + src/api/MagicsCallsPython.cc | 6 +- src/api/py_calls.h | 2 + src/attributes/AxisAttributes.cc | 39 +++- src/attributes/AxisAttributes.h | 5 + src/attributes/AxisWrapper.cc | 28 +++ src/attributes/BoxPlotVisualiserAttributes.cc | 175 +++++++++++--- src/attributes/BoxPlotVisualiserAttributes.h | 25 +- src/attributes/BoxPlotVisualiserWrapper.cc | 177 +++++++------- src/attributes/BoxPlotVisualiserWrapper.h | 8 +- src/attributes/EpsGraphAttributes.cc | 10 +- src/attributes/EpsGraphAttributes.h | 2 +- src/attributes/EpsGraphWrapper.cc | 4 +- src/attributes/EpsPlumeAttributes.cc | 95 +++++++- src/attributes/EpsPlumeAttributes.h | 13 ++ src/attributes/EpsPlumeWrapper.cc | 65 ++++++ src/attributes/EpsWaveAttributes.cc | 9 +- src/attributes/EpsWaveAttributes.h | 1 + src/attributes/EpsWaveWrapper.cc | 6 + src/attributes/GeoJSonAttributes.cc | 9 +- src/attributes/GeoJSonAttributes.h | 1 + src/attributes/GeoJSonWrapper.cc | 4 + src/attributes/GribDecoderAttributes.cc | 53 ++++- src/attributes/GribDecoderAttributes.h | 7 + src/attributes/GribDecoderWrapper.cc | 28 +++ src/attributes/MagicsSettingsWrapper.cc | 10 +- src/attributes/NetcdfInterpretorAttributes.cc | 9 +- src/attributes/NetcdfInterpretorAttributes.h | 1 + src/attributes/NetcdfInterpretorWrapper.cc | 6 + src/attributes/ObsPlottingAttributes.cc | 37 +-- src/attributes/ObsPlottingAttributes.h | 5 +- src/attributes/ObsPlottingWrapper.cc | 24 +- src/attributes/SymbolPlottingAttributes.cc | 121 ++++++++-- src/attributes/SymbolPlottingAttributes.h | 17 +- src/attributes/SymbolPlottingWrapper.cc | 72 ++++-- src/attributes/TextVisitorAttributes.cc | 4 + src/attributes/TileDecoderAttributes.cc | 7 + src/attributes/TileDecoderAttributes.h | 1 + src/attributes/TileDecoderWrapper.cc | 4 + src/attributes/WrepJSonAttributes.cc | 9 +- src/attributes/WrepJSonAttributes.h | 1 + src/attributes/WrepJSonWrapper.cc | 4 + src/basic/FortranMagics.cc | 25 +- src/basic/FortranMagics.h | 1 + src/basic/LegendVisitor.cc | 7 +- src/basic/XmlMagics.cc | 1 + src/common/BaseParameter.cc | 15 ++ src/common/BaseParameter.h | 5 + src/common/MagTranslator.h | 23 ++ src/common/ParameterManager.cc | 6 + src/common/ParameterManager.h | 3 + src/common/Polyline.h | 2 + src/common/Proj4Projection.cc | 10 +- src/common/Proj4Projection.h | 7 +- src/common/Transformation.cc | 2 +- src/common/Transformation.h | 2 +- src/decoders/GribAddressMode.h | 40 ++-- src/decoders/GribDecoder.cc | 56 +++-- src/decoders/GribDecoder.h | 3 +- src/decoders/InputData.cc | 1 + src/decoders/NetcdfData.cc | 3 + src/decoders/NetcdfData.h | 3 + src/decoders/NetcdfGeopointsInterpretor.cc | 39 +++- src/decoders/NetcdfGeopointsInterpretor.h | 5 +- src/decoders/NetcdfMatrixInterpretor.cc | 2 + src/decoders/ObsDecoder.cc | 10 +- src/decoders/TileDecoder.cc | 152 ++++++++---- src/drivers/BaseDriver.cc | 216 ++++++++++++++---- src/drivers/BaseDriver.h | 3 + src/eckit_readers/MvLocation.cc | 186 +++++++++++---- src/eckit_readers/MvLocation.h | 163 +++++++------ src/libMagWrapper/MagPlus.cc | 42 +++- src/libMagWrapper/MagPlus.h | 2 + src/params/Axis.xml | 37 ++- src/params/BoxPlotVisualiser.xml | 158 +++++++++++-- src/params/CMakeLists.txt | 12 +- src/params/EpsGraph.xml | 4 +- src/params/EpsPlume.xml | 89 ++++++++ src/params/EpsWave.xml | 7 + src/params/GeoJSon.xml | 7 + src/params/GribDecoder.xml | 56 ++++- src/params/NetcdfInterpretor.xml | 8 +- src/params/NetcdfXYpointsInterpretor.xml | 6 +- src/params/ObsPlotting.xml | 13 +- src/params/SymbolPlotting.xml | 138 +++++++++-- src/params/TextVisitor.xml | 3 +- src/params/TileDecoder.xml | 5 + src/params/WrepJSon.xml | 7 + src/visualisers/Axis.cc | 56 +++++ src/visualisers/Axis.h | 11 + src/visualisers/BoxPlotVisualiser.cc | 165 ++++++++++++- src/visualisers/BoxPlotVisualiser.h | 10 +- src/visualisers/CMakeLists.txt | 3 - src/visualisers/CalcStreamlines.cc | 187 +++++++++++++++ src/visualisers/CalcStreamlines.h | 3 +- src/visualisers/CalculateColourTechnique.h | 5 + src/visualisers/ColourTechnique.h | 10 +- src/visualisers/EpsGraph.cc | 172 ++++++++++++-- src/visualisers/EpsGraph.h | 9 +- src/visualisers/GradientsColourTechnique.h | 6 + src/visualisers/IsoShading.h | 16 +- src/visualisers/ListColourTechnique.h | 6 + src/visualisers/ObsItemFamily.cc | 137 +++++++---- src/visualisers/ObsItemFamily.h | 13 +- src/visualisers/ObsPlotting.cc | 4 +- src/visualisers/ObsTable.cc | 7 +- src/visualisers/ObsTable.h | 2 + src/visualisers/Streamlines.cc | 43 +++- src/visualisers/SymbolAdvancedTableMode.cc | 13 +- src/visualisers/SymbolAdvancedTableMode.h | 2 +- src/visualisers/SymbolMode.cc | 36 ++- src/visualisers/SymbolMode.h | 15 +- src/visualisers/SymbolPlotting.cc | 119 +++++++++- src/visualisers/SymbolPlotting.h | 1 + src/visualisers/VisDefInfo.cc | 10 +- src/visualisers/VisDefInfo.h | 22 +- src/visualisers/WindPlotting.cc | 4 +- src/web/GeoJSon.cc | 43 +++- src/web/GeoJSon.h | 2 + src/web/WrepJSon.cc | 15 +- tools/xml2cc.py | 1 + tools/xml2cc_mv.py | 1 + tools/xml2milana.py | 60 ++++- 124 files changed, 3211 insertions(+), 707 deletions(-) diff --git a/src/api/MagicsCalls.cc b/src/api/MagicsCalls.cc index 694ed8445..ce53c412d 100644 --- a/src/api/MagicsCalls.cc +++ b/src/api/MagicsCalls.cc @@ -42,7 +42,20 @@ const char* MagicsCalls::metainput() { const char* MagicsCalls::metanetcdf() { return FortranMagics::instance().metanetcdf(); } +const char* MagicsCalls::long_parameters() { + static string result; + ostringstream os; + os << "{"; + os << "\"grib_field_position\": \"grib_field_large_position\","; + os << "\"grib_wind_position_1\": \"grib_wind_large_position_1\","; + os << "\"grib_wind_position_2\": \"grib_wind_large_position_2\","; + os << "\"grib_wind_position_colour\": \"grib_wind_large_position_colour\""; + os << "}"; + result = os.str(); + return result.c_str(); + +} const char* MagicsCalls::keep_compatibility() { NOTIMP; } @@ -385,6 +398,11 @@ void MagicsCalls::seti(const std::string& name, int value) { ParameterManager::set(name, value); } +void MagicsCalls::setli(const std::string& name, unsigned long long value) { + // if (CompatibilityHelper::check(name, value)) + // return; + ParameterManager::set(name, value); +} void MagicsCalls::set1i(const std::string& name, const std::vector& data) { set1i(name, data.data(), data.size()); diff --git a/src/api/MagicsCalls.h b/src/api/MagicsCalls.h index a70123d9f..399112d3a 100644 --- a/src/api/MagicsCalls.h +++ b/src/api/MagicsCalls.h @@ -20,6 +20,7 @@ class MagicsCalls { static const char* metainput(); static const char* metanetcdf(); static const char* keep_compatibility(); + static const char* long_parameters(); // ================================================================= static void axis(); @@ -82,6 +83,7 @@ class MagicsCalls { static void set1c(const std::string& name, const std::vector& data); static void seti(const std::string& name, int value); + static void setli(const std::string& name, unsigned long long value); static void set1i(const std::string& name, const int* data, const int dim1); static void set1i(const std::string& name, const std::vector& data); static void set2i(const std::string& name, const int* data, const int dim1, const int dim2); diff --git a/src/api/MagicsCallsPython.cc b/src/api/MagicsCallsPython.cc index e3fd90b6c..45d537711 100644 --- a/src/api/MagicsCallsPython.cc +++ b/src/api/MagicsCallsPython.cc @@ -162,7 +162,7 @@ PYTHON_VOID(tile) PYTHON_VOID(unmute) // TODO: review name PYTHON_VOID(wind) PYTHON_VOID(wrepjson) - +PYTHON_CHAR(long_parameters) PYTHON_CHAR(knowndrivers) // TODO: review name PYTHON_CHAR(metagrib) // TODO: review name PYTHON_CHAR(metainput) // TODO: review name @@ -193,6 +193,10 @@ MAGICS_EXPORT const char* py_seti(const char* name, const int value) { return python_void("seti", [name, value] { MagicsCalls::seti(name, value); }); } +MAGICS_EXPORT const char* py_setli(const char* name, const unsigned long long value) { + return python_void("setli", [name, value] { MagicsCalls::setli(name, value); }); +} + MAGICS_EXPORT const char* py_set1r(const char* name, const double* data, const int dim1) { return python_void("set1r", [name, data, dim1] { MagicsCalls::set1r(name, data, dim1); }); } diff --git a/src/api/py_calls.h b/src/api/py_calls.h index 88a1c5868..503359d86 100644 --- a/src/api/py_calls.h +++ b/src/api/py_calls.h @@ -19,6 +19,7 @@ MAGICS_EXPORT const char* py_import(); MAGICS_EXPORT const char* py_input(); MAGICS_EXPORT const char* py_keep_compatibility(); MAGICS_EXPORT const char* py_knowndrivers(); +MAGICS_EXPORT const char* py_long_parameters(); MAGICS_EXPORT const char* py_legend(); MAGICS_EXPORT const char* py_line(); MAGICS_EXPORT const char* py_mapgen(); @@ -50,6 +51,7 @@ MAGICS_EXPORT const char* py_reset(const char* name); MAGICS_EXPORT const char* py_setc(const char* name, const char* value); MAGICS_EXPORT const char* py_setr(const char* name, const double value); MAGICS_EXPORT const char* py_seti(const char* name, const int value); +MAGICS_EXPORT const char* py_setli(const char* name, const unsigned long long value); MAGICS_EXPORT const char* py_set1r(const char* name, const double* data, const int dim1); MAGICS_EXPORT const char* py_set2r(const char* name, const double* data, const int dim1, const int dim2); MAGICS_EXPORT const char* py_set1i(const char* name, const int* data, const int dim1); diff --git a/src/attributes/AxisAttributes.cc b/src/attributes/AxisAttributes.cc index 0b235cb2a..c0bb27ce3 100644 --- a/src/attributes/AxisAttributes.cc +++ b/src/attributes/AxisAttributes.cc @@ -66,12 +66,15 @@ AxisAttributes::AxisAttributes(): tip_(ParameterManager::getBool("axis_tip_title")), tip_text_(ParameterManager::getString("axis_tip_title_text")), tip_height_(ParameterManager::getDouble("axis_tip_title_height")), - tip_quality_(ParameterManager::getString("axis_tip_title_quality")) + tip_quality_(ParameterManager::getString("axis_tip_title_quality")), + highlighted_values_(ParameterManager::getDoubleArray("axis_highlighted_values")), + highlighted_values_thickness_(ParameterManager::getInt("axis_highlighted_values_thickness")) , method_(MagTranslator().magics("axis_type")), line_colour_(MagTranslator().magics("axis_line_colour")), line_style_(MagTranslator().magics("axis_line_style")), grid_colour_(MagTranslator().magics("axis_grid_colour")), + grid_background_colour_(MagTranslator().magics("axis_grid_background_colour")), grid_style_(MagTranslator().magics("axis_grid_line_style")), minor_grid_colour_(MagTranslator().magics("axis_minor_grid_colour")), minor_grid_style_(MagTranslator().magics("axis_minor_grid_line_style")), @@ -81,7 +84,9 @@ AxisAttributes::AxisAttributes(): tick_colour_(MagTranslator().magics("axis_tick_colour")), label_colour_(MagTranslator().magics("axis_tick_label_colour")), minor_tick_colour_(MagTranslator().magics("axis_minor_tick_colour")), - tip_colour_(MagTranslator().magics("axis_tip_title_colour")) + tip_colour_(MagTranslator().magics("axis_tip_title_colour")), + highlighted_values_colour_(MagTranslator().magics("axis_highlighted_values_colour")), + highlighted_values_style_(MagTranslator().magics("axis_highlighted_values_style")) { } @@ -141,11 +146,14 @@ void AxisAttributes::set(const std::map& params) setAttribute(prefix, "axis_tip_title_text", tip_text_, params); setAttribute(prefix, "axis_tip_title_height", tip_height_, params); setAttribute(prefix, "axis_tip_title_quality", tip_quality_, params); + setAttribute(prefix, "axis_highlighted_values", highlighted_values_, params); + setAttribute(prefix, "axis_highlighted_values_thickness", highlighted_values_thickness_, params); setMember(prefix, "axis_type", method_, params); setMember(prefix, "axis_line_colour", line_colour_, params); setAttribute(prefix, "axis_line_style", line_style_, params); setMember(prefix, "axis_grid_colour", grid_colour_, params); + setMember(prefix, "axis_grid_background_colour", grid_background_colour_, params); setAttribute(prefix, "axis_grid_line_style", grid_style_, params); setMember(prefix, "axis_minor_grid_colour", minor_grid_colour_, params); setAttribute(prefix, "axis_minor_grid_line_style", minor_grid_style_, params); @@ -156,6 +164,8 @@ void AxisAttributes::set(const std::map& params) setMember(prefix, "axis_tick_label_colour", label_colour_, params); setMember(prefix, "axis_minor_tick_colour", minor_tick_colour_, params); setMember(prefix, "axis_tip_title_colour", tip_colour_, params); + setMember(prefix, "axis_highlighted_values_colour", highlighted_values_colour_, params); + setAttribute(prefix, "axis_highlighted_values_style", highlighted_values_style_, params); } @@ -203,10 +213,13 @@ void AxisAttributes::copy(const AxisAttributes& other) tip_text_ = other.tip_text_; tip_height_ = other.tip_height_; tip_quality_ = other.tip_quality_; + highlighted_values_ = other.highlighted_values_; + highlighted_values_thickness_ = other.highlighted_values_thickness_; method_ = unique_ptr(other.method_->clone()); line_colour_ = unique_ptr(other.line_colour_->clone()); line_style_ = other.line_style_; grid_colour_ = unique_ptr(other.grid_colour_->clone()); + grid_background_colour_ = unique_ptr(other.grid_background_colour_->clone()); grid_style_ = other.grid_style_; minor_grid_colour_ = unique_ptr(other.minor_grid_colour_->clone()); minor_grid_style_ = other.minor_grid_style_; @@ -217,6 +230,8 @@ void AxisAttributes::copy(const AxisAttributes& other) label_colour_ = unique_ptr(other.label_colour_->clone()); minor_tick_colour_ = unique_ptr(other.minor_tick_colour_->clone()); tip_colour_ = unique_ptr(other.tip_colour_->clone()); + highlighted_values_colour_ = unique_ptr(other.highlighted_values_colour_->clone()); + highlighted_values_style_ = other.highlighted_values_style_; } @@ -301,10 +316,13 @@ void AxisAttributes::print(ostream& out) const out << " tip_text = " << tip_text_; out << " tip_height = " << tip_height_; out << " tip_quality = " << tip_quality_; + out << " highlighted_values = " << highlighted_values_; + out << " highlighted_values_thickness = " << highlighted_values_thickness_; out << " method = " << *method_; out << " line_colour = " << *line_colour_; out << " line_style = " << line_style_; out << " grid_colour = " << *grid_colour_; + out << " grid_background_colour = " << *grid_background_colour_; out << " grid_style = " << grid_style_; out << " minor_grid_colour = " << *minor_grid_colour_; out << " minor_grid_style = " << minor_grid_style_; @@ -315,6 +333,8 @@ void AxisAttributes::print(ostream& out) const out << " label_colour = " << *label_colour_; out << " minor_tick_colour = " << *minor_tick_colour_; out << " tip_colour = " << *tip_colour_; + out << " highlighted_values_colour = " << *highlighted_values_colour_; + out << " highlighted_values_style = " << highlighted_values_style_; out << "]" << "\n"; } @@ -406,6 +426,10 @@ void AxisAttributes::toxml(ostream& out) const niceprint(out,tip_height_); out << ", \"axis_tip_title_quality\":"; niceprint(out,tip_quality_); + out << ", \"axis_highlighted_values\":"; + niceprint(out,highlighted_values_); + out << ", \"axis_highlighted_values_thickness\":"; + niceprint(out,highlighted_values_thickness_); out << ", \"axis_type\":"; method_->toxml(out); out << ", \"axis_line_colour\":"; @@ -414,6 +438,8 @@ void AxisAttributes::toxml(ostream& out) const niceprint(out, line_style_); out << ", \"axis_grid_colour\":"; niceprint(out, *grid_colour_); + out << ", \"axis_grid_background_colour\":"; + niceprint(out, *grid_background_colour_); out << ", \"axis_grid_line_style\":"; niceprint(out, grid_style_); out << ", \"axis_minor_grid_colour\":"; @@ -434,6 +460,10 @@ void AxisAttributes::toxml(ostream& out) const niceprint(out, *minor_tick_colour_); out << ", \"axis_tip_title_colour\":"; niceprint(out, *tip_colour_); + out << ", \"axis_highlighted_values_colour\":"; + niceprint(out, *highlighted_values_colour_); + out << ", \"axis_highlighted_values_style\":"; + niceprint(out, highlighted_values_style_); } @@ -479,10 +509,13 @@ static MagicsParameter axis_tip_title("axis_tip_title", "off"); static MagicsParameter axis_tip_title_text("axis_tip_title_text", ""); static MagicsParameter axis_tip_title_height("axis_tip_title_height", 0.4); static MagicsParameter axis_tip_title_quality("axis_tip_title_quality", "medium"); +static MagicsParameter axis_highlighted_values("axis_highlighted_values", floatarray()); +static MagicsParameter axis_highlighted_values_thickness("axis_highlighted_values_thickness", 1); static MagicsParameter axis_type("axis_type", "regular"); static MagicsParameter axis_line_colour("axis_line_colour", "automatic"); static MagicsParameter axis_line_style("axis_line_style", "solid"); static MagicsParameter axis_grid_colour("axis_grid_colour", "black"); +static MagicsParameter axis_grid_background_colour("axis_grid_background_colour", "none"); static MagicsParameter axis_grid_line_style("axis_grid_line_style", "solid"); static MagicsParameter axis_minor_grid_colour("axis_minor_grid_colour", "black"); static MagicsParameter axis_minor_grid_line_style("axis_minor_grid_line_style", "solid"); @@ -493,6 +526,8 @@ static MagicsParameter axis_tick_colour("axis_tick_colour", "automatic") static MagicsParameter axis_tick_label_colour("axis_tick_label_colour", "automatic"); static MagicsParameter axis_minor_tick_colour("axis_minor_tick_colour", "automatic"); static MagicsParameter axis_tip_title_colour("axis_tip_title_colour", "automatic"); +static MagicsParameter axis_highlighted_values_colour("axis_highlighted_values_colour", "black"); +static MagicsParameter axis_highlighted_values_style("axis_highlighted_values_style", "solid"); #include "AxisMethod.h" #include "DateAxis.h" static SimpleObjectMaker regular_AxisMethod("regular"); diff --git a/src/attributes/AxisAttributes.h b/src/attributes/AxisAttributes.h index 7adb7394f..a04e0f969 100644 --- a/src/attributes/AxisAttributes.h +++ b/src/attributes/AxisAttributes.h @@ -94,10 +94,13 @@ class AxisAttributes string tip_text_; double tip_height_; string tip_quality_; + doublearray highlighted_values_; + int highlighted_values_thickness_; unique_ptr method_; unique_ptr line_colour_; LineStyle line_style_; unique_ptr grid_colour_; + unique_ptr grid_background_colour_; LineStyle grid_style_; unique_ptr minor_grid_colour_; LineStyle minor_grid_style_; @@ -108,6 +111,8 @@ class AxisAttributes unique_ptr label_colour_; unique_ptr minor_tick_colour_; unique_ptr tip_colour_; + unique_ptr highlighted_values_colour_; + LineStyle highlighted_values_style_; private: diff --git a/src/attributes/AxisWrapper.cc b/src/attributes/AxisWrapper.cc index 99bb85571..0f5096f48 100644 --- a/src/attributes/AxisWrapper.cc +++ b/src/attributes/AxisWrapper.cc @@ -245,6 +245,15 @@ void AxisWrapper::set(const MagRequest& request) string tip_quality_value = request("AXIS_TIP_TITLE_QUALITY"); axis_->tip_quality_ = tip_quality_value; } + doublearray highlighted_values_value; + for (int i = 0; i < request.countValues("AXIS_HIGHLIGHTED_VALUES"); i++) + highlighted_values_value.push_back((double)request("AXIS_HIGHLIGHTED_VALUES", i)); + if ( !highlighted_values_value.empty() ) + axis_->highlighted_values_ = highlighted_values_value; + if (request.countValues("AXIS_HIGHLIGHTED_VALUES_THICKNESS") ) { + int highlighted_values_thickness_value = request("AXIS_HIGHLIGHTED_VALUES_THICKNESS"); + axis_->highlighted_values_thickness_ = highlighted_values_thickness_value; + } string method_value = request.countValues("AXIS_TYPE") ? (string) request("AXIS_TYPE") : "regular"; @@ -280,6 +289,11 @@ void AxisWrapper::set(const MagRequest& request) axis_->grid_colour_ = unique_ptr(MagTranslator()(grid_colour_value)); } + if (request.countValues("AXIS_GRID_BACKGROUND_COLOUR") ) { + string grid_background_colour_value = request("AXIS_GRID_BACKGROUND_COLOUR"); + axis_->grid_background_colour_ = unique_ptr(MagTranslator()(grid_background_colour_value)); + } + if (request.countValues("AXIS_GRID_LINE_STYLE") ) { string grid_style_value = request("AXIS_GRID_LINE_STYLE"); @@ -333,6 +347,17 @@ void AxisWrapper::set(const MagRequest& request) axis_->tip_colour_ = unique_ptr(MagTranslator()(tip_colour_value)); } + if (request.countValues("AXIS_HIGHLIGHTED_VALUES_COLOUR") ) { + string highlighted_values_colour_value = request("AXIS_HIGHLIGHTED_VALUES_COLOUR"); + axis_->highlighted_values_colour_ = unique_ptr(MagTranslator()(highlighted_values_colour_value)); + } + + + if (request.countValues("AXIS_HIGHLIGHTED_VALUES_STYLE") ) { + string highlighted_values_style_value = request("AXIS_HIGHLIGHTED_VALUES_STYLE"); + axis_->highlighted_values_style_ = MagTranslator()(highlighted_values_style_value); + } + } @@ -381,3 +406,6 @@ static SimpleObjectMaker Axis_axis_ty + + + diff --git a/src/attributes/BoxPlotVisualiserAttributes.cc b/src/attributes/BoxPlotVisualiserAttributes.cc index 1dc1b647d..0e953ae15 100644 --- a/src/attributes/BoxPlotVisualiserAttributes.cc +++ b/src/attributes/BoxPlotVisualiserAttributes.cc @@ -25,9 +25,28 @@ using namespace magics; BoxPlotVisualiserAttributes::BoxPlotVisualiserAttributes(): - - box_(MagTranslator().magics("boxplot_box")), - whisker_(MagTranslator().magics("boxplot_whisker")) + box_(ParameterManager::getBool("boxplot_box")), + box_width_(ParameterManager::getDouble("boxplot_box_width")), + box_border_(ParameterManager::getBool("boxplot_box_border")), + box_border_thickness_(ParameterManager::getInt("boxplot_box_border_thickness")), + median_(ParameterManager::getBool("boxplot_median")), + median_thickness_(ParameterManager::getInt("boxplot_median_thickness")), + whisker_(ParameterManager::getString("boxplot_whisker")), + whisker_box_width_(ParameterManager::getDouble("boxplot_whisker_box_width")), + whisker_box_border_(ParameterManager::getBool("boxplot_whisker_box_border")), + whisker_box_border_thickness_(ParameterManager::getInt("boxplot_whisker_box_border_thickness")), + whisker_line_thickness_(ParameterManager::getInt("boxplot_whisker_line_thickness")) + , + box_colour_(MagTranslator().magics("boxplot_box_colour")), + box_border_colour_(MagTranslator().magics("boxplot_box_border_colour")), + box_border_style_(MagTranslator().magics("boxplot_box_border_line_style")), + median_colour_(MagTranslator().magics("boxplot_median_colour")), + median_style_(MagTranslator().magics("boxplot_median_line_style")), + whisker_box_colour_(MagTranslator().magics("boxplot_whisker_box_colour")), + whisker_box_border_colour_(MagTranslator().magics("boxplot_whisker_box_border_colour")), + whisker_box_border_style_(MagTranslator().magics("boxplot_whisker_box_border_line_style")), + whisker_line_colour_(MagTranslator().magics("boxplot_whisker_line_colour")), + whisker_line_style_(MagTranslator().magics("boxplot_whisker_line_style")) { } @@ -45,16 +64,54 @@ void BoxPlotVisualiserAttributes::set(const std::map& params) int i = 0; prefix[i++] = ""; + setAttribute(prefix, "boxplot_box", box_, params); + setAttribute(prefix, "boxplot_box_width", box_width_, params); + setAttribute(prefix, "boxplot_box_border", box_border_, params); + setAttribute(prefix, "boxplot_box_border_thickness", box_border_thickness_, params); + setAttribute(prefix, "boxplot_median", median_, params); + setAttribute(prefix, "boxplot_median_thickness", median_thickness_, params); + setAttribute(prefix, "boxplot_whisker", whisker_, params); + setAttribute(prefix, "boxplot_whisker_box_width", whisker_box_width_, params); + setAttribute(prefix, "boxplot_whisker_box_border", whisker_box_border_, params); + setAttribute(prefix, "boxplot_whisker_box_border_thickness", whisker_box_border_thickness_, params); + setAttribute(prefix, "boxplot_whisker_line_thickness", whisker_line_thickness_, params); - setMember(prefix, "boxplot_box", box_, params); - setMember(prefix, "boxplot_whisker", whisker_, params); + setMember(prefix, "boxplot_box_colour", box_colour_, params); + setMember(prefix, "boxplot_box_border_colour", box_border_colour_, params); + setAttribute(prefix, "boxplot_box_border_line_style", box_border_style_, params); + setMember(prefix, "boxplot_median_colour", median_colour_, params); + setAttribute(prefix, "boxplot_median_line_style", median_style_, params); + setMember(prefix, "boxplot_whisker_box_colour", whisker_box_colour_, params); + setMember(prefix, "boxplot_whisker_box_border_colour", whisker_box_border_colour_, params); + setAttribute(prefix, "boxplot_whisker_box_border_line_style", whisker_box_border_style_, params); + setMember(prefix, "boxplot_whisker_line_colour", whisker_line_colour_, params); + setAttribute(prefix, "boxplot_whisker_line_style", whisker_line_style_, params); } void BoxPlotVisualiserAttributes::copy(const BoxPlotVisualiserAttributes& other) { - box_ = unique_ptr(other.box_->clone()); - whisker_ = unique_ptr(other.whisker_->clone()); + box_ = other.box_; + box_width_ = other.box_width_; + box_border_ = other.box_border_; + box_border_thickness_ = other.box_border_thickness_; + median_ = other.median_; + median_thickness_ = other.median_thickness_; + whisker_ = other.whisker_; + whisker_box_width_ = other.whisker_box_width_; + whisker_box_border_ = other.whisker_box_border_; + whisker_box_border_thickness_ = other.whisker_box_border_thickness_; + whisker_line_thickness_ = other.whisker_line_thickness_; + box_colour_ = unique_ptr(other.box_colour_->clone()); + box_border_colour_ = unique_ptr(other.box_border_colour_->clone()); + box_border_style_ = other.box_border_style_; + median_colour_ = unique_ptr(other.median_colour_->clone()); + median_style_ = other.median_style_; + whisker_box_colour_ = unique_ptr(other.whisker_box_colour_->clone()); + whisker_box_border_colour_ = unique_ptr(other.whisker_box_border_colour_->clone()); + whisker_box_border_style_ = other.whisker_box_border_style_; + whisker_line_colour_ = unique_ptr(other.whisker_line_colour_->clone()); + whisker_line_style_ = other.whisker_line_style_; } @@ -64,10 +121,6 @@ bool BoxPlotVisualiserAttributes::accept(const string& node) if ( magCompare(node, "boxplot") ) return true; - if ( acceptNode(node, box_) ) - return true; - if ( acceptNode(node, whisker_) ) - return true; return false; } @@ -86,14 +139,10 @@ void BoxPlotVisualiserAttributes::set(const XmlNode& node) if ( apply ) set(node.attributes()); else { - setMember(node.name(), box_, node); - setMember(node.name(), whisker_, node); } for (auto &elt : node.elements()) { - setMember(elt->name(), box_, *elt); - setMember(elt->name(), whisker_, *elt); } } @@ -101,8 +150,27 @@ void BoxPlotVisualiserAttributes::set(const XmlNode& node) void BoxPlotVisualiserAttributes::print(ostream& out) const { out << "Attributes["; - out << " box = " << *box_; - out << " whisker = " << *whisker_; + out << " box = " << box_; + out << " box_width = " << box_width_; + out << " box_border = " << box_border_; + out << " box_border_thickness = " << box_border_thickness_; + out << " median = " << median_; + out << " median_thickness = " << median_thickness_; + out << " whisker = " << whisker_; + out << " whisker_box_width = " << whisker_box_width_; + out << " whisker_box_border = " << whisker_box_border_; + out << " whisker_box_border_thickness = " << whisker_box_border_thickness_; + out << " whisker_line_thickness = " << whisker_line_thickness_; + out << " box_colour = " << *box_colour_; + out << " box_border_colour = " << *box_border_colour_; + out << " box_border_style = " << box_border_style_; + out << " median_colour = " << *median_colour_; + out << " median_style = " << median_style_; + out << " whisker_box_colour = " << *whisker_box_colour_; + out << " whisker_box_border_colour = " << *whisker_box_border_colour_; + out << " whisker_box_border_style = " << whisker_box_border_style_; + out << " whisker_line_colour = " << *whisker_line_colour_; + out << " whisker_line_style = " << whisker_line_style_; out << "]" << "\n"; } @@ -111,23 +179,68 @@ void BoxPlotVisualiserAttributes::toxml(ostream& out) const { out << "\"boxplot\""; out << ", \"boxplot_box\":"; - box_->toxml(out); + niceprint(out,box_); + out << ", \"boxplot_box_width\":"; + niceprint(out,box_width_); + out << ", \"boxplot_box_border\":"; + niceprint(out,box_border_); + out << ", \"boxplot_box_border_thickness\":"; + niceprint(out,box_border_thickness_); + out << ", \"boxplot_median\":"; + niceprint(out,median_); + out << ", \"boxplot_median_thickness\":"; + niceprint(out,median_thickness_); out << ", \"boxplot_whisker\":"; - whisker_->toxml(out); + niceprint(out,whisker_); + out << ", \"boxplot_whisker_box_width\":"; + niceprint(out,whisker_box_width_); + out << ", \"boxplot_whisker_box_border\":"; + niceprint(out,whisker_box_border_); + out << ", \"boxplot_whisker_box_border_thickness\":"; + niceprint(out,whisker_box_border_thickness_); + out << ", \"boxplot_whisker_line_thickness\":"; + niceprint(out,whisker_line_thickness_); + out << ", \"boxplot_box_colour\":"; + niceprint(out, *box_colour_); + out << ", \"boxplot_box_border_colour\":"; + niceprint(out, *box_border_colour_); + out << ", \"boxplot_box_border_line_style\":"; + niceprint(out, box_border_style_); + out << ", \"boxplot_median_colour\":"; + niceprint(out, *median_colour_); + out << ", \"boxplot_median_line_style\":"; + niceprint(out, median_style_); + out << ", \"boxplot_whisker_box_colour\":"; + niceprint(out, *whisker_box_colour_); + out << ", \"boxplot_whisker_box_border_colour\":"; + niceprint(out, *whisker_box_border_colour_); + out << ", \"boxplot_whisker_box_border_line_style\":"; + niceprint(out, whisker_box_border_style_); + out << ", \"boxplot_whisker_line_colour\":"; + niceprint(out, *whisker_line_colour_); + out << ", \"boxplot_whisker_line_style\":"; + niceprint(out, whisker_line_style_); } static MagicsParameter boxplot_box("boxplot_box", "on"); +static MagicsParameter boxplot_box_width("boxplot_box_width", 1.0); +static MagicsParameter boxplot_box_border("boxplot_box_border", "on"); +static MagicsParameter boxplot_box_border_thickness("boxplot_box_border_thickness", 1); +static MagicsParameter boxplot_median("boxplot_median", "on"); +static MagicsParameter boxplot_median_thickness("boxplot_median_thickness", 3); static MagicsParameter boxplot_whisker("boxplot_whisker", "line"); -#include "BoxPlotItem.h" -#include "BoxPlotBasicItem.h" -static SimpleObjectMaker box_BoxPlotBox("box"); -static SimpleObjectMaker on_BoxPlotBox("on"); -static SimpleObjectMaker noBox_NoBoxPlotBox("noBox"); -static SimpleObjectMaker off_NoBoxPlotBox("off"); -static SimpleObjectMaker whiskerbox_BoxPlotWhiskerBox("whiskerbox"); -static SimpleObjectMaker box_BoxPlotWhiskerBox("box"); -static SimpleObjectMaker nowhisker_NoBoxPlotWhisker("nowhisker"); -static SimpleObjectMaker off_NoBoxPlotWhisker("off"); -static SimpleObjectMaker whiskerline_BoxPlotWhiskerLine("whiskerline"); -static SimpleObjectMaker line_BoxPlotWhiskerLine("line"); +static MagicsParameter boxplot_whisker_box_width("boxplot_whisker_box_width", 0.25); +static MagicsParameter boxplot_whisker_box_border("boxplot_whisker_box_border", "on"); +static MagicsParameter boxplot_whisker_box_border_thickness("boxplot_whisker_box_border_thickness", 1); +static MagicsParameter boxplot_whisker_line_thickness("boxplot_whisker_line_thickness", 3); +static MagicsParameter boxplot_box_colour("boxplot_box_colour", "sky"); +static MagicsParameter boxplot_box_border_colour("boxplot_box_border_colour", "navy"); +static MagicsParameter boxplot_box_border_line_style("boxplot_box_border_line_style", "solid"); +static MagicsParameter boxplot_median_colour("boxplot_median_colour", "navy"); +static MagicsParameter boxplot_median_line_style("boxplot_median_line_style", "solid"); +static MagicsParameter boxplot_whisker_box_colour("boxplot_whisker_box_colour", "sky"); +static MagicsParameter boxplot_whisker_box_border_colour("boxplot_whisker_box_border_colour", "navy"); +static MagicsParameter boxplot_whisker_box_border_line_style("boxplot_whisker_box_border_line_style", "solid"); +static MagicsParameter boxplot_whisker_line_colour("boxplot_whisker_line_colour", "navy"); +static MagicsParameter boxplot_whisker_line_style("boxplot_whisker_line_style", "solid"); diff --git a/src/attributes/BoxPlotVisualiserAttributes.h b/src/attributes/BoxPlotVisualiserAttributes.h index 2b3f2b6de..13f968c3a 100644 --- a/src/attributes/BoxPlotVisualiserAttributes.h +++ b/src/attributes/BoxPlotVisualiserAttributes.h @@ -25,7 +25,7 @@ #define BoxPlotVisualiserAttributes_H #include "magics.h" -#include "BoxPlotBasicItem.h" +#include "Colour.h" namespace magics { class XmlNode; @@ -51,8 +51,27 @@ class BoxPlotVisualiserAttributes virtual void toxml(std::ostream& out) const; // -- members: string tag_; - unique_ptr box_; - unique_ptr whisker_; + bool box_; + double box_width_; + bool box_border_; + int box_border_thickness_; + bool median_; + int median_thickness_; + string whisker_; + double whisker_box_width_; + bool whisker_box_border_; + int whisker_box_border_thickness_; + int whisker_line_thickness_; + unique_ptr box_colour_; + unique_ptr box_border_colour_; + LineStyle box_border_style_; + unique_ptr median_colour_; + LineStyle median_style_; + unique_ptr whisker_box_colour_; + unique_ptr whisker_box_border_colour_; + LineStyle whisker_box_border_style_; + unique_ptr whisker_line_colour_; + LineStyle whisker_line_style_; private: diff --git a/src/attributes/BoxPlotVisualiserWrapper.cc b/src/attributes/BoxPlotVisualiserWrapper.cc index 5e7b96a2f..5ae9e286f 100644 --- a/src/attributes/BoxPlotVisualiserWrapper.cc +++ b/src/attributes/BoxPlotVisualiserWrapper.cc @@ -37,16 +37,12 @@ BoxPlotVisualiserWrapper::BoxPlotVisualiserWrapper(): boxplotvisualiser_(new Box - BoxPlotDecoderWrapper::object(boxplotvisualiser_); - } BoxPlotVisualiserWrapper::BoxPlotVisualiserWrapper(BoxPlotVisualiser* boxplotvisualiser): boxplotvisualiser_(boxplotvisualiser) { - BoxPlotDecoderWrapper::object(boxplotvisualiser_); - } BoxPlotVisualiserWrapper::~BoxPlotVisualiserWrapper() @@ -59,46 +55,113 @@ void BoxPlotVisualiserWrapper::set(const MagRequest& request) - BoxPlotDecoderWrapper::set(request); + if (request.countValues("BOXPLOT_BOX") ) { + string box_value = request("BOXPLOT_BOX"); + + boxplotvisualiser_->box_ = MagTranslator()(box_value); + + } + if (request.countValues("BOXPLOT_BOX_WIDTH") ) { + double box_width_value = request("BOXPLOT_BOX_WIDTH"); + boxplotvisualiser_->box_width_ = box_width_value; + } + if (request.countValues("BOXPLOT_BOX_BORDER") ) { + string box_border_value = request("BOXPLOT_BOX_BORDER"); + + boxplotvisualiser_->box_border_ = MagTranslator()(box_border_value); + + } + if (request.countValues("BOXPLOT_BOX_BORDER_THICKNESS") ) { + int box_border_thickness_value = request("BOXPLOT_BOX_BORDER_THICKNESS"); + boxplotvisualiser_->box_border_thickness_ = box_border_thickness_value; + } + if (request.countValues("BOXPLOT_MEDIAN") ) { + string median_value = request("BOXPLOT_MEDIAN"); + + boxplotvisualiser_->median_ = MagTranslator()(median_value); + + } + if (request.countValues("BOXPLOT_MEDIAN_THICKNESS") ) { + int median_thickness_value = request("BOXPLOT_MEDIAN_THICKNESS"); + boxplotvisualiser_->median_thickness_ = median_thickness_value; + } + if (request.countValues("BOXPLOT_WHISKER") ) { + string whisker_value = request("BOXPLOT_WHISKER"); + boxplotvisualiser_->whisker_ = whisker_value; + } + if (request.countValues("BOXPLOT_WHISKER_BOX_WIDTH") ) { + double whisker_box_width_value = request("BOXPLOT_WHISKER_BOX_WIDTH"); + boxplotvisualiser_->whisker_box_width_ = whisker_box_width_value; + } + if (request.countValues("BOXPLOT_WHISKER_BOX_BORDER") ) { + string whisker_box_border_value = request("BOXPLOT_WHISKER_BOX_BORDER"); + + boxplotvisualiser_->whisker_box_border_ = MagTranslator()(whisker_box_border_value); + + } + if (request.countValues("BOXPLOT_WHISKER_BOX_BORDER_THICKNESS") ) { + int whisker_box_border_thickness_value = request("BOXPLOT_WHISKER_BOX_BORDER_THICKNESS"); + boxplotvisualiser_->whisker_box_border_thickness_ = whisker_box_border_thickness_value; + } + if (request.countValues("BOXPLOT_WHISKER_LINE_THICKNESS") ) { + int whisker_line_thickness_value = request("BOXPLOT_WHISKER_LINE_THICKNESS"); + boxplotvisualiser_->whisker_line_thickness_ = whisker_line_thickness_value; + } - + if (request.countValues("BOXPLOT_BOX_COLOUR") ) { + string box_colour_value = request("BOXPLOT_BOX_COLOUR"); + boxplotvisualiser_->box_colour_ = unique_ptr(MagTranslator()(box_colour_value)); + } + + if (request.countValues("BOXPLOT_BOX_BORDER_COLOUR") ) { + string box_border_colour_value = request("BOXPLOT_BOX_BORDER_COLOUR"); + boxplotvisualiser_->box_border_colour_ = unique_ptr(MagTranslator()(box_border_colour_value)); + } + + if (request.countValues("BOXPLOT_BOX_BORDER_LINE_STYLE") ) { + string box_border_style_value = request("BOXPLOT_BOX_BORDER_LINE_STYLE"); + boxplotvisualiser_->box_border_style_ = MagTranslator()(box_border_style_value); + } + + if (request.countValues("BOXPLOT_MEDIAN_COLOUR") ) { + string median_colour_value = request("BOXPLOT_MEDIAN_COLOUR"); + boxplotvisualiser_->median_colour_ = unique_ptr(MagTranslator()(median_colour_value)); + } + - string box_value = request.countValues("BOXPLOT_BOX") ? (string) request("BOXPLOT_BOX") : "on"; - MagLog::debug() << " BOXPLOT_BOX set to " << box_value << endl; - NoBoxPlotBoxWrapper* box_wrapper = 0; - try - { - box_wrapper = SimpleFactory::create(box_value); + if (request.countValues("BOXPLOT_MEDIAN_LINE_STYLE") ) { + string median_style_value = request("BOXPLOT_MEDIAN_LINE_STYLE"); + boxplotvisualiser_->median_style_ = MagTranslator()(median_style_value); } - catch (NoFactoryException&) { - if (MagicsGlobal::strict()) { - throw; - } - MagLog::warning() << "[" << box_value << "] is not a valid value for box: reset to default -> [on]" << endl; - box_wrapper = SimpleFactory::create("on"); + + if (request.countValues("BOXPLOT_WHISKER_BOX_COLOUR") ) { + string whisker_box_colour_value = request("BOXPLOT_WHISKER_BOX_COLOUR"); + boxplotvisualiser_->whisker_box_colour_ = unique_ptr(MagTranslator()(whisker_box_colour_value)); } - box_wrapper->set(request); - boxplotvisualiser_->box_ = unique_ptr(box_wrapper->object()); - delete box_wrapper; + + if (request.countValues("BOXPLOT_WHISKER_BOX_BORDER_COLOUR") ) { + string whisker_box_border_colour_value = request("BOXPLOT_WHISKER_BOX_BORDER_COLOUR"); + boxplotvisualiser_->whisker_box_border_colour_ = unique_ptr(MagTranslator()(whisker_box_border_colour_value)); + } + - string whisker_value = request.countValues("BOXPLOT_WHISKER") ? (string) request("BOXPLOT_WHISKER") : "line"; - MagLog::debug() << " BOXPLOT_WHISKER set to " << whisker_value << endl; - NoBoxPlotWhiskerWrapper* whisker_wrapper = 0; - try - { - whisker_wrapper = SimpleFactory::create(whisker_value); + if (request.countValues("BOXPLOT_WHISKER_BOX_BORDER_LINE_STYLE") ) { + string whisker_box_border_style_value = request("BOXPLOT_WHISKER_BOX_BORDER_LINE_STYLE"); + boxplotvisualiser_->whisker_box_border_style_ = MagTranslator()(whisker_box_border_style_value); + } + + if (request.countValues("BOXPLOT_WHISKER_LINE_COLOUR") ) { + string whisker_line_colour_value = request("BOXPLOT_WHISKER_LINE_COLOUR"); + boxplotvisualiser_->whisker_line_colour_ = unique_ptr(MagTranslator()(whisker_line_colour_value)); } - catch (NoFactoryException&) { - if (MagicsGlobal::strict()) { - throw; - } - MagLog::warning() << "[" << whisker_value << "] is not a valid value for whisker: reset to default -> [line]" << endl; - whisker_wrapper = SimpleFactory::create("line"); + + + if (request.countValues("BOXPLOT_WHISKER_LINE_STYLE") ) { + string whisker_line_style_value = request("BOXPLOT_WHISKER_LINE_STYLE"); + boxplotvisualiser_->whisker_line_style_ = MagTranslator()(whisker_line_style_value); } - whisker_wrapper->set(request); - boxplotvisualiser_->whisker_ = unique_ptr(whisker_wrapper->object()); - delete whisker_wrapper; + } @@ -108,55 +171,13 @@ void BoxPlotVisualiserWrapper::print(ostream& out) const } -#include "BoxPlotBoxWrapper.h" -static SimpleObjectMaker BoxPlotVisualiser_boxplot_box_box ("box"); -static SimpleObjectMaker BoxPlotVisualiser_boxplot_box_box_wrapper ("box"); - - -#include "BoxPlotBoxWrapper.h" -static SimpleObjectMaker BoxPlotVisualiser_boxplot_box_on ("on"); -static SimpleObjectMaker BoxPlotVisualiser_boxplot_box_on_wrapper ("on"); - - -#include "NoBoxPlotBoxWrapper.h" - -static SimpleObjectMaker BoxPlotVisualiser_boxplot_box_noBox_Wrapper("noBox"); - - -#include "NoBoxPlotBoxWrapper.h" - -static SimpleObjectMaker BoxPlotVisualiser_boxplot_box_off_Wrapper("off"); - - - -#include "BoxPlotWhiskerBoxWrapper.h" -static SimpleObjectMaker BoxPlotVisualiser_boxplot_whisker_whiskerbox ("whiskerbox"); -static SimpleObjectMaker BoxPlotVisualiser_boxplot_whisker_whiskerbox_wrapper ("whiskerbox"); - - -#include "BoxPlotWhiskerBoxWrapper.h" -static SimpleObjectMaker BoxPlotVisualiser_boxplot_whisker_box ("box"); -static SimpleObjectMaker BoxPlotVisualiser_boxplot_whisker_box_wrapper ("box"); - - -#include "NoBoxPlotWhiskerWrapper.h" - -static SimpleObjectMaker BoxPlotVisualiser_boxplot_whisker_nowhisker_Wrapper("nowhisker"); -#include "NoBoxPlotWhiskerWrapper.h" -static SimpleObjectMaker BoxPlotVisualiser_boxplot_whisker_off_Wrapper("off"); -#include "BoxPlotWhiskerLineWrapper.h" -static SimpleObjectMaker BoxPlotVisualiser_boxplot_whisker_whiskerline ("whiskerline"); -static SimpleObjectMaker BoxPlotVisualiser_boxplot_whisker_whiskerline_wrapper ("whiskerline"); -#include "BoxPlotWhiskerLineWrapper.h" -static SimpleObjectMaker BoxPlotVisualiser_boxplot_whisker_line ("line"); -static SimpleObjectMaker BoxPlotVisualiser_boxplot_whisker_line_wrapper ("line"); diff --git a/src/attributes/BoxPlotVisualiserWrapper.h b/src/attributes/BoxPlotVisualiserWrapper.h index 393a4b161..5d42c19ea 100644 --- a/src/attributes/BoxPlotVisualiserWrapper.h +++ b/src/attributes/BoxPlotVisualiserWrapper.h @@ -34,23 +34,20 @@ -#include "BoxPlotDecoderWrapper.h" -#include "NoBoxPlotBoxWrapper.h" -#include "NoBoxPlotWhiskerWrapper.h" - namespace magics { class MagRequest; -class BoxPlotVisualiserWrapper: public BoxPlotDecoderWrapper + +class BoxPlotVisualiserWrapper { public: @@ -69,7 +66,6 @@ class BoxPlotVisualiserWrapper: public BoxPlotDecoderWrapper virtual void object(BoxPlotVisualiser* o) { // Remember to delete the previous object boxplotvisualiser_ = o; - BoxPlotDecoderWrapper::object(o); } diff --git a/src/attributes/EpsGraphAttributes.cc b/src/attributes/EpsGraphAttributes.cc index dfb1563b4..e6666cc75 100644 --- a/src/attributes/EpsGraphAttributes.cc +++ b/src/attributes/EpsGraphAttributes.cc @@ -45,7 +45,7 @@ EpsGraphAttributes::EpsGraphAttributes(): deterministic_(ParameterManager::getBool("eps_deterministic")), deterministic_thickness_(ParameterManager::getInt("eps_deterministic_line_thickness")), deterministic_legend_(ParameterManager::getString("eps_deterministic_legend_text")), - control_(ParameterManager::getBool("eps_control")), + eps_control_(ParameterManager::getBool("eps_control")), control_thickness_(ParameterManager::getInt("eps_control_line_thickness")), control_legend_(ParameterManager::getString("eps_control_legend_text")), legend_(ParameterManager::getBool("legend")), @@ -99,7 +99,7 @@ void EpsGraphAttributes::set(const std::map& params) setAttribute(prefix, "eps_deterministic", deterministic_, params); setAttribute(prefix, "eps_deterministic_line_thickness", deterministic_thickness_, params); setAttribute(prefix, "eps_deterministic_legend_text", deterministic_legend_, params); - setAttribute(prefix, "eps_control", control_, params); + setAttribute(prefix, "eps_control", eps_control_, params); setAttribute(prefix, "eps_control_line_thickness", control_thickness_, params); setAttribute(prefix, "eps_control_legend_text", control_legend_, params); setAttribute(prefix, "legend", legend_, params); @@ -141,7 +141,7 @@ void EpsGraphAttributes::copy(const EpsGraphAttributes& other) deterministic_ = other.deterministic_; deterministic_thickness_ = other.deterministic_thickness_; deterministic_legend_ = other.deterministic_legend_; - control_ = other.control_; + eps_control_ = other.eps_control_; control_thickness_ = other.control_thickness_; control_legend_ = other.control_legend_; legend_ = other.legend_; @@ -215,7 +215,7 @@ void EpsGraphAttributes::print(ostream& out) const out << " deterministic = " << deterministic_; out << " deterministic_thickness = " << deterministic_thickness_; out << " deterministic_legend = " << deterministic_legend_; - out << " control = " << control_; + out << " eps_control = " << eps_control_; out << " control_thickness = " << control_thickness_; out << " control_legend = " << control_legend_; out << " legend = " << legend_; @@ -279,7 +279,7 @@ void EpsGraphAttributes::toxml(ostream& out) const out << ", \"eps_deterministic_legend_text\":"; niceprint(out,deterministic_legend_); out << ", \"eps_control\":"; - niceprint(out,control_); + niceprint(out,eps_control_); out << ", \"eps_control_line_thickness\":"; niceprint(out,control_thickness_); out << ", \"eps_control_legend_text\":"; diff --git a/src/attributes/EpsGraphAttributes.h b/src/attributes/EpsGraphAttributes.h index 4b5edc5c4..c51a4323a 100644 --- a/src/attributes/EpsGraphAttributes.h +++ b/src/attributes/EpsGraphAttributes.h @@ -71,7 +71,7 @@ class EpsGraphAttributes bool deterministic_; int deterministic_thickness_; string deterministic_legend_; - bool control_; + bool eps_control_; int control_thickness_; string control_legend_; bool legend_; diff --git a/src/attributes/EpsGraphWrapper.cc b/src/attributes/EpsGraphWrapper.cc index 0d29f71c4..f21b51b34 100644 --- a/src/attributes/EpsGraphWrapper.cc +++ b/src/attributes/EpsGraphWrapper.cc @@ -141,9 +141,9 @@ void EpsGraphWrapper::set(const MagRequest& request) epsgraph_->deterministic_legend_ = deterministic_legend_value; } if (request.countValues("EPS_CONTROL") ) { - string control_value = request("EPS_CONTROL"); + string eps_control_value = request("EPS_CONTROL"); - epsgraph_->control_ = MagTranslator()(control_value); + epsgraph_->eps_control_ = MagTranslator()(eps_control_value); } if (request.countValues("EPS_CONTROL_LINE_THICKNESS") ) { diff --git a/src/attributes/EpsPlumeAttributes.cc b/src/attributes/EpsPlumeAttributes.cc index 5518fc280..bb6f02b29 100644 --- a/src/attributes/EpsPlumeAttributes.cc +++ b/src/attributes/EpsPlumeAttributes.cc @@ -27,6 +27,7 @@ using namespace magics; EpsPlumeAttributes::EpsPlumeAttributes(): method_(ParameterManager::getString("eps_plume_method")), legend_(ParameterManager::getBool("eps_plume_legend")), + legend_grey_style_(ParameterManager::getBool("eps_plume_legend_grey_style")), line_(ParameterManager::getBool("eps_plume_members")), line_thickness_(ParameterManager::getInt("eps_plume_line_thickness")), forecast_(ParameterManager::getBool("eps_plume_forecast")), @@ -35,9 +36,20 @@ EpsPlumeAttributes::EpsPlumeAttributes(): control_line_thickness_(ParameterManager::getInt("eps_plume_control_line_thickness")), median_(ParameterManager::getBool("eps_plume_median")), median_line_thickness_(ParameterManager::getInt("eps_plume_median_line_thickness")), + percentiles_(ParameterManager::getBool("eps_plume_percentiles")), + percentiles_list_(ParameterManager::getDoubleArray("eps_plume_percentiles_list")), + percentiles_line_colour_list_(ParameterManager::getStringArray("eps_plume_percentiles_line_colour_list")), + percentiles_line_style_list_(ParameterManager::getStringArray("eps_plume_percentiles_line_style_list")), + percentiles_line_thickness_list_(ParameterManager::getIntArray("eps_plume_percentiles_line_thickness_list")), shading_(ParameterManager::getBool("eps_plume_shading")), shading_levels_(ParameterManager::getDoubleArray("eps_plume_shading_level_list")), - shading_colours_(ParameterManager::getStringArray("eps_plume_shading_colour_list")) + shading_colours_(ParameterManager::getStringArray("eps_plume_shading_colour_list")), + background_level_list_(ParameterManager::getDoubleArray("eps_plume_background_level_list")), + background_colour_list_(ParameterManager::getStringArray("eps_plume_background_colour_list")), + background_label_list_(ParameterManager::getStringArray("eps_plume_background_label_list")), + background_label_font_(ParameterManager::getString("eps_plume_background_label_font")), + background_label_font_size_(ParameterManager::getDouble("eps_plume_background_label_font_size")), + background_label_font_style_(ParameterManager::getString("eps_plume_background_label_font_style")) , line_colour_(MagTranslator().magics("eps_plume_line_colour")), line_style_(MagTranslator().magics("eps_plume_line_style")), @@ -46,7 +58,8 @@ EpsPlumeAttributes::EpsPlumeAttributes(): control_line_colour_(MagTranslator().magics("eps_plume_control_line_colour")), control_line_style_(MagTranslator().magics("eps_plume_control_line_style")), median_line_colour_(MagTranslator().magics("eps_plume_median_line_colour")), - median_line_style_(MagTranslator().magics("eps_plume_median_line_style")) + median_line_style_(MagTranslator().magics("eps_plume_median_line_style")), + background_label_font_colour_(MagTranslator().magics("eps_plume_background_label_font_colour")) { } @@ -67,6 +80,7 @@ void EpsPlumeAttributes::set(const std::map& params) setAttribute(prefix, "eps_plume_method", method_, params); setAttribute(prefix, "eps_plume_legend", legend_, params); + setAttribute(prefix, "eps_plume_legend_grey_style", legend_grey_style_, params); setAttribute(prefix, "eps_plume_members", line_, params); setAttribute(prefix, "eps_plume_line_thickness", line_thickness_, params); setAttribute(prefix, "eps_plume_forecast", forecast_, params); @@ -75,9 +89,20 @@ void EpsPlumeAttributes::set(const std::map& params) setAttribute(prefix, "eps_plume_control_line_thickness", control_line_thickness_, params); setAttribute(prefix, "eps_plume_median", median_, params); setAttribute(prefix, "eps_plume_median_line_thickness", median_line_thickness_, params); + setAttribute(prefix, "eps_plume_percentiles", percentiles_, params); + setAttribute(prefix, "eps_plume_percentiles_list", percentiles_list_, params); + setAttribute(prefix, "eps_plume_percentiles_line_colour_list", percentiles_line_colour_list_, params); + setAttribute(prefix, "eps_plume_percentiles_line_style_list", percentiles_line_style_list_, params); + setAttribute(prefix, "eps_plume_percentiles_line_thickness_list", percentiles_line_thickness_list_, params); setAttribute(prefix, "eps_plume_shading", shading_, params); setAttribute(prefix, "eps_plume_shading_level_list", shading_levels_, params); setAttribute(prefix, "eps_plume_shading_colour_list", shading_colours_, params); + setAttribute(prefix, "eps_plume_background_level_list", background_level_list_, params); + setAttribute(prefix, "eps_plume_background_colour_list", background_colour_list_, params); + setAttribute(prefix, "eps_plume_background_label_list", background_label_list_, params); + setAttribute(prefix, "eps_plume_background_label_font", background_label_font_, params); + setAttribute(prefix, "eps_plume_background_label_font_size", background_label_font_size_, params); + setAttribute(prefix, "eps_plume_background_label_font_style", background_label_font_style_, params); setMember(prefix, "eps_plume_line_colour", line_colour_, params); setAttribute(prefix, "eps_plume_line_style", line_style_, params); @@ -87,6 +112,7 @@ void EpsPlumeAttributes::set(const std::map& params) setAttribute(prefix, "eps_plume_control_line_style", control_line_style_, params); setMember(prefix, "eps_plume_median_line_colour", median_line_colour_, params); setAttribute(prefix, "eps_plume_median_line_style", median_line_style_, params); + setMember(prefix, "eps_plume_background_label_font_colour", background_label_font_colour_, params); } @@ -94,6 +120,7 @@ void EpsPlumeAttributes::copy(const EpsPlumeAttributes& other) { method_ = other.method_; legend_ = other.legend_; + legend_grey_style_ = other.legend_grey_style_; line_ = other.line_; line_thickness_ = other.line_thickness_; forecast_ = other.forecast_; @@ -102,9 +129,20 @@ void EpsPlumeAttributes::copy(const EpsPlumeAttributes& other) control_line_thickness_ = other.control_line_thickness_; median_ = other.median_; median_line_thickness_ = other.median_line_thickness_; + percentiles_ = other.percentiles_; + percentiles_list_ = other.percentiles_list_; + percentiles_line_colour_list_ = other.percentiles_line_colour_list_; + percentiles_line_style_list_ = other.percentiles_line_style_list_; + percentiles_line_thickness_list_ = other.percentiles_line_thickness_list_; shading_ = other.shading_; shading_levels_ = other.shading_levels_; shading_colours_ = other.shading_colours_; + background_level_list_ = other.background_level_list_; + background_colour_list_ = other.background_colour_list_; + background_label_list_ = other.background_label_list_; + background_label_font_ = other.background_label_font_; + background_label_font_size_ = other.background_label_font_size_; + background_label_font_style_ = other.background_label_font_style_; line_colour_ = unique_ptr(other.line_colour_->clone()); line_style_ = other.line_style_; forecast_line_colour_ = unique_ptr(other.forecast_line_colour_->clone()); @@ -113,6 +151,7 @@ void EpsPlumeAttributes::copy(const EpsPlumeAttributes& other) control_line_style_ = other.control_line_style_; median_line_colour_ = unique_ptr(other.median_line_colour_->clone()); median_line_style_ = other.median_line_style_; + background_label_font_colour_ = unique_ptr(other.background_label_font_colour_->clone()); } @@ -153,6 +192,7 @@ void EpsPlumeAttributes::print(ostream& out) const out << "Attributes["; out << " method = " << method_; out << " legend = " << legend_; + out << " legend_grey_style = " << legend_grey_style_; out << " line = " << line_; out << " line_thickness = " << line_thickness_; out << " forecast = " << forecast_; @@ -161,9 +201,20 @@ void EpsPlumeAttributes::print(ostream& out) const out << " control_line_thickness = " << control_line_thickness_; out << " median = " << median_; out << " median_line_thickness = " << median_line_thickness_; + out << " percentiles = " << percentiles_; + out << " percentiles_list = " << percentiles_list_; + out << " percentiles_line_colour_list = " << percentiles_line_colour_list_; + out << " percentiles_line_style_list = " << percentiles_line_style_list_; + out << " percentiles_line_thickness_list = " << percentiles_line_thickness_list_; out << " shading = " << shading_; out << " shading_levels = " << shading_levels_; out << " shading_colours = " << shading_colours_; + out << " background_level_list = " << background_level_list_; + out << " background_colour_list = " << background_colour_list_; + out << " background_label_list = " << background_label_list_; + out << " background_label_font = " << background_label_font_; + out << " background_label_font_size = " << background_label_font_size_; + out << " background_label_font_style = " << background_label_font_style_; out << " line_colour = " << *line_colour_; out << " line_style = " << line_style_; out << " forecast_line_colour = " << *forecast_line_colour_; @@ -172,6 +223,7 @@ void EpsPlumeAttributes::print(ostream& out) const out << " control_line_style = " << control_line_style_; out << " median_line_colour = " << *median_line_colour_; out << " median_line_style = " << median_line_style_; + out << " background_label_font_colour = " << *background_label_font_colour_; out << "]" << "\n"; } @@ -183,6 +235,8 @@ void EpsPlumeAttributes::toxml(ostream& out) const niceprint(out,method_); out << ", \"eps_plume_legend\":"; niceprint(out,legend_); + out << ", \"eps_plume_legend_grey_style\":"; + niceprint(out,legend_grey_style_); out << ", \"eps_plume_members\":"; niceprint(out,line_); out << ", \"eps_plume_line_thickness\":"; @@ -199,12 +253,34 @@ void EpsPlumeAttributes::toxml(ostream& out) const niceprint(out,median_); out << ", \"eps_plume_median_line_thickness\":"; niceprint(out,median_line_thickness_); + out << ", \"eps_plume_percentiles\":"; + niceprint(out,percentiles_); + out << ", \"eps_plume_percentiles_list\":"; + niceprint(out,percentiles_list_); + out << ", \"eps_plume_percentiles_line_colour_list\":"; + niceprint(out,percentiles_line_colour_list_); + out << ", \"eps_plume_percentiles_line_style_list\":"; + niceprint(out,percentiles_line_style_list_); + out << ", \"eps_plume_percentiles_line_thickness_list\":"; + niceprint(out,percentiles_line_thickness_list_); out << ", \"eps_plume_shading\":"; niceprint(out,shading_); out << ", \"eps_plume_shading_level_list\":"; niceprint(out,shading_levels_); out << ", \"eps_plume_shading_colour_list\":"; niceprint(out,shading_colours_); + out << ", \"eps_plume_background_level_list\":"; + niceprint(out,background_level_list_); + out << ", \"eps_plume_background_colour_list\":"; + niceprint(out,background_colour_list_); + out << ", \"eps_plume_background_label_list\":"; + niceprint(out,background_label_list_); + out << ", \"eps_plume_background_label_font\":"; + niceprint(out,background_label_font_); + out << ", \"eps_plume_background_label_font_size\":"; + niceprint(out,background_label_font_size_); + out << ", \"eps_plume_background_label_font_style\":"; + niceprint(out,background_label_font_style_); out << ", \"eps_plume_line_colour\":"; niceprint(out, *line_colour_); out << ", \"eps_plume_line_style\":"; @@ -221,11 +297,14 @@ void EpsPlumeAttributes::toxml(ostream& out) const niceprint(out, *median_line_colour_); out << ", \"eps_plume_median_line_style\":"; niceprint(out, median_line_style_); + out << ", \"eps_plume_background_label_font_colour\":"; + niceprint(out, *background_label_font_colour_); } static MagicsParameter eps_plume_method("eps_plume_method", "time_serie"); static MagicsParameter eps_plume_legend("eps_plume_legend", "on"); +static MagicsParameter eps_plume_legend_grey_style("eps_plume_legend_grey_style", "on"); static MagicsParameter eps_plume_members("eps_plume_members", "on"); static MagicsParameter eps_plume_line_thickness("eps_plume_line_thickness", 1); static MagicsParameter eps_plume_forecast("eps_plume_forecast", "on"); @@ -234,9 +313,20 @@ static MagicsParameter eps_plume_control("eps_plume_control", "on"); static MagicsParameter eps_plume_control_line_thickness("eps_plume_control_line_thickness", 5); static MagicsParameter eps_plume_median("eps_plume_median", "off"); static MagicsParameter eps_plume_median_line_thickness("eps_plume_median_line_thickness", 5); +static MagicsParameter eps_plume_percentiles("eps_plume_percentiles", "off"); +static MagicsParameter eps_plume_percentiles_list("eps_plume_percentiles_list", floatarray()); +static MagicsParameter eps_plume_percentiles_line_colour_list("eps_plume_percentiles_line_colour_list", stringarray()); +static MagicsParameter eps_plume_percentiles_line_style_list("eps_plume_percentiles_line_style_list", stringarray()); +static MagicsParameter eps_plume_percentiles_line_thickness_list("eps_plume_percentiles_line_thickness_list", intarray()); static MagicsParameter eps_plume_shading("eps_plume_shading", "off"); static MagicsParameter eps_plume_shading_level_list("eps_plume_shading_level_list", floatarray()); static MagicsParameter eps_plume_shading_colour_list("eps_plume_shading_colour_list", stringarray()); +static MagicsParameter eps_plume_background_level_list("eps_plume_background_level_list", floatarray()); +static MagicsParameter eps_plume_background_colour_list("eps_plume_background_colour_list", stringarray()); +static MagicsParameter eps_plume_background_label_list("eps_plume_background_label_list", stringarray()); +static MagicsParameter eps_plume_background_label_font("eps_plume_background_label_font", "sansserif"); +static MagicsParameter eps_plume_background_label_font_size("eps_plume_background_label_font_size", 0.25); +static MagicsParameter eps_plume_background_label_font_style("eps_plume_background_label_font_style", ""); static MagicsParameter eps_plume_line_colour("eps_plume_line_colour", "magenta"); static MagicsParameter eps_plume_line_style("eps_plume_line_style", "solid"); static MagicsParameter eps_plume_forecast_line_colour("eps_plume_forecast_line_colour", "cyan"); @@ -245,3 +335,4 @@ static MagicsParameter eps_plume_control_line_colour("eps_plume_control_ static MagicsParameter eps_plume_control_line_style("eps_plume_control_line_style", "solid"); static MagicsParameter eps_plume_median_line_colour("eps_plume_median_line_colour", "cyan"); static MagicsParameter eps_plume_median_line_style("eps_plume_median_line_style", "solid"); +static MagicsParameter eps_plume_background_label_font_colour("eps_plume_background_label_font_colour", "black"); diff --git a/src/attributes/EpsPlumeAttributes.h b/src/attributes/EpsPlumeAttributes.h index e233fbf2b..f237745d3 100644 --- a/src/attributes/EpsPlumeAttributes.h +++ b/src/attributes/EpsPlumeAttributes.h @@ -53,6 +53,7 @@ class EpsPlumeAttributes string tag_; string method_; bool legend_; + bool legend_grey_style_; bool line_; int line_thickness_; bool forecast_; @@ -61,9 +62,20 @@ class EpsPlumeAttributes int control_line_thickness_; bool median_; int median_line_thickness_; + bool percentiles_; + doublearray percentiles_list_; + stringarray percentiles_line_colour_list_; + stringarray percentiles_line_style_list_; + intarray percentiles_line_thickness_list_; bool shading_; doublearray shading_levels_; stringarray shading_colours_; + doublearray background_level_list_; + stringarray background_colour_list_; + stringarray background_label_list_; + string background_label_font_; + double background_label_font_size_; + string background_label_font_style_; unique_ptr line_colour_; LineStyle line_style_; unique_ptr forecast_line_colour_; @@ -72,6 +84,7 @@ class EpsPlumeAttributes LineStyle control_line_style_; unique_ptr median_line_colour_; LineStyle median_line_style_; + unique_ptr background_label_font_colour_; private: diff --git a/src/attributes/EpsPlumeWrapper.cc b/src/attributes/EpsPlumeWrapper.cc index 1f9aac7b8..4d388e370 100644 --- a/src/attributes/EpsPlumeWrapper.cc +++ b/src/attributes/EpsPlumeWrapper.cc @@ -64,6 +64,12 @@ void EpsPlumeWrapper::set(const MagRequest& request) epsplume_->legend_ = MagTranslator()(legend_value); + } + if (request.countValues("EPS_PLUME_LEGEND_GREY_STYLE") ) { + string legend_grey_style_value = request("EPS_PLUME_LEGEND_GREY_STYLE"); + + epsplume_->legend_grey_style_ = MagTranslator()(legend_grey_style_value); + } if (request.countValues("EPS_PLUME_MEMBERS") ) { string line_value = request("EPS_PLUME_MEMBERS"); @@ -105,6 +111,32 @@ void EpsPlumeWrapper::set(const MagRequest& request) int median_line_thickness_value = request("EPS_PLUME_MEDIAN_LINE_THICKNESS"); epsplume_->median_line_thickness_ = median_line_thickness_value; } + if (request.countValues("EPS_PLUME_PERCENTILES") ) { + string percentiles_value = request("EPS_PLUME_PERCENTILES"); + + epsplume_->percentiles_ = MagTranslator()(percentiles_value); + + } + doublearray percentiles_list_value; + for (int i = 0; i < request.countValues("EPS_PLUME_PERCENTILES_LIST"); i++) + percentiles_list_value.push_back((double)request("EPS_PLUME_PERCENTILES_LIST", i)); + if ( !percentiles_list_value.empty() ) + epsplume_->percentiles_list_ = percentiles_list_value; + stringarray percentiles_line_colour_list_value; + for (int i = 0; i < request.countValues("EPS_PLUME_PERCENTILES_LINE_COLOUR_LIST"); i++) + percentiles_line_colour_list_value.push_back((string)request("EPS_PLUME_PERCENTILES_LINE_COLOUR_LIST", i)); + if ( !percentiles_line_colour_list_value.empty() ) + epsplume_->percentiles_line_colour_list_ = percentiles_line_colour_list_value; + stringarray percentiles_line_style_list_value; + for (int i = 0; i < request.countValues("EPS_PLUME_PERCENTILES_LINE_STYLE_LIST"); i++) + percentiles_line_style_list_value.push_back((string)request("EPS_PLUME_PERCENTILES_LINE_STYLE_LIST", i)); + if ( !percentiles_line_style_list_value.empty() ) + epsplume_->percentiles_line_style_list_ = percentiles_line_style_list_value; + intarray percentiles_line_thickness_list_value; + for (int i = 0; i < request.countValues("EPS_PLUME_PERCENTILES_LINE_THICKNESS_LIST"); i++) + percentiles_line_thickness_list_value.push_back((int)request("EPS_PLUME_PERCENTILES_LINE_THICKNESS_LIST", i)); + if ( !percentiles_line_thickness_list_value.empty() ) + epsplume_->percentiles_line_thickness_list_ = percentiles_line_thickness_list_value; if (request.countValues("EPS_PLUME_SHADING") ) { string shading_value = request("EPS_PLUME_SHADING"); @@ -121,6 +153,33 @@ void EpsPlumeWrapper::set(const MagRequest& request) shading_colours_value.push_back((string)request("EPS_PLUME_SHADING_COLOUR_LIST", i)); if ( !shading_colours_value.empty() ) epsplume_->shading_colours_ = shading_colours_value; + doublearray background_level_list_value; + for (int i = 0; i < request.countValues("EPS_PLUME_BACKGROUND_LEVEL_LIST"); i++) + background_level_list_value.push_back((double)request("EPS_PLUME_BACKGROUND_LEVEL_LIST", i)); + if ( !background_level_list_value.empty() ) + epsplume_->background_level_list_ = background_level_list_value; + stringarray background_colour_list_value; + for (int i = 0; i < request.countValues("EPS_PLUME_BACKGROUND_COLOUR_LIST"); i++) + background_colour_list_value.push_back((string)request("EPS_PLUME_BACKGROUND_COLOUR_LIST", i)); + if ( !background_colour_list_value.empty() ) + epsplume_->background_colour_list_ = background_colour_list_value; + stringarray background_label_list_value; + for (int i = 0; i < request.countValues("EPS_PLUME_BACKGROUND_LABEL_LIST"); i++) + background_label_list_value.push_back((string)request("EPS_PLUME_BACKGROUND_LABEL_LIST", i)); + if ( !background_label_list_value.empty() ) + epsplume_->background_label_list_ = background_label_list_value; + if (request.countValues("EPS_PLUME_BACKGROUND_LABEL_FONT") ) { + string background_label_font_value = request("EPS_PLUME_BACKGROUND_LABEL_FONT"); + epsplume_->background_label_font_ = background_label_font_value; + } + if (request.countValues("EPS_PLUME_BACKGROUND_LABEL_FONT_SIZE") ) { + double background_label_font_size_value = request("EPS_PLUME_BACKGROUND_LABEL_FONT_SIZE"); + epsplume_->background_label_font_size_ = background_label_font_size_value; + } + if (request.countValues("EPS_PLUME_BACKGROUND_LABEL_FONT_STYLE") ) { + string background_label_font_style_value = request("EPS_PLUME_BACKGROUND_LABEL_FONT_STYLE"); + epsplume_->background_label_font_style_ = background_label_font_style_value; + } if (request.countValues("EPS_PLUME_LINE_COLOUR") ) { string line_colour_value = request("EPS_PLUME_LINE_COLOUR"); @@ -166,6 +225,11 @@ void EpsPlumeWrapper::set(const MagRequest& request) epsplume_->median_line_style_ = MagTranslator()(median_line_style_value); } + if (request.countValues("EPS_PLUME_BACKGROUND_LABEL_FONT_COLOUR") ) { + string background_label_font_colour_value = request("EPS_PLUME_BACKGROUND_LABEL_FONT_COLOUR"); + epsplume_->background_label_font_colour_ = unique_ptr(MagTranslator()(background_label_font_colour_value)); + } + } @@ -183,3 +247,4 @@ void EpsPlumeWrapper::print(ostream& out) const + diff --git a/src/attributes/EpsWaveAttributes.cc b/src/attributes/EpsWaveAttributes.cc index a8b326ff8..77fa20864 100644 --- a/src/attributes/EpsWaveAttributes.cc +++ b/src/attributes/EpsWaveAttributes.cc @@ -25,7 +25,8 @@ using namespace magics; EpsWaveAttributes::EpsWaveAttributes(): - colour_(ParameterManager::getStringArray("eps_rose_wave_colour")) + colour_(ParameterManager::getStringArray("eps_rose_wave_colour")), + eps_control_(ParameterManager::getBool("eps_control")) { @@ -46,6 +47,7 @@ void EpsWaveAttributes::set(const std::map& params) prefix[i++] = "eps_rose_wave"; setAttribute(prefix, "eps_rose_wave_colour", colour_, params); + setAttribute(prefix, "eps_control", eps_control_, params); } @@ -53,6 +55,7 @@ void EpsWaveAttributes::set(const std::map& params) void EpsWaveAttributes::copy(const EpsWaveAttributes& other) { colour_ = other.colour_; + eps_control_ = other.eps_control_; } @@ -92,6 +95,7 @@ void EpsWaveAttributes::print(ostream& out) const { out << "Attributes["; out << " colour = " << colour_; + out << " eps_control = " << eps_control_; out << "]" << "\n"; } @@ -101,7 +105,10 @@ void EpsWaveAttributes::toxml(ostream& out) const out << "\"epswave\""; out << ", \"eps_rose_wave_colour\":"; niceprint(out,colour_); + out << ", \"eps_control\":"; + niceprint(out,eps_control_); } static MagicsParameter eps_rose_wave_colour("eps_rose_wave_colour", stringarray()); +static MagicsParameter eps_control("eps_control", "on"); diff --git a/src/attributes/EpsWaveAttributes.h b/src/attributes/EpsWaveAttributes.h index 2fa412adb..6a63a29a8 100644 --- a/src/attributes/EpsWaveAttributes.h +++ b/src/attributes/EpsWaveAttributes.h @@ -51,6 +51,7 @@ class EpsWaveAttributes // -- members: string tag_; stringarray colour_; + bool eps_control_; private: diff --git a/src/attributes/EpsWaveWrapper.cc b/src/attributes/EpsWaveWrapper.cc index c4a145e69..7e14c28df 100644 --- a/src/attributes/EpsWaveWrapper.cc +++ b/src/attributes/EpsWaveWrapper.cc @@ -60,6 +60,12 @@ void EpsWaveWrapper::set(const MagRequest& request) colour_value.push_back((string)request("EPS_ROSE_WAVE_COLOUR", i)); if ( !colour_value.empty() ) epswave_->colour_ = colour_value; + if (request.countValues("EPS_CONTROL") ) { + string eps_control_value = request("EPS_CONTROL"); + + epswave_->eps_control_ = MagTranslator()(eps_control_value); + + } } diff --git a/src/attributes/GeoJSonAttributes.cc b/src/attributes/GeoJSonAttributes.cc index 28f0bda4e..ab58f95be 100644 --- a/src/attributes/GeoJSonAttributes.cc +++ b/src/attributes/GeoJSonAttributes.cc @@ -28,7 +28,8 @@ GeoJSonAttributes::GeoJSonAttributes(): type_(ParameterManager::getString("geojson_input_type")), path_(ParameterManager::getString("geojson_input_filename")), input_(ParameterManager::getString("geojson_input")), - binning_resolution_(ParameterManager::getDouble("geojson_binning_grid_resolution")) + binning_resolution_(ParameterManager::getDouble("geojson_binning_grid_resolution")), + value_(ParameterManager::getString("geojson_value_property")) { @@ -51,6 +52,7 @@ void GeoJSonAttributes::set(const std::map& params) setAttribute(prefix, "geojson_input_filename", path_, params); setAttribute(prefix, "geojson_input", input_, params); setAttribute(prefix, "geojson_binning_grid_resolution", binning_resolution_, params); + setAttribute(prefix, "geojson_value_property", value_, params); } @@ -61,6 +63,7 @@ void GeoJSonAttributes::copy(const GeoJSonAttributes& other) path_ = other.path_; input_ = other.input_; binning_resolution_ = other.binning_resolution_; + value_ = other.value_; } @@ -103,6 +106,7 @@ void GeoJSonAttributes::print(ostream& out) const out << " path = " << path_; out << " input = " << input_; out << " binning_resolution = " << binning_resolution_; + out << " value = " << value_; out << "]" << "\n"; } @@ -118,6 +122,8 @@ void GeoJSonAttributes::toxml(ostream& out) const niceprint(out,input_); out << ", \"geojson_binning_grid_resolution\":"; niceprint(out,binning_resolution_); + out << ", \"geojson_value_property\":"; + niceprint(out,value_); } @@ -125,3 +131,4 @@ static MagicsParameter geojson_input_type("geojson_input_type", "file"); static MagicsParameter geojson_input_filename("geojson_input_filename", ""); static MagicsParameter geojson_input("geojson_input", "{}"); static MagicsParameter geojson_binning_grid_resolution("geojson_binning_grid_resolution", 1.); +static MagicsParameter geojson_value_property("geojson_value_property", "value"); diff --git a/src/attributes/GeoJSonAttributes.h b/src/attributes/GeoJSonAttributes.h index 739fa73df..c9e43bff0 100644 --- a/src/attributes/GeoJSonAttributes.h +++ b/src/attributes/GeoJSonAttributes.h @@ -54,6 +54,7 @@ class GeoJSonAttributes string path_; string input_; double binning_resolution_; + string value_; private: diff --git a/src/attributes/GeoJSonWrapper.cc b/src/attributes/GeoJSonWrapper.cc index 1d9b3bd32..e95e78ee2 100644 --- a/src/attributes/GeoJSonWrapper.cc +++ b/src/attributes/GeoJSonWrapper.cc @@ -71,6 +71,10 @@ void GeoJSonWrapper::set(const MagRequest& request) double binning_resolution_value = request("GEOJSON_BINNING_GRID_RESOLUTION"); geojson_->binning_resolution_ = binning_resolution_value; } + if (request.countValues("GEOJSON_VALUE_PROPERTY") ) { + string value_value = request("GEOJSON_VALUE_PROPERTY"); + geojson_->value_ = value_value; + } } diff --git a/src/attributes/GribDecoderAttributes.cc b/src/attributes/GribDecoderAttributes.cc index 9ead15a43..8c44856a1 100644 --- a/src/attributes/GribDecoderAttributes.cc +++ b/src/attributes/GribDecoderAttributes.cc @@ -26,6 +26,9 @@ using namespace magics; GribDecoderAttributes::GribDecoderAttributes(): file_name_(ParameterManager::getString("grib_input_file_name")), + first_file_name_(ParameterManager::getString("grib_first_component_file_name")), + colour_file_name_(ParameterManager::getString("grib_colour_component_file_name")), + second_file_name_(ParameterManager::getString("grib_second_component_file_name")), id_(ParameterManager::getString("grib_id")), loop_(ParameterManager::getBool("grib_loop")), scaling_(ParameterManager::getBool("grib_automatic_scaling")), @@ -38,9 +41,13 @@ GribDecoderAttributes::GribDecoderAttributes(): expver_(ParameterManager::getBool("grib_text_experiment")), units_(ParameterManager::getBool("grib_text_units")), field_position_(ParameterManager::getInt("grib_field_position")), + large_field_position_(ParameterManager::getULong("grib_field_large_position")), position_1_(ParameterManager::getInt("grib_wind_position_1")), position_2_(ParameterManager::getInt("grib_wind_position_2")), colour_position_(ParameterManager::getInt("grib_wind_position_colour")), + large_position_1_(ParameterManager::getULong("grib_wind_large_position_1")), + large_position_2_(ParameterManager::getULong("grib_wind_large_position_2")), + large_colour_position_(ParameterManager::getULong("grib_wind_large_position_colour")), missing_value_(ParameterManager::getDouble("grib_missing_value_indicator")), wind_style_(ParameterManager::getBool("grib_wind_style")) , @@ -65,6 +72,9 @@ void GribDecoderAttributes::set(const std::map& params) prefix[i++] = "grib"; setAttribute(prefix, "grib_input_file_name", file_name_, params); + setAttribute(prefix, "grib_first_component_file_name", first_file_name_, params); + setAttribute(prefix, "grib_colour_component_file_name", colour_file_name_, params); + setAttribute(prefix, "grib_second_component_file_name", second_file_name_, params); setAttribute(prefix, "grib_id", id_, params); setAttribute(prefix, "grib_loop", loop_, params); setAttribute(prefix, "grib_automatic_scaling", scaling_, params); @@ -77,9 +87,13 @@ void GribDecoderAttributes::set(const std::map& params) setAttribute(prefix, "grib_text_experiment", expver_, params); setAttribute(prefix, "grib_text_units", units_, params); setAttribute(prefix, "grib_field_position", field_position_, params); + setAttribute(prefix, "grib_field_large_position", large_field_position_, params); setAttribute(prefix, "grib_wind_position_1", position_1_, params); setAttribute(prefix, "grib_wind_position_2", position_2_, params); setAttribute(prefix, "grib_wind_position_colour", colour_position_, params); + setAttribute(prefix, "grib_wind_large_position_1", large_position_1_, params); + setAttribute(prefix, "grib_wind_large_position_2", large_position_2_, params); + setAttribute(prefix, "grib_wind_large_position_colour", large_colour_position_, params); setAttribute(prefix, "grib_missing_value_indicator", missing_value_, params); setAttribute(prefix, "grib_wind_style", wind_style_, params); @@ -91,6 +105,9 @@ void GribDecoderAttributes::set(const std::map& params) void GribDecoderAttributes::copy(const GribDecoderAttributes& other) { file_name_ = other.file_name_; + first_file_name_ = other.first_file_name_; + colour_file_name_ = other.colour_file_name_; + second_file_name_ = other.second_file_name_; id_ = other.id_; loop_ = other.loop_; scaling_ = other.scaling_; @@ -103,9 +120,13 @@ void GribDecoderAttributes::copy(const GribDecoderAttributes& other) expver_ = other.expver_; units_ = other.units_; field_position_ = other.field_position_; + large_field_position_ = other.large_field_position_; position_1_ = other.position_1_; position_2_ = other.position_2_; colour_position_ = other.colour_position_; + large_position_1_ = other.large_position_1_; + large_position_2_ = other.large_position_2_; + large_colour_position_ = other.large_colour_position_; missing_value_ = other.missing_value_; wind_style_ = other.wind_style_; address_mode_ = unique_ptr(other.address_mode_->clone()); @@ -157,6 +178,9 @@ void GribDecoderAttributes::print(ostream& out) const { out << "Attributes["; out << " file_name = " << file_name_; + out << " first_file_name = " << first_file_name_; + out << " colour_file_name = " << colour_file_name_; + out << " second_file_name = " << second_file_name_; out << " id = " << id_; out << " loop = " << loop_; out << " scaling = " << scaling_; @@ -169,9 +193,13 @@ void GribDecoderAttributes::print(ostream& out) const out << " expver = " << expver_; out << " units = " << units_; out << " field_position = " << field_position_; + out << " large_field_position = " << large_field_position_; out << " position_1 = " << position_1_; out << " position_2 = " << position_2_; out << " colour_position = " << colour_position_; + out << " large_position_1 = " << large_position_1_; + out << " large_position_2 = " << large_position_2_; + out << " large_colour_position = " << large_colour_position_; out << " missing_value = " << missing_value_; out << " wind_style = " << wind_style_; out << " address_mode = " << *address_mode_; @@ -185,6 +213,12 @@ void GribDecoderAttributes::toxml(ostream& out) const out << "\"grib\""; out << ", \"grib_input_file_name\":"; niceprint(out,file_name_); + out << ", \"grib_first_component_file_name\":"; + niceprint(out,first_file_name_); + out << ", \"grib_colour_component_file_name\":"; + niceprint(out,colour_file_name_); + out << ", \"grib_second_component_file_name\":"; + niceprint(out,second_file_name_); out << ", \"grib_id\":"; niceprint(out,id_); out << ", \"grib_loop\":"; @@ -209,12 +243,20 @@ void GribDecoderAttributes::toxml(ostream& out) const niceprint(out,units_); out << ", \"grib_field_position\":"; niceprint(out,field_position_); + out << ", \"grib_field_large_position\":"; + niceprint(out,large_field_position_); out << ", \"grib_wind_position_1\":"; niceprint(out,position_1_); out << ", \"grib_wind_position_2\":"; niceprint(out,position_2_); out << ", \"grib_wind_position_colour\":"; niceprint(out,colour_position_); + out << ", \"grib_wind_large_position_1\":"; + niceprint(out,large_position_1_); + out << ", \"grib_wind_large_position_2\":"; + niceprint(out,large_position_2_); + out << ", \"grib_wind_large_position_colour\":"; + niceprint(out,large_colour_position_); out << ", \"grib_missing_value_indicator\":"; niceprint(out,missing_value_); out << ", \"grib_wind_style\":"; @@ -227,6 +269,9 @@ void GribDecoderAttributes::toxml(ostream& out) const } static MagicsParameter grib_input_file_name("grib_input_file_name", ""); +static MagicsParameter grib_first_component_file_name("grib_first_component_file_name", "grib_input_file_name"); +static MagicsParameter grib_colour_component_file_name("grib_colour_component_file_name", "grib_input_file_name"); +static MagicsParameter grib_second_component_file_name("grib_second_component_file_name", "grib_input_file_name"); static MagicsParameter grib_id("grib_id", ""); static MagicsParameter grib_loop("grib_loop", "off"); static MagicsParameter grib_automatic_scaling("grib_automatic_scaling", "on"); @@ -239,9 +284,13 @@ static MagicsParameter grib_interpolation_method_missing_fill_count("grib_i static MagicsParameter grib_text_experiment("grib_text_experiment", "off"); static MagicsParameter grib_text_units("grib_text_units", "off"); static MagicsParameter grib_field_position("grib_field_position", 1); +static MagicsParameter grib_field_large_position("grib_field_large_position", 0); static MagicsParameter grib_wind_position_1("grib_wind_position_1", 1); -static MagicsParameter grib_wind_position_2("grib_wind_position_2", 2); -static MagicsParameter grib_wind_position_colour("grib_wind_position_colour", 3); +static MagicsParameter grib_wind_position_2("grib_wind_position_2", -1); +static MagicsParameter grib_wind_position_colour("grib_wind_position_colour", -1); +static MagicsParameter grib_wind_large_position_1("grib_wind_large_position_1", 0); +static MagicsParameter grib_wind_large_position_2("grib_wind_large_position_2", 0); +static MagicsParameter grib_wind_large_position_colour("grib_wind_large_position_colour", 0); static MagicsParameter grib_missing_value_indicator("grib_missing_value_indicator", -1.5e+21); static MagicsParameter grib_wind_style("grib_wind_style", "off"); static MagicsParameter grib_file_address_mode("grib_file_address_mode", "record"); diff --git a/src/attributes/GribDecoderAttributes.h b/src/attributes/GribDecoderAttributes.h index 6e272fe6c..090aa4ba8 100644 --- a/src/attributes/GribDecoderAttributes.h +++ b/src/attributes/GribDecoderAttributes.h @@ -53,6 +53,9 @@ class GribDecoderAttributes // -- members: string tag_; string file_name_; + string first_file_name_; + string colour_file_name_; + string second_file_name_; string id_; bool loop_; bool scaling_; @@ -65,9 +68,13 @@ class GribDecoderAttributes bool expver_; bool units_; int field_position_; + unsigned long long large_field_position_; int position_1_; int position_2_; int colour_position_; + unsigned long long large_position_1_; + unsigned long long large_position_2_; + unsigned long long large_colour_position_; double missing_value_; bool wind_style_; unique_ptr address_mode_; diff --git a/src/attributes/GribDecoderWrapper.cc b/src/attributes/GribDecoderWrapper.cc index c98405938..cec441ce6 100644 --- a/src/attributes/GribDecoderWrapper.cc +++ b/src/attributes/GribDecoderWrapper.cc @@ -59,6 +59,18 @@ void GribDecoderWrapper::set(const MagRequest& request) string file_name_value = request("GRIB_INPUT_FILE_NAME"); gribdecoder_->file_name_ = file_name_value; } + if (request.countValues("GRIB_FIRST_COMPONENT_FILE_NAME") ) { + string first_file_name_value = request("GRIB_FIRST_COMPONENT_FILE_NAME"); + gribdecoder_->first_file_name_ = first_file_name_value; + } + if (request.countValues("GRIB_COLOUR_COMPONENT_FILE_NAME") ) { + string colour_file_name_value = request("GRIB_COLOUR_COMPONENT_FILE_NAME"); + gribdecoder_->colour_file_name_ = colour_file_name_value; + } + if (request.countValues("GRIB_SECOND_COMPONENT_FILE_NAME") ) { + string second_file_name_value = request("GRIB_SECOND_COMPONENT_FILE_NAME"); + gribdecoder_->second_file_name_ = second_file_name_value; + } if (request.countValues("GRIB_ID") ) { string id_value = request("GRIB_ID"); gribdecoder_->id_ = id_value; @@ -117,6 +129,10 @@ void GribDecoderWrapper::set(const MagRequest& request) int field_position_value = request("GRIB_FIELD_POSITION"); gribdecoder_->field_position_ = field_position_value; } + if (request.countValues("GRIB_FIELD_LARGE_POSITION") ) { + unsigned long long large_field_position_value = request("GRIB_FIELD_LARGE_POSITION"); + gribdecoder_->large_field_position_ = large_field_position_value; + } if (request.countValues("GRIB_WIND_POSITION_1") ) { int position_1_value = request("GRIB_WIND_POSITION_1"); gribdecoder_->position_1_ = position_1_value; @@ -129,6 +145,18 @@ void GribDecoderWrapper::set(const MagRequest& request) int colour_position_value = request("GRIB_WIND_POSITION_COLOUR"); gribdecoder_->colour_position_ = colour_position_value; } + if (request.countValues("GRIB_WIND_LARGE_POSITION_1") ) { + unsigned long long large_position_1_value = request("GRIB_WIND_LARGE_POSITION_1"); + gribdecoder_->large_position_1_ = large_position_1_value; + } + if (request.countValues("GRIB_WIND_LARGE_POSITION_2") ) { + unsigned long long large_position_2_value = request("GRIB_WIND_LARGE_POSITION_2"); + gribdecoder_->large_position_2_ = large_position_2_value; + } + if (request.countValues("GRIB_WIND_LARGE_POSITION_COLOUR") ) { + unsigned long long large_colour_position_value = request("GRIB_WIND_LARGE_POSITION_COLOUR"); + gribdecoder_->large_colour_position_ = large_colour_position_value; + } if (request.countValues("GRIB_MISSING_VALUE_INDICATOR") ) { double missing_value_value = request("GRIB_MISSING_VALUE_INDICATOR"); gribdecoder_->missing_value_ = missing_value_value; diff --git a/src/attributes/MagicsSettingsWrapper.cc b/src/attributes/MagicsSettingsWrapper.cc index 15b36bf10..830af363a 100644 --- a/src/attributes/MagicsSettingsWrapper.cc +++ b/src/attributes/MagicsSettingsWrapper.cc @@ -24,13 +24,15 @@ #include "MagicsParameter.h" #include "Factory.h" #include "MagTranslator.h" -#include "MagicsSettings.h" +#include "MagicsGlobal.h" using namespace magics; + MagicsSettingsWrapper::MagicsSettingsWrapper(): magicssettings_(new MagicsSettings()) + { @@ -55,15 +57,21 @@ void MagicsSettingsWrapper::set(const MagRequest& request) if (request.countValues("MAGICS_SILENT") ) { string silent_value = request("MAGICS_SILENT"); + magicssettings_->silent_ = MagTranslator()(silent_value); + } if (request.countValues("MAGICS_BACKWARD_COMPATIBILITY") ) { string compatibility_value = request("MAGICS_BACKWARD_COMPATIBILITY"); + magicssettings_->compatibility_ = MagTranslator()(compatibility_value); + } if (request.countValues("MAGICS_STRICT_MODE") ) { string strict_value = request("MAGICS_STRICT_MODE"); + magicssettings_->strict_ = MagTranslator()(strict_value); + } diff --git a/src/attributes/NetcdfInterpretorAttributes.cc b/src/attributes/NetcdfInterpretorAttributes.cc index ae440323c..26109872d 100644 --- a/src/attributes/NetcdfInterpretorAttributes.cc +++ b/src/attributes/NetcdfInterpretorAttributes.cc @@ -58,7 +58,8 @@ NetcdfInterpretorAttributes::NetcdfInterpretorAttributes(): geo_y_convention_(ParameterManager::getString("netcdf_y_geoline_convention")), aux_y_(ParameterManager::getString("netcdf_y_auxiliary_variable")), primary_index_(ParameterManager::getString("netcdf_matrix_primary_index")), - interpretation_(ParameterManager::getString("netcdf_matrix_interpretation")) + interpretation_(ParameterManager::getString("netcdf_matrix_interpretation")), + ignore_missing_(ParameterManager::getBool("netcdf_ignore_missing_value")) { @@ -111,6 +112,7 @@ void NetcdfInterpretorAttributes::set(const std::map& params) setAttribute(prefix, "netcdf_y_auxiliary_variable", aux_y_, params); setAttribute(prefix, "netcdf_matrix_primary_index", primary_index_, params); setAttribute(prefix, "netcdf_matrix_interpretation", interpretation_, params); + setAttribute(prefix, "netcdf_ignore_missing_value", ignore_missing_, params); } @@ -151,6 +153,7 @@ void NetcdfInterpretorAttributes::copy(const NetcdfInterpretorAttributes& other) aux_y_ = other.aux_y_; primary_index_ = other.primary_index_; interpretation_ = other.interpretation_; + ignore_missing_ = other.ignore_missing_; } @@ -223,6 +226,7 @@ void NetcdfInterpretorAttributes::print(ostream& out) const out << " aux_y = " << aux_y_; out << " primary_index = " << primary_index_; out << " interpretation = " << interpretation_; + out << " ignore_missing = " << ignore_missing_; out << "]" << "\n"; } @@ -298,6 +302,8 @@ void NetcdfInterpretorAttributes::toxml(ostream& out) const niceprint(out,primary_index_); out << ", \"netcdf_matrix_interpretation\":"; niceprint(out,interpretation_); + out << ", \"netcdf_ignore_missing_value\":"; + niceprint(out,ignore_missing_); } @@ -335,3 +341,4 @@ static MagicsParameter netcdf_y_geoline_convention("netcdf_y_geoline_con static MagicsParameter netcdf_y_auxiliary_variable("netcdf_y_auxiliary_variable", ""); static MagicsParameter netcdf_matrix_primary_index("netcdf_matrix_primary_index", "longitude"); static MagicsParameter netcdf_matrix_interpretation("netcdf_matrix_interpretation", "automatic"); +static MagicsParameter netcdf_ignore_missing_value("netcdf_ignore_missing_value", "off"); diff --git a/src/attributes/NetcdfInterpretorAttributes.h b/src/attributes/NetcdfInterpretorAttributes.h index 328183968..b8a1e9262 100644 --- a/src/attributes/NetcdfInterpretorAttributes.h +++ b/src/attributes/NetcdfInterpretorAttributes.h @@ -84,6 +84,7 @@ class NetcdfInterpretorAttributes string aux_y_; string primary_index_; string interpretation_; + bool ignore_missing_; private: diff --git a/src/attributes/NetcdfInterpretorWrapper.cc b/src/attributes/NetcdfInterpretorWrapper.cc index e3a824497..a604c257a 100644 --- a/src/attributes/NetcdfInterpretorWrapper.cc +++ b/src/attributes/NetcdfInterpretorWrapper.cc @@ -194,6 +194,12 @@ void NetcdfInterpretorWrapper::set(const MagRequest& request) string interpretation_value = request("NETCDF_MATRIX_INTERPRETATION"); netcdfinterpretor_->interpretation_ = interpretation_value; } + if (request.countValues("NETCDF_IGNORE_MISSING_VALUE") ) { + string ignore_missing_value = request("NETCDF_IGNORE_MISSING_VALUE"); + + netcdfinterpretor_->ignore_missing_ = MagTranslator()(ignore_missing_value); + + } } diff --git a/src/attributes/ObsPlottingAttributes.cc b/src/attributes/ObsPlottingAttributes.cc index 5dea86ef3..70c0a50d3 100644 --- a/src/attributes/ObsPlottingAttributes.cc +++ b/src/attributes/ObsPlottingAttributes.cc @@ -29,6 +29,7 @@ ObsPlottingAttributes::ObsPlottingAttributes(): size_(ParameterManager::getDouble("obs_size")), ring_size_(ParameterManager::getDouble("obs_ring_size")), present_ww_visible_(ParameterManager::getBool("obs_present_weather")), + present_ww_colour_(ParameterManager::getString("obs_present_weather_colour")), pressure_visible_(ParameterManager::getBool("obs_pressure")), upper_air_visible_(ParameterManager::getBool("obs_upper_air_pressure")), pressure_tendency_visible_(ParameterManager::getBool("obs_pressure_tendency")), @@ -48,10 +49,11 @@ ObsPlottingAttributes::ObsPlottingAttributes(): time_plot_visible_(ParameterManager::getBool("obs_time")), visibility_visible_(ParameterManager::getBool("obs_visibility")), wind_visible_(ParameterManager::getBool("obs_wind")), + wind_colour_(ParameterManager::getString("obs_wind_colour")), + wind_thickness_(ParameterManager::getInt("obs_wind_thickness")), wind_projected_(ParameterManager::getBool("obs_wind_projected")) , colour_(MagTranslator().magics("obs_colour")), - present_ww_colour_(MagTranslator().magics("obs_present_weather_colour")), pressure_colour_(MagTranslator().magics("obs_pressure_colour")), upper_air_colour_(MagTranslator().magics("obs_upper_air_pressure_colour")), pressure_tendency_colour_(MagTranslator().magics("obs_pressure_tendency_colour")), @@ -68,8 +70,7 @@ ObsPlottingAttributes::ObsPlottingAttributes(): waves_colour_(MagTranslator().magics("obs_waves_colour")), past_ww_colour_(MagTranslator().magics("obs_past_weather_colour")), time_plot_colour_(MagTranslator().magics("obs_time_colour")), - visibility_colour_(MagTranslator().magics("obs_visibility_colour")), - wind_colour_(MagTranslator().magics("obs_wind_colour")) + visibility_colour_(MagTranslator().magics("obs_visibility_colour")) { } @@ -91,6 +92,7 @@ void ObsPlottingAttributes::set(const std::map& params) setAttribute(prefix, "obs_size", size_, params); setAttribute(prefix, "obs_ring_size", ring_size_, params); setAttribute(prefix, "obs_present_weather", present_ww_visible_, params); + setAttribute(prefix, "obs_present_weather_colour", present_ww_colour_, params); setAttribute(prefix, "obs_pressure", pressure_visible_, params); setAttribute(prefix, "obs_upper_air_pressure", upper_air_visible_, params); setAttribute(prefix, "obs_pressure_tendency", pressure_tendency_visible_, params); @@ -110,10 +112,11 @@ void ObsPlottingAttributes::set(const std::map& params) setAttribute(prefix, "obs_time", time_plot_visible_, params); setAttribute(prefix, "obs_visibility", visibility_visible_, params); setAttribute(prefix, "obs_wind", wind_visible_, params); + setAttribute(prefix, "obs_wind_colour", wind_colour_, params); + setAttribute(prefix, "obs_wind_thickness", wind_thickness_, params); setAttribute(prefix, "obs_wind_projected", wind_projected_, params); setMember(prefix, "obs_colour", colour_, params); - setMember(prefix, "obs_present_weather_colour", present_ww_colour_, params); setMember(prefix, "obs_pressure_colour", pressure_colour_, params); setMember(prefix, "obs_upper_air_pressure_colour", upper_air_colour_, params); setMember(prefix, "obs_pressure_tendency_colour", pressure_tendency_colour_, params); @@ -131,7 +134,6 @@ void ObsPlottingAttributes::set(const std::map& params) setMember(prefix, "obs_past_weather_colour", past_ww_colour_, params); setMember(prefix, "obs_time_colour", time_plot_colour_, params); setMember(prefix, "obs_visibility_colour", visibility_colour_, params); - setMember(prefix, "obs_wind_colour", wind_colour_, params); } @@ -141,6 +143,7 @@ void ObsPlottingAttributes::copy(const ObsPlottingAttributes& other) size_ = other.size_; ring_size_ = other.ring_size_; present_ww_visible_ = other.present_ww_visible_; + present_ww_colour_ = other.present_ww_colour_; pressure_visible_ = other.pressure_visible_; upper_air_visible_ = other.upper_air_visible_; pressure_tendency_visible_ = other.pressure_tendency_visible_; @@ -160,9 +163,10 @@ void ObsPlottingAttributes::copy(const ObsPlottingAttributes& other) time_plot_visible_ = other.time_plot_visible_; visibility_visible_ = other.visibility_visible_; wind_visible_ = other.wind_visible_; + wind_colour_ = other.wind_colour_; + wind_thickness_ = other.wind_thickness_; wind_projected_ = other.wind_projected_; colour_ = unique_ptr(other.colour_->clone()); - present_ww_colour_ = unique_ptr(other.present_ww_colour_->clone()); pressure_colour_ = unique_ptr(other.pressure_colour_->clone()); upper_air_colour_ = unique_ptr(other.upper_air_colour_->clone()); pressure_tendency_colour_ = unique_ptr(other.pressure_tendency_colour_->clone()); @@ -180,7 +184,6 @@ void ObsPlottingAttributes::copy(const ObsPlottingAttributes& other) past_ww_colour_ = unique_ptr(other.past_ww_colour_->clone()); time_plot_colour_ = unique_ptr(other.time_plot_colour_->clone()); visibility_colour_ = unique_ptr(other.visibility_colour_->clone()); - wind_colour_ = unique_ptr(other.wind_colour_->clone()); } @@ -223,6 +226,7 @@ void ObsPlottingAttributes::print(ostream& out) const out << " size = " << size_; out << " ring_size = " << ring_size_; out << " present_ww_visible = " << present_ww_visible_; + out << " present_ww_colour = " << present_ww_colour_; out << " pressure_visible = " << pressure_visible_; out << " upper_air_visible = " << upper_air_visible_; out << " pressure_tendency_visible = " << pressure_tendency_visible_; @@ -242,9 +246,10 @@ void ObsPlottingAttributes::print(ostream& out) const out << " time_plot_visible = " << time_plot_visible_; out << " visibility_visible = " << visibility_visible_; out << " wind_visible = " << wind_visible_; + out << " wind_colour = " << wind_colour_; + out << " wind_thickness = " << wind_thickness_; out << " wind_projected = " << wind_projected_; out << " colour = " << *colour_; - out << " present_ww_colour = " << *present_ww_colour_; out << " pressure_colour = " << *pressure_colour_; out << " upper_air_colour = " << *upper_air_colour_; out << " pressure_tendency_colour = " << *pressure_tendency_colour_; @@ -262,7 +267,6 @@ void ObsPlottingAttributes::print(ostream& out) const out << " past_ww_colour = " << *past_ww_colour_; out << " time_plot_colour = " << *time_plot_colour_; out << " visibility_colour = " << *visibility_colour_; - out << " wind_colour = " << *wind_colour_; out << "]" << "\n"; } @@ -278,6 +282,8 @@ void ObsPlottingAttributes::toxml(ostream& out) const niceprint(out,ring_size_); out << ", \"obs_present_weather\":"; niceprint(out,present_ww_visible_); + out << ", \"obs_present_weather_colour\":"; + niceprint(out,present_ww_colour_); out << ", \"obs_pressure\":"; niceprint(out,pressure_visible_); out << ", \"obs_upper_air_pressure\":"; @@ -316,12 +322,14 @@ void ObsPlottingAttributes::toxml(ostream& out) const niceprint(out,visibility_visible_); out << ", \"obs_wind\":"; niceprint(out,wind_visible_); + out << ", \"obs_wind_colour\":"; + niceprint(out,wind_colour_); + out << ", \"obs_wind_thickness\":"; + niceprint(out,wind_thickness_); out << ", \"obs_wind_projected\":"; niceprint(out,wind_projected_); out << ", \"obs_colour\":"; niceprint(out, *colour_); - out << ", \"obs_present_weather_colour\":"; - niceprint(out, *present_ww_colour_); out << ", \"obs_pressure_colour\":"; niceprint(out, *pressure_colour_); out << ", \"obs_upper_air_pressure_colour\":"; @@ -356,8 +364,6 @@ void ObsPlottingAttributes::toxml(ostream& out) const niceprint(out, *time_plot_colour_); out << ", \"obs_visibility_colour\":"; niceprint(out, *visibility_colour_); - out << ", \"obs_wind_colour\":"; - niceprint(out, *wind_colour_); } @@ -365,6 +371,7 @@ static MagicsParameter obs_distance_apart("obs_distance_apart", 1.0); static MagicsParameter obs_size("obs_size", 0.25); static MagicsParameter obs_ring_size("obs_ring_size", -1); static MagicsParameter obs_present_weather("obs_present_weather", "on"); +static MagicsParameter obs_present_weather_colour("obs_present_weather_colour", "automatic"); static MagicsParameter obs_pressure("obs_pressure", "on"); static MagicsParameter obs_upper_air_pressure("obs_upper_air_pressure", "off"); static MagicsParameter obs_pressure_tendency("obs_pressure_tendency", "on"); @@ -384,9 +391,10 @@ static MagicsParameter obs_past_weather("obs_past_weather", "on"); static MagicsParameter obs_time("obs_time", "off"); static MagicsParameter obs_visibility("obs_visibility", "on"); static MagicsParameter obs_wind("obs_wind", "on"); +static MagicsParameter obs_wind_colour("obs_wind_colour", "automatic"); +static MagicsParameter obs_wind_thickness("obs_wind_thickness", 1); static MagicsParameter obs_wind_projected("obs_wind_projected", "on"); static MagicsParameter obs_colour("obs_colour", "black"); -static MagicsParameter obs_present_weather_colour("obs_present_weather_colour", "automatic"); static MagicsParameter obs_pressure_colour("obs_pressure_colour", "automatic"); static MagicsParameter obs_upper_air_pressure_colour("obs_upper_air_pressure_colour", "automatic"); static MagicsParameter obs_pressure_tendency_colour("obs_pressure_tendency_colour", "red"); @@ -404,4 +412,3 @@ static MagicsParameter obs_waves_colour("obs_waves_colour", "black"); static MagicsParameter obs_past_weather_colour("obs_past_weather_colour", "red"); static MagicsParameter obs_time_colour("obs_time_colour", "automatic"); static MagicsParameter obs_visibility_colour("obs_visibility_colour", "automatic"); -static MagicsParameter obs_wind_colour("obs_wind_colour", "automatic"); diff --git a/src/attributes/ObsPlottingAttributes.h b/src/attributes/ObsPlottingAttributes.h index 34fe6b67e..154c0afbc 100644 --- a/src/attributes/ObsPlottingAttributes.h +++ b/src/attributes/ObsPlottingAttributes.h @@ -55,6 +55,7 @@ class ObsPlottingAttributes double size_; double ring_size_; bool present_ww_visible_; + string present_ww_colour_; bool pressure_visible_; bool upper_air_visible_; bool pressure_tendency_visible_; @@ -74,9 +75,10 @@ class ObsPlottingAttributes bool time_plot_visible_; bool visibility_visible_; bool wind_visible_; + string wind_colour_; + int wind_thickness_; bool wind_projected_; unique_ptr colour_; - unique_ptr present_ww_colour_; unique_ptr pressure_colour_; unique_ptr upper_air_colour_; unique_ptr pressure_tendency_colour_; @@ -94,7 +96,6 @@ class ObsPlottingAttributes unique_ptr past_ww_colour_; unique_ptr time_plot_colour_; unique_ptr visibility_colour_; - unique_ptr wind_colour_; private: diff --git a/src/attributes/ObsPlottingWrapper.cc b/src/attributes/ObsPlottingWrapper.cc index dad253bac..5b712d310 100644 --- a/src/attributes/ObsPlottingWrapper.cc +++ b/src/attributes/ObsPlottingWrapper.cc @@ -72,6 +72,10 @@ void ObsPlottingWrapper::set(const MagRequest& request) obsplotting_->present_ww_visible_ = MagTranslator()(present_ww_visible_value); + } + if (request.countValues("OBS_PRESENT_WEATHER_COLOUR") ) { + string present_ww_colour_value = request("OBS_PRESENT_WEATHER_COLOUR"); + obsplotting_->present_ww_colour_ = present_ww_colour_value; } if (request.countValues("OBS_PRESSURE") ) { string pressure_visible_value = request("OBS_PRESSURE"); @@ -186,6 +190,14 @@ void ObsPlottingWrapper::set(const MagRequest& request) obsplotting_->wind_visible_ = MagTranslator()(wind_visible_value); + } + if (request.countValues("OBS_WIND_COLOUR") ) { + string wind_colour_value = request("OBS_WIND_COLOUR"); + obsplotting_->wind_colour_ = wind_colour_value; + } + if (request.countValues("OBS_WIND_THICKNESS") ) { + int wind_thickness_value = request("OBS_WIND_THICKNESS"); + obsplotting_->wind_thickness_ = wind_thickness_value; } if (request.countValues("OBS_WIND_PROJECTED") ) { string wind_projected_value = request("OBS_WIND_PROJECTED"); @@ -199,11 +211,6 @@ void ObsPlottingWrapper::set(const MagRequest& request) obsplotting_->colour_ = unique_ptr(MagTranslator()(colour_value)); } - if (request.countValues("OBS_PRESENT_WEATHER_COLOUR") ) { - string present_ww_colour_value = request("OBS_PRESENT_WEATHER_COLOUR"); - obsplotting_->present_ww_colour_ = unique_ptr(MagTranslator()(present_ww_colour_value)); - } - if (request.countValues("OBS_PRESSURE_COLOUR") ) { string pressure_colour_value = request("OBS_PRESSURE_COLOUR"); obsplotting_->pressure_colour_ = unique_ptr(MagTranslator()(pressure_colour_value)); @@ -289,11 +296,6 @@ void ObsPlottingWrapper::set(const MagRequest& request) obsplotting_->visibility_colour_ = unique_ptr(MagTranslator()(visibility_colour_value)); } - if (request.countValues("OBS_WIND_COLOUR") ) { - string wind_colour_value = request("OBS_WIND_COLOUR"); - obsplotting_->wind_colour_ = unique_ptr(MagTranslator()(wind_colour_value)); - } - } @@ -319,7 +321,5 @@ void ObsPlottingWrapper::print(ostream& out) const - - diff --git a/src/attributes/SymbolPlottingAttributes.cc b/src/attributes/SymbolPlottingAttributes.cc index 151edc3d1..72b0c0f68 100644 --- a/src/attributes/SymbolPlottingAttributes.cc +++ b/src/attributes/SymbolPlottingAttributes.cc @@ -26,9 +26,7 @@ using namespace magics; SymbolPlottingAttributes::SymbolPlottingAttributes(): legend_(ParameterManager::getBool("legend")), - scaling_method_(ParameterManager::getBool("symbol_scaling_method")), - scaling_level_0_(ParameterManager::getDouble("symbol_scaling_level_0_height")), - scaling_factor_(ParameterManager::getDouble("symbol_scaling_factor")), + unit_method_(ParameterManager::getString("symbol_height_unit")), type_(ParameterManager::getString("symbol_type")), marker_mode_(ParameterManager::getString("symbol_marker_mode")), format_(ParameterManager::getString("symbol_format")), @@ -38,7 +36,20 @@ 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_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")), + 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")), @@ -63,9 +74,7 @@ void SymbolPlottingAttributes::set(const std::map& params) prefix[i++] = "symbol"; setAttribute(prefix, "legend", legend_, params); - setAttribute(prefix, "symbol_scaling_method", scaling_method_, params); - setAttribute(prefix, "symbol_scaling_level_0_height", scaling_level_0_, params); - setAttribute(prefix, "symbol_scaling_factor", scaling_factor_, params); + setAttribute(prefix, "symbol_height_unit", unit_method_, params); setAttribute(prefix, "symbol_type", type_, params); setAttribute(prefix, "symbol_marker_mode", marker_mode_, params); setAttribute(prefix, "symbol_format", format_, params); @@ -76,6 +85,19 @@ 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_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); + 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); @@ -88,9 +110,7 @@ void SymbolPlottingAttributes::set(const std::map& params) void SymbolPlottingAttributes::copy(const SymbolPlottingAttributes& other) { legend_ = other.legend_; - scaling_method_ = other.scaling_method_; - scaling_level_0_ = other.scaling_level_0_; - scaling_factor_ = other.scaling_factor_; + unit_method_ = other.unit_method_; type_ = other.type_; marker_mode_ = other.marker_mode_; format_ = other.format_; @@ -101,6 +121,19 @@ void SymbolPlottingAttributes::copy(const SymbolPlottingAttributes& other) automatic_connect_colour_ = other.automatic_connect_colour_; connect_thickness_ = other.connect_thickness_; legend_only_ = other.legend_only_; + 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_; + 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_; @@ -149,9 +182,7 @@ void SymbolPlottingAttributes::print(ostream& out) const { out << "Attributes["; out << " legend = " << legend_; - out << " scaling_method = " << scaling_method_; - out << " scaling_level_0 = " << scaling_level_0_; - out << " scaling_factor = " << scaling_factor_; + out << " unit_method = " << unit_method_; out << " type = " << type_; out << " marker_mode = " << marker_mode_; out << " format = " << format_; @@ -162,6 +193,19 @@ 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_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_; + 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_; @@ -176,12 +220,8 @@ void SymbolPlottingAttributes::toxml(ostream& out) const out << "\"symbol\""; out << ", \"legend\":"; niceprint(out,legend_); - out << ", \"symbol_scaling_method\":"; - niceprint(out,scaling_method_); - out << ", \"symbol_scaling_level_0_height\":"; - niceprint(out,scaling_level_0_); - out << ", \"symbol_scaling_factor\":"; - niceprint(out,scaling_factor_); + out << ", \"symbol_height_unit\":"; + niceprint(out,unit_method_); out << ", \"symbol_type\":"; niceprint(out,type_); out << ", \"symbol_marker_mode\":"; @@ -202,6 +242,32 @@ void SymbolPlottingAttributes::toxml(ostream& out) const niceprint(out,connect_thickness_); out << ", \"symbol_legend_only\":"; niceprint(out,legend_only_); + 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\":"; + 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\":"; @@ -216,9 +282,7 @@ void SymbolPlottingAttributes::toxml(ostream& out) const } static MagicsParameter legend("legend", "off"); -static MagicsParameter symbol_scaling_method("symbol_scaling_method", "off"); -static MagicsParameter symbol_scaling_level_0_height("symbol_scaling_level_0_height", 0.1); -static MagicsParameter symbol_scaling_factor("symbol_scaling_factor", 4.); +static MagicsParameter symbol_height_unit("symbol_height_unit", "cm"); static MagicsParameter symbol_type("symbol_type", "number"); static MagicsParameter symbol_marker_mode("symbol_marker_mode", "index"); static MagicsParameter symbol_format("symbol_format", "(automatic)"); @@ -229,6 +293,19 @@ 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_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", ""); +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 72ca920a5..d41a04925 100644 --- a/src/attributes/SymbolPlottingAttributes.h +++ b/src/attributes/SymbolPlottingAttributes.h @@ -53,9 +53,7 @@ class SymbolPlottingAttributes // -- members: string tag_; bool legend_; - bool scaling_method_; - double scaling_level_0_; - double scaling_factor_; + string unit_method_; string type_; string marker_mode_; string format_; @@ -66,6 +64,19 @@ class SymbolPlottingAttributes bool automatic_connect_colour_; int connect_thickness_; bool legend_only_; + 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_; + 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 a490b0cd0..bdd416614 100644 --- a/src/attributes/SymbolPlottingWrapper.cc +++ b/src/attributes/SymbolPlottingWrapper.cc @@ -61,19 +61,9 @@ void SymbolPlottingWrapper::set(const MagRequest& request) symbolplotting_->legend_ = MagTranslator()(legend_value); } - if (request.countValues("SYMBOL_SCALING_METHOD") ) { - string scaling_method_value = request("SYMBOL_SCALING_METHOD"); - - symbolplotting_->scaling_method_ = MagTranslator()(scaling_method_value); - - } - if (request.countValues("SYMBOL_SCALING_LEVEL_0_HEIGHT") ) { - double scaling_level_0_value = request("SYMBOL_SCALING_LEVEL_0_HEIGHT"); - symbolplotting_->scaling_level_0_ = scaling_level_0_value; - } - if (request.countValues("SYMBOL_SCALING_FACTOR") ) { - double scaling_factor_value = request("SYMBOL_SCALING_FACTOR"); - symbolplotting_->scaling_factor_ = scaling_factor_value; + if (request.countValues("SYMBOL_HEIGHT_UNIT") ) { + string unit_method_value = request("SYMBOL_HEIGHT_UNIT"); + symbolplotting_->unit_method_ = unit_method_value; } if (request.countValues("SYMBOL_TYPE") ) { string type_value = request("SYMBOL_TYPE"); @@ -125,6 +115,62 @@ void SymbolPlottingWrapper::set(const MagRequest& request) symbolplotting_->legend_only_ = MagTranslator()(legend_only_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; + } + 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/attributes/TextVisitorAttributes.cc b/src/attributes/TextVisitorAttributes.cc index e1f7aed7c..6cf849b23 100644 --- a/src/attributes/TextVisitorAttributes.cc +++ b/src/attributes/TextVisitorAttributes.cc @@ -277,6 +277,8 @@ bool TextVisitorAttributes::accept(const string& node) if ( magCompare(node, "text") ) return true; + if ( magCompare(node, "ztext") ) + return true; return false; } @@ -290,6 +292,8 @@ void TextVisitorAttributes::set(const XmlNode& node) if ( magCompare(node.name(), "text") ) apply = true; + if ( magCompare(node.name(), "ztext") ) + apply = true; if ( apply ) diff --git a/src/attributes/TileDecoderAttributes.cc b/src/attributes/TileDecoderAttributes.cc index 6bde01aec..32b32c292 100644 --- a/src/attributes/TileDecoderAttributes.cc +++ b/src/attributes/TileDecoderAttributes.cc @@ -27,6 +27,7 @@ using namespace magics; TileDecoderAttributes::TileDecoderAttributes(): file_name_(ParameterManager::getString("grib_input_file_name")), projection_(ParameterManager::getString("grib_tile_projection")), + mode_(ParameterManager::getString("grib_tile_mode")), loop_(ParameterManager::getBool("grib_loop")), z_(ParameterManager::getInt("grib_tile_z")), x_(ParameterManager::getInt("grib_tile_x")), @@ -54,6 +55,7 @@ void TileDecoderAttributes::set(const std::map& params) setAttribute(prefix, "grib_input_file_name", file_name_, params); setAttribute(prefix, "grib_tile_projection", projection_, params); + setAttribute(prefix, "grib_tile_mode", mode_, params); setAttribute(prefix, "grib_loop", loop_, params); setAttribute(prefix, "grib_tile_z", z_, params); setAttribute(prefix, "grib_tile_x", x_, params); @@ -69,6 +71,7 @@ void TileDecoderAttributes::copy(const TileDecoderAttributes& other) { file_name_ = other.file_name_; projection_ = other.projection_; + mode_ = other.mode_; loop_ = other.loop_; z_ = other.z_; x_ = other.x_; @@ -116,6 +119,7 @@ void TileDecoderAttributes::print(ostream& out) const out << "Attributes["; out << " file_name = " << file_name_; out << " projection = " << projection_; + out << " mode = " << mode_; out << " loop = " << loop_; out << " z = " << z_; out << " x = " << x_; @@ -134,6 +138,8 @@ void TileDecoderAttributes::toxml(ostream& out) const niceprint(out,file_name_); out << ", \"grib_tile_projection\":"; niceprint(out,projection_); + out << ", \"grib_tile_mode\":"; + niceprint(out,mode_); out << ", \"grib_loop\":"; niceprint(out,loop_); out << ", \"grib_tile_z\":"; @@ -153,6 +159,7 @@ void TileDecoderAttributes::toxml(ostream& out) const static MagicsParameter grib_input_file_name("grib_input_file_name", ""); static MagicsParameter grib_tile_projection("grib_tile_projection", "cylindrical"); +static MagicsParameter grib_tile_mode("grib_tile_mode", "eccharts"); static MagicsParameter grib_loop("grib_loop", "off"); static MagicsParameter grib_tile_z("grib_tile_z", 1); static MagicsParameter grib_tile_x("grib_tile_x", 0); diff --git a/src/attributes/TileDecoderAttributes.h b/src/attributes/TileDecoderAttributes.h index 659a05d71..470ea181f 100644 --- a/src/attributes/TileDecoderAttributes.h +++ b/src/attributes/TileDecoderAttributes.h @@ -52,6 +52,7 @@ class TileDecoderAttributes string tag_; string file_name_; string projection_; + string mode_; bool loop_; int z_; int x_; diff --git a/src/attributes/TileDecoderWrapper.cc b/src/attributes/TileDecoderWrapper.cc index dbc9c0f4b..ddbcb42a4 100644 --- a/src/attributes/TileDecoderWrapper.cc +++ b/src/attributes/TileDecoderWrapper.cc @@ -63,6 +63,10 @@ void TileDecoderWrapper::set(const MagRequest& request) string projection_value = request("GRIB_TILE_PROJECTION"); tiledecoder_->projection_ = projection_value; } + if (request.countValues("GRIB_TILE_MODE") ) { + string mode_value = request("GRIB_TILE_MODE"); + tiledecoder_->mode_ = mode_value; + } if (request.countValues("GRIB_LOOP") ) { string loop_value = request("GRIB_LOOP"); diff --git a/src/attributes/WrepJSonAttributes.cc b/src/attributes/WrepJSonAttributes.cc index cdde96b59..61a3f4cfc 100644 --- a/src/attributes/WrepJSonAttributes.cc +++ b/src/attributes/WrepJSonAttributes.cc @@ -55,7 +55,8 @@ WrepJSonAttributes::WrepJSonAttributes(): profile_quantile_(ParameterManager::getString("wrepjson_profile_quantile")), hodograph_grid_(ParameterManager::getBool("wrepjson_hodograph_grid")), hodograph_tephi_(ParameterManager::getBool("wrepjson_hodograph_tephi")), - hodograph_member_(ParameterManager::getInt("wrepjson_hodograph_member")) + hodograph_member_(ParameterManager::getInt("wrepjson_hodograph_member")), + y_axis_value_(ParameterManager::getDouble("wrepjson_y_axis_value")) { @@ -105,6 +106,7 @@ void WrepJSonAttributes::set(const std::map& params) setAttribute(prefix, "wrepjson_hodograph_grid", hodograph_grid_, params); setAttribute(prefix, "wrepjson_hodograph_tephi", hodograph_tephi_, params); setAttribute(prefix, "wrepjson_hodograph_member", hodograph_member_, params); + setAttribute(prefix, "wrepjson_y_axis_value", y_axis_value_, params); } @@ -142,6 +144,7 @@ void WrepJSonAttributes::copy(const WrepJSonAttributes& other) hodograph_grid_ = other.hodograph_grid_; hodograph_tephi_ = other.hodograph_tephi_; hodograph_member_ = other.hodograph_member_; + y_axis_value_ = other.y_axis_value_; } @@ -211,6 +214,7 @@ void WrepJSonAttributes::print(ostream& out) const out << " hodograph_grid = " << hodograph_grid_; out << " hodograph_tephi = " << hodograph_tephi_; out << " hodograph_member = " << hodograph_member_; + out << " y_axis_value = " << y_axis_value_; out << "]" << "\n"; } @@ -280,6 +284,8 @@ void WrepJSonAttributes::toxml(ostream& out) const niceprint(out,hodograph_tephi_); out << ", \"wrepjson_hodograph_member\":"; niceprint(out,hodograph_member_); + out << ", \"wrepjson_y_axis_value\":"; + niceprint(out,y_axis_value_); } @@ -314,3 +320,4 @@ static MagicsParameter wrepjson_profile_quantile("wrepjson_profile_quant static MagicsParameter wrepjson_hodograph_grid("wrepjson_hodograph_grid", "off"); static MagicsParameter wrepjson_hodograph_tephi("wrepjson_hodograph_tephi", "off"); static MagicsParameter wrepjson_hodograph_member("wrepjson_hodograph_member", -1); +static MagicsParameter wrepjson_y_axis_value("wrepjson_y_axis_value", 1); diff --git a/src/attributes/WrepJSonAttributes.h b/src/attributes/WrepJSonAttributes.h index 5dbe6af44..67bb40d2b 100644 --- a/src/attributes/WrepJSonAttributes.h +++ b/src/attributes/WrepJSonAttributes.h @@ -81,6 +81,7 @@ class WrepJSonAttributes bool hodograph_grid_; bool hodograph_tephi_; int hodograph_member_; + double y_axis_value_; private: diff --git a/src/attributes/WrepJSonWrapper.cc b/src/attributes/WrepJSonWrapper.cc index fa43cdf3c..32d5f05c0 100644 --- a/src/attributes/WrepJSonWrapper.cc +++ b/src/attributes/WrepJSonWrapper.cc @@ -193,6 +193,10 @@ void WrepJSonWrapper::set(const MagRequest& request) int hodograph_member_value = request("WREPJSON_HODOGRAPH_MEMBER"); wrepjson_->hodograph_member_ = hodograph_member_value; } + if (request.countValues("WREPJSON_Y_AXIS_VALUE") ) { + double y_axis_value_value = request("WREPJSON_Y_AXIS_VALUE"); + wrepjson_->y_axis_value_ = y_axis_value_value; + } } diff --git a/src/basic/FortranMagics.cc b/src/basic/FortranMagics.cc index 7f8a00041..bf0ea4110 100644 --- a/src/basic/FortranMagics.cc +++ b/src/basic/FortranMagics.cc @@ -102,9 +102,11 @@ void FortranMagics::reset() { empty_ = true; gribindex_ = 0; legend_todo_ = false; + symbolinput_todo_ = false; matrixinput_todo_ = false; polyinput_todo_ = false; + obsinput_todo_ = false; while (actions_.size()) { @@ -429,19 +431,26 @@ void FortranMagics::ptephi() { } void FortranMagics::pobs() { actions(); - action_ = new VisualAction(); - ObsDecoder* obs = new ObsDecoder(); - if (obs->defined()) { - action_->data(obs); - top()->push_back(action_); - action_->visdef(new ObsPlotting()); - return; + + if (!action_ || obsinput_todo_ ) { + action_ = new VisualAction(); + ObsDecoder* obs = new ObsDecoder(); + if (obs->defined()) { + action_->data(obs); + top()->push_back(action_); + + } + else { + action_ = new VisualAction(); + action_->data(new ObsJSon()); + top()->push_back(action_); + } } action_ = new VisualAction(); action_->data(new ObsJSon()); top()->push_back(action_); action_->visdef(new ObsPlotting()); - return; + } #include "MatrixTestDecoder.h" diff --git a/src/basic/FortranMagics.h b/src/basic/FortranMagics.h index ae4ef9435..cd9179e14 100644 --- a/src/basic/FortranMagics.h +++ b/src/basic/FortranMagics.h @@ -151,6 +151,7 @@ class FortranMagics : public std::stack { bool symbolinput_todo_; bool matrixinput_todo_; bool polyinput_todo_; + bool obsinput_todo_; private: FortranMagics(); diff --git a/src/basic/LegendVisitor.cc b/src/basic/LegendVisitor.cc index 21794b07b..96984d914 100644 --- a/src/basic/LegendVisitor.cc +++ b/src/basic/LegendVisitor.cc @@ -186,6 +186,9 @@ void DoubleLineEntry::columnBox(const PaperPoint& point, BasicGraphicsObjectCont void LegendVisitor::build() { legend_ = new LegendLayout(); + LegendVisitor::legendEntriesInfo_.clear(); + LegendVisitor::legendInfo_.clear(); + legend_->x(view_x_); legend_->y(view_y_); legend_->width(view_width_); @@ -204,7 +207,8 @@ void LegendVisitor::build() { vector::const_iterator position = positions_.begin(); if (title_) { Text* legend = new Text(); - MagFont font; + MagFont font(font_); + double font_size = (title_font_size_ == -1) ? font_size_ : title_font_size_; font.size(font_size); Colour colour = title_font_colour_->automatic() ? *colour_ : *title_font_colour_; @@ -278,6 +282,7 @@ void LegendVisitor::build() { continue; legendEntriesInfo_.push_back(map()); + (magCompare(direction_, "column")) ? (*method_).column(*entry, position->x(), position->y(), *legend, *legend_) : (*method_).row(*entry, position->x(), position->y(), *legend, *legend_); diff --git a/src/basic/XmlMagics.cc b/src/basic/XmlMagics.cc index 9a452df56..1b1263d69 100644 --- a/src/basic/XmlMagics.cc +++ b/src/basic/XmlMagics.cc @@ -73,6 +73,7 @@ XmlMagics::XmlMagics() : root_(0), gribloop_(0), geographical_(true), driversToS actions_["mgb"] = &XmlMagics::binary; actions_["text"] = &XmlMagics::text; + actions_["ztext"] = &XmlMagics::text; actions_["map"] = &XmlMagics::map; actions_["matrix"] = &XmlMagics::matrix; actions_["cartesian"] = &XmlMagics::cartesian; diff --git a/src/common/BaseParameter.cc b/src/common/BaseParameter.cc index 1f70d981b..deac8e3cf 100644 --- a/src/common/BaseParameter.cc +++ b/src/common/BaseParameter.cc @@ -72,6 +72,14 @@ void BaseParameter::set(const bool& value) { throw MistmatchType(name_, getType(value), type()); } +void BaseParameter::get(unsigned long long& value) const { + throw MistmatchType(name_, getType(value), type()); +} + +void BaseParameter::set(const unsigned long long& value) { + throw MistmatchType(name_, getType(value), type()); +} + void BaseParameter::get(bool& value) const { throw MistmatchType(name_, getType(value), type()); } @@ -308,6 +316,13 @@ void BaseParameter::get(Matrix& value) const { string BaseParameter::getType(const string&) const { return "string"; } +string BaseParameter::getType(const unsigned long long&) const { + return "unsigned long "; +} + +string BaseParameter::getType(const unsigned int&) const { + return "unsigned int "; +} string BaseParameter::getType(const int&) const { return "integer"; diff --git a/src/common/BaseParameter.h b/src/common/BaseParameter.h index f61320dc4..a58b6b2f7 100644 --- a/src/common/BaseParameter.h +++ b/src/common/BaseParameter.h @@ -65,6 +65,9 @@ class BaseParameter { virtual void set(const int&); virtual void get(int&) const; + virtual void set(const unsigned long long&); + virtual void get(unsigned long long&) const; + virtual void set(const magvector&); virtual void get(magvector&) const; @@ -104,6 +107,8 @@ class BaseParameter { string getType(const string&) const; string getType(const int&) const; + string getType(const unsigned long long&) const; + string getType(const unsigned int&) const; string getType(const double&) const; string getType(const magvector&) const; string getType(const magvector&) const; diff --git a/src/common/MagTranslator.h b/src/common/MagTranslator.h index a4d4ac47d..3faf61359 100644 --- a/src/common/MagTranslator.h +++ b/src/common/MagTranslator.h @@ -130,6 +130,29 @@ class MagTranslator { } }; +template <> +class MagTranslator { +public: + int operator()(const string& value) { return atoll(value.c_str()); } + int magics(const string& param) { + int from; + ParameterManager::get(param, from); + return from; + } +}; + + +template <> +class MagTranslator { +public: + int operator()(unsigned long long& value) { return value; } + int magics(const string& param) { + unsigned long long from; + ParameterManager::get(param, from); + return from; + } +}; + template <> class MagTranslator { public: diff --git a/src/common/ParameterManager.cc b/src/common/ParameterManager.cc index 606835e4b..823154372 100644 --- a/src/common/ParameterManager.cc +++ b/src/common/ParameterManager.cc @@ -103,6 +103,12 @@ int ParameterManager::getInt(const string& name) { ASSERT(get(name, value)); return value; } +unsigned long long ParameterManager::getULong(const string& name) { + unsigned long long value; + + ASSERT(get(name, value)); + return value; +} string ParameterManager::getString(const string& name) { string value; diff --git a/src/common/ParameterManager.h b/src/common/ParameterManager.h index c25056d59..c921d670f 100644 --- a/src/common/ParameterManager.h +++ b/src/common/ParameterManager.h @@ -45,6 +45,7 @@ class ParameterManager : public map { template static void set(const string& name, const T& value) { + ASSERT(table_); BaseParameter* param = (*table_).parameter(name); if (param) { @@ -80,6 +81,8 @@ class ParameterManager : public map { static double getDouble(const string& name); static int getInt(const string& name); + static int getUnsignedInt(const string& name); + static unsigned long long getULong(const string& name); static string getString(const string& name); static stringarray getStringArray(const string& name); diff --git a/src/common/Polyline.h b/src/common/Polyline.h index c4fccab62..d0c8797a5 100644 --- a/src/common/Polyline.h +++ b/src/common/Polyline.h @@ -280,6 +280,8 @@ class Polyline : public PolylineProperties { void push_front(Polyline&); void push_back(Polyline&); + void reverse() {std::reverse(polygon_.begin(), polygon_.end());} + // Is the pointincluded in the polyline" bool in(const PaperPoint&) const; diff --git a/src/common/Proj4Projection.cc b/src/common/Proj4Projection.cc index 5fe8a9174..abfbfadc0 100644 --- a/src/common/Proj4Projection.cc +++ b/src/common/Proj4Projection.cc @@ -1324,12 +1324,12 @@ double Proj4Projection::patchDistance(double res) const { double x1 = 0; double y1 = 60; double x2 = 0; - double y2 = 61; - fast_reproject(x1, y1); - fast_reproject(x2, y2); + double y2 = 60+res; - double degree = ((x1 - x2) * (x1 - x2)) + ((y1 - y2) * (y1 - y2)); - return 1000000000; + fast_reproject(y1, x1); + fast_reproject(y2, x2); + + return sqrt(((x1 - x2) * (x1 - x2)) + ((y1 - y2) * (y1 - y2))); } void Proj4Projection::collect(MetaDataCollector& collector) const { diff --git a/src/common/Proj4Projection.h b/src/common/Proj4Projection.h index de6d3cf31..76f4a69ab 100644 --- a/src/common/Proj4Projection.h +++ b/src/common/Proj4Projection.h @@ -387,12 +387,13 @@ class Proj4EPSG4326 : public Proj4Projection { class Proj4Automatic : public Proj4Projection { public: Proj4Automatic(); - void aspectRatio(double&, double&); + void aspectRatio(double&, double&) override; - void init(); + void init() override; - void setNewPCBox(double minx, double miny, double maxx, double maxy); + void setNewPCBox(double minx, double miny, + double maxx, double maxy) override; virtual void setExtend() override; diff --git a/src/common/Transformation.cc b/src/common/Transformation.cc index c8008c732..1577e8f14 100644 --- a/src/common/Transformation.cc +++ b/src/common/Transformation.cc @@ -322,7 +322,7 @@ void Transformation::operator()(const magics::Polyline& from, BasicGraphicsObjec } void Transformation::operator()(const magics::Polyline& from, vector& out) const { - ASSERT(false); + if (from.empty()) return; diff --git a/src/common/Transformation.h b/src/common/Transformation.h index 2ef59f1ae..34ab70fc4 100644 --- a/src/common/Transformation.h +++ b/src/common/Transformation.h @@ -188,7 +188,7 @@ class Transformation { virtual bool fast_reproject(double& x, double& y) const { return true; } - virtual double patchDistance(double) const { NOTIMP; } + virtual double patchDistance(double x) const { return x; } virtual PaperPoint operator()(const PaperPoint& xy) const { return xy; } virtual void operator()(const UserPoint& geo, Polyline& out) const; diff --git a/src/decoders/GribAddressMode.h b/src/decoders/GribAddressMode.h index a521a337a..8ca95e1a8 100644 --- a/src/decoders/GribAddressMode.h +++ b/src/decoders/GribAddressMode.h @@ -50,11 +50,11 @@ class GribAddressMode { virtual void toxml(ostream&, int = 0) const { MagLog::dev() << "GribAddressMode::toxml(ostream&, int = 0)---> to be checked!...\n"; } - virtual grib_handle* operator()(grib_context*, FILE*, int) const { - MagLog::dev() << "GribAddressMode::toxml(ostream&, int = 0)---> to be checked!...\n"; - return 0; - } - virtual grib_handle* operator()(grib_context*, FILE*, long int) const { + // virtual grib_handle* operator()(grib_context*, FILE*, int) const { + // MagLog::dev() << "GribAddressMode::toxml(ostream&, int = 0)---> to be checked!...\n"; + // return 0; + // } + virtual grib_handle* operator()(grib_context*, FILE*, unsigned long long) const { MagLog::dev() << "GribAddressMode::toxml(ostream&, int = 0)---> to be checked!...\n"; return 0; } @@ -87,13 +87,13 @@ class GribAddressRecordMode : public GribAddressMode { return mode; } - virtual grib_handle* operator()(grib_context*, FILE* file, int position) const override { + virtual grib_handle* operator()(grib_context*, FILE* file, unsigned long long position) const override { grib_handle* handle = 0; grib_context* context = grib_context_get_default(); int error; - for (int i = 0; i < position - 1; i++) { + for (auto i = 0; i < position - 1; i++) { // grib_read_any_from_file_alloc (context, file, &msg , &size); // grib_context_free(context,msg); // MagLog::debug() << "call to grib_handle_new_from_file for position " << i << "\n"; @@ -118,22 +118,28 @@ class GribAddressByteMode : public GribAddressMode { GribAddressMode* mode = new GribAddressByteMode(); return mode; } + #include - virtual grib_handle* operator()(grib_context* context, FILE* file, int position) const override { - // long int offset = (long int)position; - // cout << "OFFSET-->" << offset << endl; - fseek(file, (long int)position, SEEK_SET); - grib_handle* handle = 0; + // virtual grib_handle* operator()(grib_context* context, FILE* file, int position) const override { + // // long int offset = (long int)position; + // cout << "OFFSET-->" << position << endl; - int error; - handle = grib_handle_new_from_file(0, file, &error); + // fseek(file, (long int)position, SEEK_SET); + // grib_handle* handle = 0; - return handle; - } - virtual grib_handle* operator()(grib_context* context, FILE* file, long int position) const override { + // int error; + // handle = grib_handle_new_from_file(0, file, &error); + + // return handle; + // } + virtual grib_handle* operator()(grib_context* context, FILE* file, unsigned long long position) const override { + fseek(file, position, SEEK_SET); grib_handle* handle = 0; + + + int error; handle = grib_handle_new_from_file(0, file, &error); diff --git a/src/decoders/GribDecoder.cc b/src/decoders/GribDecoder.cc index 74d34e8f8..5ecabd94d 100644 --- a/src/decoders/GribDecoder.cc +++ b/src/decoders/GribDecoder.cc @@ -751,7 +751,7 @@ void GribDecoder::decode2D(const Transformation&) { } void GribDecoder::openField() { - current_position_ = field_position_; + field_ = open(field_); } @@ -762,13 +762,38 @@ void GribDecoder::openFirstComponent() { } void GribDecoder::openSecondComponent() { - current_position_ = position_2_; - component2_ = open(component2_); + MagLog::debug() << "received-> " << position_2_ << " from file " << second_file_name_ < " << current_position_ << " from file " << current_file_name_ < " << colour_position_ << " from file " << colour_file_name_ < " << current_position_ << " from file " << current_file_name_ < 0) { buf[count] = '\0'; setInfo("path", string(buf)); } else { - setInfo("path", file_name_); + setInfo("path", current_file_name_); } setInfo("MV_Format", "GRIB"); } diff --git a/src/decoders/GribDecoder.h b/src/decoders/GribDecoder.h index 74d4f378d..f818e73fd 100644 --- a/src/decoders/GribDecoder.h +++ b/src/decoders/GribDecoder.h @@ -275,7 +275,8 @@ class GribDecoder : public Decoder, public Data, public GribDecoderAttributes { bool directionDone_; mutable grib_handle* current_handle_; - mutable int current_position_; + mutable unsigned long long current_position_; + mutable string current_file_name_; string title_; static int count_; diff --git a/src/decoders/InputData.cc b/src/decoders/InputData.cc index f3c0b9927..ce6e7f7ec 100644 --- a/src/decoders/InputData.cc +++ b/src/decoders/InputData.cc @@ -303,6 +303,7 @@ void InputData::visit(Transformation& transformation) { if (magCompare(x_type_, "date")) { + transformation.setDataMinMaxX(minmax.first, minmax.second, baseDateX_); } else { diff --git a/src/decoders/NetcdfData.cc b/src/decoders/NetcdfData.cc index 5466f8fa5..f0157483a 100644 --- a/src/decoders/NetcdfData.cc +++ b/src/decoders/NetcdfData.cc @@ -404,6 +404,9 @@ double NetVariable::getDefaultMissing() { string Netcdf::detect(const string& var, const string& type, bool use_cache) const { + if ( std::find(ignoredDimensions_.begin(), ignoredDimensions_.end(), type) != ignoredDimensions_.end() ) + // Here we force to ignore the dimension type + return ""; if ( use_cache ) { auto cache = detected_.find(var); if ( cache != detected_.end() ) diff --git a/src/decoders/NetcdfData.h b/src/decoders/NetcdfData.h index 27f9abe3b..5a5beaabc 100644 --- a/src/decoders/NetcdfData.h +++ b/src/decoders/NetcdfData.h @@ -476,6 +476,8 @@ class Netcdf { } map getAttributes() { return attributes_; } + void ignoreDimension(const string& dim) { ignoredDimensions_.push_back(dim); } + void interpretDimension(const string&) { } //std::remove( ignoredDimensions_.begin(), ignoredDimensions_.end(), dim ); } protected: @@ -486,6 +488,7 @@ class Netcdf { map attributes_; double missing_; mutable map detected_; + vector ignoredDimensions_; private: int file_; diff --git a/src/decoders/NetcdfGeopointsInterpretor.cc b/src/decoders/NetcdfGeopointsInterpretor.cc index 96dac478d..abc0c0b28 100644 --- a/src/decoders/NetcdfGeopointsInterpretor.cc +++ b/src/decoders/NetcdfGeopointsInterpretor.cc @@ -64,7 +64,14 @@ bool NetcdfGeopointsInterpretor::interpretAsPoints(PointsList& list, const Trans netcdf.get(field_, values, first, last); setDim(netcdf, longitude_, longitudes, first, last); setDim(netcdf, latitude_, latitudes, first, last); + double missing = numeric_limits::max(); + if (field_.empty() == false) { + netcdf.get(field_, values, first, last); + missing = netcdf.getMissing(field_, missing_attribute_); + } + + vector::iterator lat = latitudes.begin(); vector::iterator lon = longitudes.begin(); vector::const_iterator val = values.begin(); @@ -89,8 +96,10 @@ bool NetcdfGeopointsInterpretor::interpretAsPoints(PointsList& list, const Trans lat = latitudes.begin(); lon = longitudes.begin(); while (lat != latitudes.end() && lon != longitudes.end() && val != values.end()) { - UserPoint* geo = new UserPoint(*lon, *lat, *val); - list.push_back(geo); + if ( !same(*val, missing) ) { + UserPoint* geo = new UserPoint(*lon, *lat, *val); + list.push_back(geo); + } lon++; lat++; val++; @@ -247,9 +256,11 @@ bool NetcdfXYpointsInterpretor::interpretAsPoints(PointsList& list, const Transf vector values; map first, last; setDimensions(dimension_, first, last); + double missing = numeric_limits::max(); if (field_.empty() == false) { netcdf.get(field_, values, first, last); + missing = netcdf.getMissing(field_, missing_attribute_); } setDim(netcdf, x_, xs, first, last); setDim(netcdf, y_, ys, first, last); @@ -257,6 +268,8 @@ bool NetcdfXYpointsInterpretor::interpretAsPoints(PointsList& list, const Transf double xmissing = netcdf.getMissing(x_, missing_attribute_); double ymissing = netcdf.getMissing(y_, missing_attribute_); + + vector::iterator x = xs.begin(); vector::iterator y = ys.begin(); vector::const_iterator val = values.begin(); @@ -267,7 +280,7 @@ bool NetcdfXYpointsInterpretor::interpretAsPoints(PointsList& list, const Transf value = *val; val++; } - if (!same(*x, xmissing) || !same(*y, ymissing)) { + if (!same(*x, xmissing) || !same(*y, ymissing) || same(value, missing)) { UserPoint* xy = new UserPoint(*x, *y, value); if (projection.in(*xy)) list.push_back(xy); @@ -301,24 +314,35 @@ bool NetcdfXYpointsInterpretor::interpretAsPoints(PointsList& list, const std::s vector values; map first, last; setDimensions(dimension_, first, last); + double missing = numeric_limits::max(); if (field_.empty() == false) { netcdf.get(field_, values, first, last); + missing = netcdf.getMissing(field_, missing_attribute_); } + + setDim(netcdf, x_, xs, first, last); setDim(netcdf, y_, ys, first, last); double xmissing = netcdf.getMissing(x_, missing_attribute_); double ymissing = netcdf.getMissing(y_, missing_attribute_); + + baseDateX_ = ""; if (!reference_date(netcdf, x_, refDateX_, baseDateX_, xs, datex)) cf_date(netcdf, x_, refDateX_, baseDateX_, xs, datex); vector::iterator y = ys.begin(); vector::iterator x = xs.begin(); + vector::const_iterator val = values.begin(); + + minDate_ = *std::min_element(xs.begin(), xs.end()); + maxDate_ = *std::max_element(xs.begin(), xs.end()); + while (x != xs.end() && y != ys.end()) { double value = 0; @@ -327,7 +351,7 @@ bool NetcdfXYpointsInterpretor::interpretAsPoints(PointsList& list, const std::s val++; } if (!same(*y, ymissing) || !same(*x, xmissing)) { - list.push_back(new UserPoint(*x, *y, value, (same(*y, ymissing) || same(*x, xmissing)))); + list.push_back(new UserPoint(*x, *y, value, (same(*y, ymissing) || same(*x, xmissing) || same(value, missing)))); } x++; @@ -380,10 +404,15 @@ void NetcdfXYpointsInterpretor::visit(Transformation& transformation) { if (transformation.getAutomaticX()) { if (!this->baseDateX_.empty()) { - transformation.setDataMinMaxX(points.minX(), points.maxX(), this->baseDateX_); + if ( ignore_missing_) + transformation.setDataMinMaxX(points.minX(), points.maxX(), this->baseDateX_); + else + transformation.setDataMinMaxX(minDate_, maxDate_, this->baseDateX_); } else { + + transformation.setMinMaxX(points.minX(), points.maxX()); } } diff --git a/src/decoders/NetcdfGeopointsInterpretor.h b/src/decoders/NetcdfGeopointsInterpretor.h index d5095f586..57a982e05 100644 --- a/src/decoders/NetcdfGeopointsInterpretor.h +++ b/src/decoders/NetcdfGeopointsInterpretor.h @@ -78,7 +78,7 @@ class NetcdfGeopointsInterpretor : public NetcdfInterpretor { return s; } }; -class NetcdfXYpointsInterpretor : public NetcdfInterpretor { +class NetcdfXYpointsInterpretor : public NetcdfInterpretor { public: NetcdfXYpointsInterpretor(); virtual ~NetcdfXYpointsInterpretor() override; @@ -117,6 +117,9 @@ class NetcdfXYpointsInterpretor : public NetcdfInterpretor { protected: //! Method to print string about this class on to a stream of type ostream (virtual). virtual void print(ostream&) const override; + // Specail case for date in x axis . + double minDate_; + double maxDate_; private: //! Copy constructor - No copy allowed diff --git a/src/decoders/NetcdfMatrixInterpretor.cc b/src/decoders/NetcdfMatrixInterpretor.cc index 84baea446..9446fb2cf 100644 --- a/src/decoders/NetcdfMatrixInterpretor.cc +++ b/src/decoders/NetcdfMatrixInterpretor.cc @@ -55,8 +55,10 @@ void NetcdfMatrixInterpretor::interpret(Netcdf& netcdf, vector& rows, ve x.precision(20); y.precision(20); + netcdf.ignoreDimension("time"); // here we send time as expressed in the data, not as a date. y << y_ << "/" << *r << "/" << *r; x << x_ << "/" << columns.front() << "/" << columns.back(); + netcdf.interpretDimension("time"); } std::copy(dimension_.begin(), dimension_.end(), std::back_inserter(dims)); dims.push_back(y.str()); diff --git a/src/decoders/ObsDecoder.cc b/src/decoders/ObsDecoder.cc index 7e17561d7..2d63fbd6a 100644 --- a/src/decoders/ObsDecoder.cc +++ b/src/decoders/ObsDecoder.cc @@ -194,7 +194,7 @@ BufrIdentifiers::BufrIdentifiers(int centre) : centre_(centre) { // Open the default template for 98! // and send a big warning! in = fopen(deffile.str().c_str(), "r"); - MagLog::warning() << "No definition file for [" << centre << "]: We use ECMWF definitions " << endl; + MagLog::warning() << "No local definition file for [" << centre << "]: We use ECMWF definitions " << endl; if (MagicsGlobal::strict()) { throw CannotOpenFile(deffile.str()); @@ -293,8 +293,6 @@ class BufrAccessor { BufrAccessor(const string& descriptor) : descriptor_(descriptor) { init(); auto token = translator_.find(descriptor_); - if (token == translator_.end()) - MagLog::warning() << "Could not find eccodes key for " << descriptor_ << endl; eccodes_ = (token == translator_.end()) ? descriptor_ : token->second; } virtual ~BufrAccessor(){}; @@ -461,7 +459,7 @@ class BufrMultiLevelAccessor : public BufrAccessor { void operator()(const ObsDecoder& decoder, MvObs& obs, double& val) const { const BufrIdentifiers& table = BufrIdentTable::get(obs.originatingCentre()); int type = obs.messageType(); - + map::const_iterator multilevel = multilevels_.find(type); if (multilevel == multilevels_.end()) { MagLog::warning() << "BufrMultiLevelAccessor> Unknown observation type [" << val << "]\n"; @@ -470,6 +468,10 @@ class BufrMultiLevelAccessor : public BufrAccessor { if (type == 0 || type == 1) { // surface data val = obs.value(surface_); + if ( val == kBufrMissingValue ) { + // Trying the descriptor for multilevel: some centres are using it for surface. + val = obs.value(altitude_); + } } else { // MagLog::dev()<< " look for --->" << table.ident(altitude_) << " at " << decoder.getLevel(); diff --git a/src/decoders/TileDecoder.cc b/src/decoders/TileDecoder.cc index 3cc62f1b7..9a455367b 100644 --- a/src/decoders/TileDecoder.cc +++ b/src/decoders/TileDecoder.cc @@ -49,10 +49,14 @@ string TileDecoder::projection() { string TileDecoder::weights() { ostringstream out; string parent = getEnvVariable("MAGPLUS_TILE"); + if (parent.empty()) { parent = buildSharePath("tiles"); } - out << parent << "/weight-" << grid_ << "-" << projection() << "-z" + tostring(z_) << ".nc"; + if (mode_ == "opencharts" ) + out << parent << "/opencharts-cache-" << grid_ << ".nc"; + else + out << parent << "/weight-" << grid_ << "-" << projection() << "-z" + tostring(z_) << ".nc"; return out.str(); } @@ -62,7 +66,11 @@ string TileDecoder::positions() { if (parent.empty()) { parent = buildSharePath("tiles"); } - out << parent << "/wind-" << grid_ << "-" << projection() << "-z" + tostring(z_) << ".nc"; + if (mode_ == "opencharts" ) + out << parent << "/opencharts-wind-" << grid_ << ".nc"; + + else + out << parent << "/wind-" << grid_ << "-" << projection() << "-z" + tostring(z_) << ".nc"; return out.str(); } @@ -73,7 +81,12 @@ string TileDecoder::positions_symbols() { if (parent.empty()) { parent = buildSharePath("tiles"); } - out << parent << "/symbol-" << grid_ << "-" << projection() << "-z" + tostring(z_) << ".nc"; + if (mode_ == "opencharts" ) { + out << parent << "/opencharts-symbol-" << grid_ << ".nc"; + } + + else + out << parent << "/symbol-" << grid_ << "-" << projection() << "-z" + tostring(z_) << ".nc"; file_ = ifstream(out.str()); if (file_.good()) { file_.close(); @@ -105,6 +118,20 @@ bool TileDecoder::ok() { grid_ = string(val); string path = weights(); + if (mode_ == "opencharts" ) { + try { + Netcdf netcdf(path, "index"); + map first, last; + static vector latitudes; + netcdf.get(projection_ + "_lat", latitudes, first, last); + return true; + } + catch(...) { + return false; + } + } + + file_ = ifstream(path); if (!file_.good()) { file_.close(); @@ -149,21 +176,32 @@ void TileDecoder::customisedPoints(const Transformation& transformation, const s CustomisedPointsList& out, bool all) { string path = positions(); Timer timer("Tile", path); - #ifdef HAVE_NETCDF Netcdf netcdf(path, "index"); - map first, last; - first["x"] = tostring(x_); - first["y"] = tostring(y_); - last["x"] = tostring(x_); - last["y"] = tostring(y_); - vector bbox; vector latitudes; vector longitudes; vector values; vector index; + map first, last; + + if ( mode_ == "opencharts") { + + // netcdf.get(projection_ + "_lat", latitudes, first, last); + // netcdf.get(projection_ + "_lon", longitudes, first, last); + netcdf.get(projection_ + "_index", values, first, last); + + } + else { + first["x"] = tostring(x_); + first["y"] = tostring(y_); + last["x"] = tostring(x_); + last["y"] = tostring(y_); + netcdf.get("index", values, first, last); + } + + int error; FILE* in = fopen(file_name_.c_str(), "rb"); @@ -188,9 +226,6 @@ void TileDecoder::customisedPoints(const Transformation& transformation, const s return; } - int nbpoints = netcdf.getDimension("points"); - // netcdf.get("bounding-box", bbox, first, last); - netcdf.get("index", values, first, last); for (auto b = values.begin(); b != values.end(); ++b) { double lat = *b; @@ -200,15 +235,16 @@ void TileDecoder::customisedPoints(const Transformation& transformation, const s double i = *b; if (i != 0) { - if (lon > 180) - lon -= 360; + if ( mode_ != "opencharts") { + if (lon > 180) + lon -= 360; + } latitudes.push_back(lat); longitudes.push_back(lon); index.push_back(i); } } - { vector uc; uc.reserve(index.size()); @@ -230,6 +266,7 @@ void TileDecoder::customisedPoints(const Transformation& transformation, const s point->insert(make_pair("y_component", *vx)); out.push_back(point); point->tile(true); + ux++; vx++; lat++; @@ -244,21 +281,35 @@ void TileDecoder::customisedPoints(const Transformation& transformation, const s PointsHandler& TileDecoder::points(const Transformation& t, bool) { string path = positions_symbols(); Timer timer("Tile", path); + #ifdef HAVE_NETCDF Netcdf netcdf(path, "index"); - map first, last; - first["x"] = tostring(x_); - first["y"] = tostring(y_); - last["x"] = tostring(x_); - last["y"] = tostring(y_); - // vector bbox; - static vector latitudes; - static vector longitudes; - static vector values; + vector latitudes; + vector longitudes; + vector values; vector index; + map first, last; + + if ( mode_ == "opencharts") { + // netcdf.get(projection_ + "_lat", latitudes, first, last); + // netcdf.get(projection_ + "_lon", longitudes, first, last); + netcdf.get(projection_ + "_index", values, first, last); + + + + } + else { + first["x"] = tostring(x_); + first["y"] = tostring(y_); + last["x"] = tostring(x_); + last["y"] = tostring(y_); + netcdf.get("index", values, first, last); + } + + int error; FILE* in = fopen(file_name_.c_str(), "rb"); @@ -280,12 +331,8 @@ PointsHandler& TileDecoder::points(const Transformation& t, bool) { return *(pointsHandlers_.back()); } - + if (latitudes.size() == 0) { - int nbpoints = netcdf.getDimension("points"); - // netcdf.get("bounding-box", bbox, first, last); - netcdf.get("index", values, first, last); - for (auto b = values.begin(); b != values.end(); ++b) { double lat = *b; @@ -295,13 +342,14 @@ PointsHandler& TileDecoder::points(const Transformation& t, bool) { double i = *b; if (i != 0) { - if (lon > 180) - lon -= 360; - // transformation.fast_reproject(lon, lat); - + if ( mode_ != "opencharts") { + if (lon > 180) + lon -= 360; + } latitudes.push_back(lat); longitudes.push_back(lon); index.push_back(i); + } } } @@ -428,21 +476,19 @@ Data* TileDecoder::next() { void TileDecoder::decode() { - if (matrix_.size()) - return; + if (matrix_.size()) { + matrix_ = Matrix(); + + } string path = weights(); Timer timer("Tile", path); #ifdef HAVE_NETCDF + Netcdf netcdf(path, "index"); map first, last; - first["x"] = tostring(x_); - first["y"] = tostring(y_); - last["x"] = tostring(x_); - last["y"] = tostring(y_); - static vector bbox; static vector latitudes; static vector longitudes; @@ -450,10 +496,25 @@ void TileDecoder::decode() { static vector dindex; static vector distances; - int nblat = netcdf.getDimension("lat") - 1; - int nblon = netcdf.getDimension("lon") - 1; + if ( mode_ == "opencharts") { - if (bbox.empty()) { + netcdf.get(projection_ + "_lat", latitudes, first, last); + netcdf.get(projection_ + "_lon", longitudes, first, last); + netcdf.get(projection_ + "_index", dindex, first, last); + netcdf.get(projection_ + "_distances", distances, first, last); + } + else { + first["x"] = tostring(x_); + first["y"] = tostring(y_); + last["x"] = tostring(x_); + last["y"] = tostring(y_); + + + + int nblat = netcdf.getDimension("lat") - 1; + int nblon = netcdf.getDimension("lon") - 1; + + netcdf.get("bounding-box", bbox, first, last); int error; @@ -481,10 +542,13 @@ void TileDecoder::decode() { last["lat"] = tostring(maxy); last["lon"] = tostring(maxx); + + netcdf.get("lat", latitudes, first, last); netcdf.get("lon", longitudes, first, last); netcdf.get("index", dindex, first, last); netcdf.get("distances", distances, first, last); + } int index[4]; diff --git a/src/drivers/BaseDriver.cc b/src/drivers/BaseDriver.cc index bc5674406..d043e82e1 100644 --- a/src/drivers/BaseDriver.cc +++ b/src/drivers/BaseDriver.cc @@ -40,10 +40,16 @@ #include "magics.h" +#include +#include +#include + + using namespace magics; int BaseDriver::numFiles_ = 0; +//#define MAG_POLYLINE_ARROW_DEBUG_ //! Constructor for all drivers /*! @@ -400,6 +406,61 @@ double BaseDriver::LSF(MFloat* x, MFloat* y, int i0) const { return angle; } +// Compute the least square fit (regression) line angle. This does not determine the +// direction of the regression line, so we need an extra step to adjust the computed angle. +double BaseDriver::arrowHeadLSF(MFloat* x, MFloat* y, int i0) const { + double angle = 0.; + const unsigned int n = 3; + const double eps = 1E-5; + double xSum = 0.; + double ySum = 0.; + double x2Sum = 0.; + double xySum = 0; + + for (unsigned int r = 0; r < n; r++) { + auto xp = projectX(x[i0 + r]); + auto yp = projectY(y[i0 + r]); + xSum += xp; + ySum += yp; + x2Sum += (xp * xp); + xySum += (xp * yp); + } + + double s1 = n * xySum - xSum * ySum; + double s2 = n * x2Sum - xSum * xSum; + + // Compute the LSF line angle. This does not tell us which way the line + // goes. We need additional information to estimate it. + if (std::fabs(s2) > eps) { + angle = std::atan(s1/s2); + + } else { + //std::cout << " (LSF) NS line!" << std::endl; + MagLog::debug() << "BaseDriver: Division through zero prevented in calculation of arrowhead angle!" << endl; + return 10.; + } + + // estimate the lines's direction from the line formed by first two point + // TODO: also use the last two points + double dx = projectX(x[i0 + 1]) - projectX(x[i0]); + double dy = projectY(y[i0 + 1]) - projectY(y[i0]); + + // std::cout << " (LSF) angle=" << angle << " dx=" << dx << " dy=" << dy << std::endl; + + // create unite vector from angle + double xAngle = std::cos(angle); + double yAngle = std::sin(angle); + + // compute the scalar product between the two vectors and use the + // sign of it to decide whether they point in the same direction] + auto sp = dx*xAngle + dy*yAngle; + if (sp <= 0) { + angle += PI; + //std::cout << " --> a=" << angle*180/PI << std::endl; + } + return angle; +} + /*! \brief Method plotting Polylines with Labels. @@ -449,10 +510,102 @@ void BaseDriver::printLine(const magics::Polyline& line) const { } } - const unsigned int minimum_points_for_labelling = 25; // must be at least -15 : see function LSF above + if (arrowHead) { + renderArrowHeadsAlongLine(line, x, y, n); + } else { + renderLabelsAlongLine(line, x, y, n); + } + + delete[] x; + delete[] y; + currentColour_ = Colour("none"); +} + +void BaseDriver::renderArrowHeadsAlongLine(const magics::Polyline& line, MFloat* x, MFloat* y, unsigned long n) const { +#ifdef MAG_POLYLINE_ARROW_DEBUG_ + { + if (n > 25) { + // Use this code to draw a green line segment to the beginning of the polyline + magics::Colour dbgCol("green"); + const unsigned long maxDbgLineLen = 3; + MFloat* xx = new MFloat[maxDbgLineLen]; + MFloat* yy = new MFloat[maxDbgLineLen]; + auto dbgLineLen = std::min(maxDbgLineLen, n); + for (unsigned long i = 0; i < dbgLineLen ; i++) { + xx[i] = x[i]; + yy[i] = y[i]; + } + setNewColour(dbgCol); + renderPolyline(dbgLineLen, xx, yy); + delete[] xx; + delete[] yy; + setNewColour(line.getColour()); + } + } +#endif + +// when this debug code is enabled we try add an arrowhead to each line +#ifdef MAG_POLYLINE_ARROW_DEBUG_ + const unsigned int minimum_points_for_labelling = 4; +#else + const unsigned int minimum_points_for_labelling = 25; // must be at least -15 : see function LSF +#endif + + if (n > minimum_points_for_labelling) { + unsigned int i = 10; + const unsigned int step =5; + static const double cosLimit = std::cos(0.01); +#ifdef MAG_POLYLINE_ARROW_DEBUG_ + i = 1; + //std::cout << "LINE" << std::endl; +#endif + while (i < n - minimum_points_for_labelling) { + assert(i < n-1); + assert(i+1 <= n-1); + bool closeAngles = false; + const double angle = arrowHeadLSF(x, y, i); +#ifdef MAG_POLYLINE_ARROW_DEBUG_ + closeAngles = angle < 4.; +#else + const double angle2 = arrowHeadLSF(x, y, i + 1); + if (angle < 4. && angle2 < 4.) { + // the cos of the angular diff is the scalar product + auto sp = std::cos(angle)*std::cos(angle2) + std::sin(angle)*std::sin(angle2); + closeAngles = (sp >= cosLimit); + } +#endif + if (closeAngles) { + MFloat pro_x = x[i+1]; + MFloat pro_y = y[i+1]; + + Arrow arrow; + arrow.copy(*line.arrowProperties()); + arrow.setColour(line.getColour()); + arrow.setArrowPosition(ArrowPosition::HEAD_ONLY); + +#ifdef MAG_POLYLINE_ARROW_DEBUG_ + //std::cout << " add " << angle * 180 / 3.14 << " [" << pro_x << "," << pro_y << "] " << x[i+1] << "," << x[i+2] << "," << x[i+3] << std::endl; +#endif + const double dx = std::cos(angle); + const double dy = setAngleY(std::sin(angle)); + PaperPoint pp(pro_x, pro_y); + ArrowPoint apoint(dx, dy, pp); + arrow.push_back(apoint); + renderWindArrow(arrow); + + i += step; + } // angles are not the same + i += step; + } + } +} + +void BaseDriver::renderLabelsAlongLine(const magics::Polyline& line, MFloat* x, MFloat* y, unsigned long n) const { + const unsigned int minimum_points_for_labelling = 25; // must be at least -15 : see function LSF + + if (n > minimum_points_for_labelling && + line.getLabel().isVisible() && line.getLabel().getText() != "") { - if ((arrowHead || (line.getLabel().isVisible() && line.getLabel().getText() != "")) && - (n > minimum_points_for_labelling)) { ASSERT(staLayouts_.empty() == false); MFloat* labelx = new MFloat[n]; // in theory, we shouldn't need this many entries... @@ -487,41 +640,23 @@ void BaseDriver::printLine(const magics::Polyline& line) const { const double distance_squared = ((THIS_X - PREV_X) * (THIS_X - PREV_X)) + ((THIS_Y - PREV_Y) * (THIS_Y - PREV_Y)); - if ((arrowHead) || (distance_squared > min_square_distance_between_labels)) { - if (arrowHead) { - MFloat pro_x = x[i]; - MFloat pro_y = y[i]; - - Arrow arrow; - arrow.copy(*line.arrowProperties()); - arrow.setColour(line.getColour()); - arrow.setArrowPosition(ArrowPosition::HEAD_ONLY); - if ((x[i] - x[i + 3]) < 0.) - angle += PI; - const double dx = sin(angle + 1.5707963267949); - const double dy = -setAngleY(cos(angle + 1.5707963267949)); - PaperPoint pp(pro_x, pro_y); - ArrowPoint apoint(dx, dy, pp); - arrow.push_back(apoint); - renderWindArrow(arrow); - } - else { - MFloat pro_x = x[i + 2]; - MFloat pro_y = y[i + 2]; - Text text; - PaperPoint pp(pro_x, pro_y); - text.push_back(pp); - Label label = line.getLabel(); - MagFont font = label.font(); - text.setFont(font); - text.addText(label.getText(), font.colour(), font.size()); - text.setBlanking(label.getBlanking()); - text.setJustification(label.getJustification()); - text.setVerticalAlign(VerticalAlign::HALF); - text.setAngle(-setAngleY(angle)); - text.setFont(font); - renderText(text); - } + if (distance_squared > min_square_distance_between_labels) { + MFloat pro_x = x[i + 2]; + MFloat pro_y = y[i + 2]; + Text text; + PaperPoint pp(pro_x, pro_y); + text.push_back(pp); + Label label = line.getLabel(); + MagFont font = label.font(); + text.setFont(font); + text.addText(label.getText(), font.colour(), font.size()); + text.setBlanking(label.getBlanking()); + text.setJustification(label.getJustification()); + text.setVerticalAlign(VerticalAlign::HALF); + text.setAngle(-setAngleY(angle)); + text.setFont(font); + renderText(text); + labelx[num_labels] = x[i]; labely[num_labels] = y[i]; num_labels++; @@ -532,10 +667,7 @@ void BaseDriver::printLine(const magics::Polyline& line) const { } delete[] labelx; delete[] labely; - } // endif enough points for a label - delete[] x; - delete[] y; - currentColour_ = Colour("none"); + } } void BaseDriver::renderPolyline(vector& vP) const { diff --git a/src/drivers/BaseDriver.h b/src/drivers/BaseDriver.h index 88bda3901..e5eab1d3d 100644 --- a/src/drivers/BaseDriver.h +++ b/src/drivers/BaseDriver.h @@ -369,6 +369,9 @@ class BaseDriver : public BaseDriverAttributes, public MagicsObserver { double LSF(MFloat* x, MFloat* y, int i0) const; + double arrowHeadLSF(MFloat* x, MFloat* y, int i0) const; + void renderArrowHeadsAlongLine(const Polyline& line, MFloat* x, MFloat* y, unsigned long n) const; + void renderLabelsAlongLine(const Polyline& line, MFloat* x, MFloat* y, unsigned long n) const; mutable int currentPage_; mutable string fileName_; diff --git a/src/eckit_readers/MvLocation.cc b/src/eckit_readers/MvLocation.cc index 9191cac07..04bc03b9f 100644 --- a/src/eckit_readers/MvLocation.cc +++ b/src/eckit_readers/MvLocation.cc @@ -7,74 +7,142 @@ ***************************** LICENSE END *************************************/ -// MvLocation.cc, vk 940901... -// rev vk 011025 +#include +#include "MvLocation.h" -// classes: MvLocation, MvArea, MvXSectionLine +//=================================================== +// +// MvLocation +// +//=================================================== +const double MvLocation::cRadian = 180. / M_PI; +const double MvLocation::cDegree = 1 / MvLocation::cRadian; +const double MvLocation::cRadianToMetre = 1852 *180.0 * 60.0 / M_PI; +const double MvLocation::cMetreToRadian = 1./MvLocation::cRadianToMetre; -#include "MvLocation.h" -#include -//_____________________________________________________________________ set -void MvLocation ::set(double aLat, double aLong) { - fLatitude = aLat; - fLongitude = aLong; +MvLocation& MvLocation::operator=(const MvLocation& aLoc) +{ + set(aLoc.latitude(), aLoc.longitude()); + return *this; +} + +void MvLocation::set(double aLat, double aLong) +{ + lat_ = aLat; + lon_ = aLong; } -//______________________________________________________________ distanceInRadians -double MvLocation ::distanceInRadians(const MvLocation& anOtherLocation) const { - const double cDEG2RAD = M_PI / 180.0; +void MvLocation::ensureLongitudeBelow360() +{ + while (lon_ >= 360) { + lon_ -= 360; + } +} - double lat1 = latitude() * cDEG2RAD; - double lat2 = anOtherLocation.latitude() * cDEG2RAD; - double lon1 = longitude() * cDEG2RAD; - double lon2 = anOtherLocation.longitude() * cDEG2RAD; +// compute the cosine of the angular distance between the current and the other location +double MvLocation::cosOfDistance(double aLat, double aLon) const +{ + // short-circuit if the two points are the same, because floating-point + // imprecisions can cause a 'nan' on the next calculation + if ((lat_ == aLat) && (lon_ == aLon)) { + return 1.; + } - //-- from: http://williams.best.vwh.net/avform.htm (020815/vk) -- - double d = acos(sin(lat1) * sin(lat2) + cos(lat1) * cos(lat2) * cos(lon1 - lon2)); + double lat1 = degToRad(lat_); + double lat2 = degToRad(aLat); + double dlon = degToRad(lon_ - aLon); - return d; + //-- from: http://williams.best.vwh.net/avform.htm + return std::sin(lat1) * std::sin(lat2) + std::cos(lat1) * std::cos(lat2) * std::cos(dlon); } -//_____________________________________________________________ distanceInDegrees -double MvLocation ::distanceInDegrees(const MvLocation& anOtherLocation) const { - return distanceInRadians(anOtherLocation) * 180.0 / M_PI; +// compute the cosine of the angular distance between the current and the other location +double MvLocation::cosOfDistance(const MvLocation& other) const +{ + return cosOfDistance(other.latitude(), other.longitude()); } -//_____________________________________________________________ distanceInMeters -double MvLocation ::distanceInMeters(const MvLocation& anOtherLocation) const { - const double cR2NM = 180.0 * 60.0 / M_PI; //-- radians -> nautical miles - const double cNM2M = 1852; //-- nautical miles -> metres +// compute the angular distance in radians between the current and the other location +double MvLocation::distanceInRadians(const MvLocation& other) const +{ + return std::acos(cosOfDistance(other)); +} - double nm = distanceInRadians(anOtherLocation) * cR2NM; - return nm * cNM2M; - ; +// compute the angular distance in degrees between the current and the other location +double MvLocation::distanceInDegrees(const MvLocation& other) const +{ + return radToDeg(distanceInRadians(other)); } -//_____________________________________________________________ operator= -MvLocation& MvLocation ::operator=(const MvLocation& aLoc) { - set(aLoc.latitude(), aLoc.longitude()); - return *this; +// compute the distance in metres on the surface of Earth +// between the current and the other location +double MvLocation::distanceInMeters(const MvLocation& other) const +{ + return radiansToMetres(distanceInRadians(other)); } -//_____________________________________________________________ operator<< -ostream& operator<<(ostream& aStream, const MvLocation& aLocation) { +std::ostream& operator<<(std::ostream& aStream, const MvLocation& aLocation) +{ aStream << "(" << aLocation.latitude() << "," << aLocation.longitude() << ")"; + /*--- How to get a constant field width + constant nr of decimal digits!? + aStream << "("; + aStream.width( 6 ); aStream.fill( ' ' ); + aStream << aLocation.latitude() << ","; + aStream.width( 7 ); aStream.fill( ' ' ); + aStream << aLocation.longitude() << ")"; +---*/ return aStream; } +//=================================================== +// +// MvLocationHub +// +//=================================================== + +MvLocationHub& MvLocationHub::operator=(const MvLocationHub& aLoc) +{ + set(aLoc.latitude(), aLoc.longitude()); + cosLat_ = aLoc.cosLat_; + sinLat_ = aLoc.sinLat_; + return *this; +} + +double MvLocationHub::cosOfDistance(double aLat, double aLon) const +{ + if (sinLat_ < -100) { + sinLat_ = std::sin(degToRad(lat_)); + cosLat_ = std::cos(degToRad(lat_)); + } + + // short-circuit if the two points are the same, because floating-point + // imprecisions can cause a 'nan' on the next calculation + if (lat_ == aLat && lon_ == aLon) { + return 1.; + } + + double lat2 = degToRad(aLat); + double dLon = degToRad(lon_ - aLon); + + //-- from: http://williams.best.vwh.net/avform.htm + return sinLat_* std::sin(lat2) + cosLat_ * std::cos(lat2) * std::cos(dLon); +} + //____________________________________________________________________________ //============================================================================ MvArea //____________________________________________________________________________ -MvArea ::MvArea(void) { +MvArea ::MvArea() +{ MvLocation myLocation; set(myLocation, myLocation); } //____________________________________________________________________ -void MvArea ::set(const MvLocation& aLocation1, const MvLocation& aLocation2) { +void MvArea ::set(const MvLocation& aLocation1, const MvLocation& aLocation2) +{ double y1 = aLocation1.latitude(); double x1 = aLocation1.longitude(); double y2 = aLocation2.latitude(); @@ -94,22 +162,28 @@ void MvArea ::set(const MvLocation& aLocation1, const MvLocation& aLocation2) { } //____________________________________________________________________ -bool MvArea ::inside(const MvLocation& aPoint) const { - if (aPoint.latitude() >= fLowerLeft.latitude() && aPoint.latitude() <= fUpperRight.latitude() && - aPoint.longitude() >= fLowerLeft.longitude() && aPoint.longitude() <= fUpperRight.longitude()) +bool MvArea ::inside(const MvLocation& aPoint) const +{ + if (aPoint.latitude() >= fLowerLeft.latitude() && + aPoint.latitude() <= fUpperRight.latitude() && + aPoint.longitude() >= fLowerLeft.longitude() && + aPoint.longitude() <= fUpperRight.longitude()) return true; else return false; } //____________________________________________________________________ -MvArea& MvArea ::operator=(const MvArea& anArea) { +MvArea& +MvArea ::operator=(const MvArea& anArea) +{ set(anArea.lowerLeft(), anArea.upperRight()); return *this; } //____________________________________________________________________ -ostream& operator<<(ostream& aStream, const MvArea& anArea) { +std::ostream& operator<<(std::ostream& aStream, const MvArea& anArea) +{ aStream << anArea.lowerLeft() << "-" << anArea.upperRight(); return aStream; } @@ -119,7 +193,8 @@ ostream& operator<<(ostream& aStream, const MvArea& anArea) { //______________________________________________________________________ //_____________________________________________________________ WithinDelta -bool MvXSectionLine ::withinDelta(const MvLocation& aLocation) const { +bool MvXSectionLine ::withinDelta(const MvLocation& aLocation) const +{ //-- check that max delta has been set if (fMaxDeltaInMeters < 0) return false; @@ -132,7 +207,8 @@ bool MvXSectionLine ::withinDelta(const MvLocation& aLocation) const { return insideXLine(aLocation); } //_____________________________________________________________ InsideXLine -bool MvXSectionLine ::insideXLine(const MvLocation& aLocation) const { +bool MvXSectionLine ::insideXLine(const MvLocation& aLocation) const +{ MvLocation myLocation = nearestPointOnXLine(aLocation); MvArea myArea(fLocation1, fLocation2); return myArea.inside(myLocation); @@ -144,7 +220,9 @@ bool MvXSectionLine ::insideXLine(const MvLocation& aLocation) const { // WARNING: calculates distance from a line going through end // points of XSectionLine, NOT ONLY between points! //------------------------------------------------------------- -MvLocation MvXSectionLine ::nearestPointOnXLine(const MvLocation& aLocation) const { +MvLocation +MvXSectionLine ::nearestPointOnXLine(const MvLocation& aLocation) const +{ MvLocation myNearestPointOnXLine; double dy = fLocation1.latitude() - fLocation2.latitude(); @@ -177,19 +255,25 @@ MvLocation MvXSectionLine ::nearestPointOnXLine(const MvLocation& aLocation) con return myNearestPointOnXLine; } //_____________________________________________________________ DeltaInDegrees -double MvXSectionLine ::deltaInDegrees(const MvLocation& aLocation) const { +double +MvXSectionLine ::deltaInDegrees(const MvLocation& aLocation) const +{ return aLocation.distanceInDegrees(nearestPointOnXLine(aLocation)); } //_____________________________________________________________ DeltaInMeters // Q&D approximation for delta, uses DeltaInDegrees //------------------------------------------------------------- -double MvXSectionLine ::deltaInMeters(const MvLocation& aLocation) const { +double +MvXSectionLine ::deltaInMeters(const MvLocation& aLocation) const +{ //-- Q&D formula, out of my old used brains, unchecked!!!! (vk 940901) -- double degreeIntoMeters = 6370. * 1000. * 2. * M_PI / 360.; return deltaInDegrees(aLocation) * degreeIntoMeters; } //_____________________________________________________________ operator= -MvXSectionLine& MvXSectionLine ::operator=(const MvXSectionLine& anXLine) { +MvXSectionLine& +MvXSectionLine ::operator=(const MvXSectionLine& anXLine) +{ setLine(anXLine.startPoint(), anXLine.endPoint()); setMaxDelta(anXLine.maxDelta()); return *this; @@ -198,7 +282,9 @@ MvXSectionLine& MvXSectionLine ::operator=(const MvXSectionLine& anXLine) { // output format: "(lat1,long1)-(lat2,long2)/delta" //------------------------------------------------- -ostream& operator<<(ostream& aStream, const MvXSectionLine& anXLine) { - aStream << anXLine.startPoint() << "-" << anXLine.endPoint() << "/" << anXLine.fMaxDeltaInMeters; // << endl; +std::ostream& operator<<(std::ostream& aStream, const MvXSectionLine& anXLine) +{ + aStream << anXLine.startPoint() << "-" << anXLine.endPoint() + << "/" << anXLine.fMaxDeltaInMeters; // << std::endl; return aStream; } diff --git a/src/eckit_readers/MvLocation.h b/src/eckit_readers/MvLocation.h index a54bd1a57..81a5536bc 100644 --- a/src/eckit_readers/MvLocation.h +++ b/src/eckit_readers/MvLocation.h @@ -7,85 +7,100 @@ ***************************** LICENSE END *************************************/ -// MvLocation.h, vk 940901... -// rev vk 950303 +#pragma once -#ifndef MvLocation_DEFINED_ -#define MvLocation_DEFINED_ - -#include "inc_iostream.h" +#include const double MISSING_LOC_VALUE = -99999.; +//========================================================= +// WARNING: we cannot use MvSci here because this code is +// also included in the Magics source!!! +//========================================================= -//_________________________________________________________________________ MvLocation //! Class for geographical locations /*! MvLocation is used to store latitude-longitude location values. * Class also provides methods to calculate the distance to another * geographical location */ -class MvLocation { +class MvLocation +{ //! Output operator for MvLocation object /*! The output is enclosed in parenthesis and latitude and longitude values - * are separated by a comma, for instance: - *
-     *      MvLocation loc1(51.46,-1.33);
-     *      MvLocation loc2(60.45,25.0);
-     *      std::cout << "Locations are: " << loc1 << " and " << loc2 << std::endl;
-     * 
- * would output the following line: - *
-     *      Locations are: (51.46,-1.33) and (60.45,25)
-     * 
- */ - friend ostream& operator<<(ostream& aStream, const MvLocation& aLocation); + * are separated by a comma, for instance: + *
+ *      MvLocation loc1(51.46,-1.33);
+ *      MvLocation loc2(60.45,25.0);
+ *      std::cout << "Locations are: " << loc1 << " and " << loc2 << std::endl;
+ * 
+ * would output the following line: + *
+ *      Locations are: (51.46,-1.33) and (60.45,25)
+ * 
+ */ + friend std::ostream& operator<<(std::ostream& aStream, const MvLocation& aLocation); public: - //! Constructor, location is assigned with missing values - MvLocation() { - fLatitude = MISSING_LOC_VALUE; - fLongitude = MISSING_LOC_VALUE; - } - - //! Constructor for latitude-longitude location + MvLocation() {} MvLocation(double aLat, double aLong) { set(aLat, aLong); } + MvLocation& operator=(const MvLocation& aLoc); - //! Sets new latitude-longitude location void set(double aLat, double aLong); - //! Checks that the stored location is a valid geographical point - /*! Latitude value must be in interval [-90,90] and longitude - * value in interval [-360,360], in degrees. - */ - bool ok() { return (fLatitude <= 90 && fLatitude >= -90 && fLongitude <= 360 && fLongitude >= -360); } - - //! Returns the latitude value - double latitude() const { return fLatitude; } - - //! Alias to method latitude() - double y() const { return fLatitude; } - - //! Returns the longitude value - double longitude() const { return fLongitude; } - - //! Alias to method longitude() - double x() const { return fLongitude; } - - //! Returns the distance (in radians) to the given point - double distanceInRadians(const MvLocation& anOtherLocation) const; - - //! Returns the distance (in degrees) to the given point - double distanceInDegrees(const MvLocation& anOtherLocation) const; - - //! Returns the distance (in metres) to the given point - double distanceInMeters(const MvLocation& anOtherLocation) const; + // Checks that the stored location is a valid geographical point + // Latitude value must be in interval [-90,90] and longitude + // value in interval [-360,360], in degrees. + bool ok() const { return (lat_ <= 90 && lat_ >= -90 && + lon_ <= 360 && lon_ >= -360); } + + // Subtracts 360 until the longitude is below 360 (e.g. 360 becomes 0, 370 becomes 10) + void ensureLongitudeBelow360(); + + double latitude() const { return lat_; } + double y() const { return lat_; } + double longitude() const { return lon_; } + double x() const { return lon_; } + + // Returns the cosine of the angular distance to the given point + double cosOfDistance(const MvLocation& other) const; + virtual double cosOfDistance(double aLat, double aLon) const; + + // Returns the distance (in radians) to the given point + double distanceInRadians(const MvLocation& other) const; + + // Returns the distance (in degrees) to the given point + double distanceInDegrees(const MvLocation& other) const; + + // Returns the distance (in metres) to the given point + double distanceInMeters(const MvLocation& other) const; + +protected: + // ideally McSci should be used here, but see warning above! + static double degToRad(double d) {return d * cDegree;} + static double radToDeg(double r) {return r * cRadian;} + static double metresToRadians(double m) {return m*cMetreToRadian;} + static double radiansToMetres(double r) {return r*cRadianToMetre;} + + static const double cRadian; + static const double cDegree; + static const double cMetreToRadian; + static const double cRadianToMetre; + double lat_{MISSING_LOC_VALUE}; + double lon_{MISSING_LOC_VALUE}; +}; - //! Assignment operator - MvLocation& operator=(const MvLocation& aLoc); +// A location from that the distance to other locations are computed. It +// caches some trigonometric values to make the computations faster. +class MvLocationHub : public MvLocation +{ +public: + using MvLocation::MvLocation; + MvLocationHub& operator=(const MvLocationHub& aLoc); + double cosOfDistance(double aLat, double aLon) const override; -private: - double fLatitude; - double fLongitude; +protected: + mutable double cosLat_{-1000.}; + mutable double sinLat_{-1000.}; }; //_________________________________________________________________________ MvArea @@ -93,12 +108,16 @@ class MvLocation { /*! This is another incarnation of MvGeoBox class, used mainly by * MvObsSetIterator. For other usage MvGeoBox is recommended over MvArea. */ -class MvArea { - friend ostream& operator<<(ostream& aStream, const MvArea& aArea); +class MvArea +{ + friend std::ostream& operator<<(std::ostream& aStream, const MvArea& aArea); public: MvArea(); - MvArea(const MvLocation& aLoc1, const MvLocation& aLoc2) { set(aLoc1, aLoc2); } + MvArea(const MvLocation& aLoc1, const MvLocation& aLoc2) + { + set(aLoc1, aLoc2); + } void set(const MvLocation& aLoc1, const MvLocation& aLoc2); bool inside(const MvLocation& aPoint) const; @@ -118,12 +137,14 @@ class MvArea { * distance (max delta) from the given line, i.e. close enough to be * considered to be within the line. */ -class MvXSectionLine { - friend ostream& operator<<(ostream& aStream, const MvXSectionLine& aXSectionLine); +class MvXSectionLine +{ + friend std::ostream& operator<<(std::ostream& aStream, const MvXSectionLine& aXSectionLine); public: //! Empty constructor creates a missing line - MvXSectionLine(void) { + MvXSectionLine(void) + { fLocation1.set(MISSING_LOC_VALUE, MISSING_LOC_VALUE); fLocation2.set(MISSING_LOC_VALUE, MISSING_LOC_VALUE); fMaxDeltaInMeters = -1; @@ -131,22 +152,25 @@ class MvXSectionLine { //! Constructor, only points defined, no max delta given /*! Use method setMaxDelta() to set the maximum allowed distance from the line - */ - MvXSectionLine(const MvLocation& aLoc1, const MvLocation& aLoc2) { + */ + MvXSectionLine(const MvLocation& aLoc1, const MvLocation& aLoc2) + { fLocation1 = aLoc1; fLocation2 = aLoc2; fMaxDeltaInMeters = -1; } //! Constructor, two points and max distance from the line - MvXSectionLine(const MvLocation& aLoc1, const MvLocation& aLoc2, double aDelta) { + MvXSectionLine(const MvLocation& aLoc1, const MvLocation& aLoc2, double aDelta) + { fLocation1 = aLoc1; fLocation2 = aLoc2; fMaxDeltaInMeters = aDelta; } //! Set a new line between points aLoc1 and aLoc2 - void setLine(const MvLocation& aLoc1, const MvLocation& aLoc2) { + void setLine(const MvLocation& aLoc1, const MvLocation& aLoc2) + { fLocation1 = aLoc1; fLocation2 = aLoc2; } @@ -188,5 +212,4 @@ class MvXSectionLine { double fMaxDeltaInMeters; }; -#endif // MvLocation_DEFINED_ diff --git a/src/libMagWrapper/MagPlus.cc b/src/libMagWrapper/MagPlus.cc index 084b0d620..bcdb602dd 100644 --- a/src/libMagWrapper/MagPlus.cc +++ b/src/libMagWrapper/MagPlus.cc @@ -43,6 +43,7 @@ #include "ObsDecoderWrapper.h" #include "ObsPlottingWrapper.h" +#include "BoxPlotDecoderWrapper.h" #include "ContourWrapper.h" #include "GeoJSonWrapper.h" @@ -55,6 +56,10 @@ #include "TextVisitor.h" #include "TextVisitorWrapper.h" + +#include "BoxPlotVisualiserWrapper.h" + + #include "GraphPlottingWrapper.h" #include "MultiVisdef.h" #include "SymbolPlottingWrapper.h" @@ -209,6 +214,8 @@ MagPlus::MagPlus() : root_(0), superpage_(-1), geographical_(true), mode_(intera sceneCreators_["INPUT_GEO_VECTORS"] = &MagPlus::input; sceneCreators_["INPUT_XY_BINNING"] = &MagPlus::input; sceneCreators_["INPUT_GEO_BINNING"] = &MagPlus::input; + sceneCreators_["INPUT_BOXPLOT"] = &MagPlus::inputBoxplot; + sceneCreators_["TABLE_XY_POINTS"] = &MagPlus::table; sceneCreators_["TABLE_GEO_POINTS"] = &MagPlus::table; @@ -237,6 +244,7 @@ MagPlus::MagPlus() : root_(0), superpage_(-1), geographical_(true), mode_(intera sceneCreators_["PSYMB"] = &MagPlus::symbol; sceneCreators_["MSYMB"] = &MagPlus::symbol; sceneCreators_["PSYMBPLUS"] = &MagPlus::symbol; + sceneCreators_["MBOXPLOT"] = &MagPlus::boxplot; sceneCreators_["PWIND"] = &MagPlus::wind; sceneCreators_["MWIND"] = &MagPlus::wind; sceneCreators_["MGRAPH"] = &MagPlus::graph; @@ -823,7 +831,6 @@ bool MagPlus::binning(magics::MagRequest& in) { } bool MagPlus::grib(magics::MagRequest& in) { - MagLog::dev() << "add grib" << endl; in.print(); @@ -983,7 +990,6 @@ void MagPlus::setIconInfo(magics::MagRequest& mv, MetviewIcon& object) { } bool MagPlus::gribloop(magics::MagRequest& in) { - MagLog::dev() << "add gribloop" << endl; in.print(); string loop("loop"); @@ -1398,7 +1404,6 @@ bool MagPlus::geojson(magics::MagRequest& in) { } bool MagPlus::bufr(magics::MagRequest& in) { - /* // Extract the path .. magics::MagRequest record = in("RECORD"); @@ -1416,6 +1421,20 @@ bool MagPlus::bufr(magics::MagRequest& in) { setIconInfo(in, *obs.object()); return false; // do not exit } + +bool MagPlus::inputBoxplot(magics::MagRequest& in) { + in.print(); + VisualAction* action = new VisualAction(); + top()->push_back(action); + push(action); + + BoxPlotDecoderWrapper boxplot; + boxplot.set(in); + top()->data(boxplot.object()); + setIconInfo(in, *boxplot.object()); + + return false; // do not exit +} bool MagPlus::symbol(magics::MagRequest& in) { if (in.countValues("SYMBOL_INPUT_MARKER_LIST")) { in("SYMBOL_MARKER") = in("SYMBOL_INPUT_MARKER_LIST"); @@ -1461,7 +1480,6 @@ bool MagPlus::graph(magics::MagRequest& in) { } bool MagPlus::obs(magics::MagRequest& in) { - ObsPlottingWrapper visdef; visdef.set(in); @@ -1471,6 +1489,16 @@ bool MagPlus::obs(magics::MagRequest& in) { pop(); + return false; // do not exit +} +bool MagPlus::boxplot(magics::MagRequest& in) { + BoxPlotVisualiserWrapper visdef; + + visdef.set(in); + + MagLog::dev() << "add boxplot visualiser" << *visdef.object() << endl; + top()->visdef(visdef.object()); + pop(); return false; // do not exit } @@ -1784,9 +1812,9 @@ void MagPlus::notify(MagicsEvent& event) { } void MagPlus::unregisterObserver(MagicsObserver* observer) { - // observers_.erase( - // std::remove_if(observers_.begin(), observers_.end(), bind2nd(std::equal_to(), observer)), - // observers_.end()); + // observers_.erase( + // std::remove_if(observers_.begin(), observers_.end(), bind2nd(std::equal_to(), observer)), + // observers_.end()); } void setDouble(const string& key, const ParamJSon& json, MagRequest& out) { diff --git a/src/libMagWrapper/MagPlus.h b/src/libMagWrapper/MagPlus.h index db8f6cd3c..81f26849a 100644 --- a/src/libMagWrapper/MagPlus.h +++ b/src/libMagWrapper/MagPlus.h @@ -114,6 +114,7 @@ class MagPlus : public stack { bool raster(magics::MagRequest&); bool input(magics::MagRequest&); + bool inputBoxplot(magics::MagRequest&); bool table(magics::MagRequest&); bool binning(magics::MagRequest&); @@ -123,6 +124,7 @@ class MagPlus : public stack { bool import(magics::MagRequest&); bool obs(magics::MagRequest&); bool graph(magics::MagRequest&); + bool boxplot(magics::MagRequest&); bool multi(magics::MagRequest&); bool ptext(magics::MagRequest&); diff --git a/src/params/Axis.xml b/src/params/Axis.xml index af2609c17..cae9bd550 100644 --- a/src/params/Axis.xml +++ b/src/params/Axis.xml @@ -91,7 +91,13 @@ does it submit to any jurisdiction. from="string" name="axis_grid_colour"> Colour of grid lines - 2.13.5 - Default changed fronm YELLOW to BLACK + + + Colour of grid background Quality of the font + + List of highlighted values + + + Colour of highlighted values lines + + + Line style of of highlighted values lines + + + Thickness of of highlighted values lines +
diff --git a/src/params/BoxPlotVisualiser.xml b/src/params/BoxPlotVisualiser.xml index a2a8dad1b..3a2f38dca 100644 --- a/src/params/BoxPlotVisualiser.xml +++ b/src/params/BoxPlotVisualiser.xml @@ -9,7 +9,6 @@ does it submit to any jurisdiction. The following parameters allow the user to define both the data @@ -18,24 +17,157 @@ does it submit to any jurisdiction. name="boxplot_box" default="on" member="box" - to="NoBoxPlotBox" - include="BoxPlotBasicItem.h"> + to="bool"> + Turns the plotting of the box on or off - - - Magics++1.3 + + + + Colour of the box + + + Width of the box in centimeters + + + Determines whether the box border is drawn or not + + + Colour of the box border + + + Thickness of the box border + + + Line style of the box border + + + Determines whether the median line is drawn or not + + + Colour of the median line + + + Thickness of the median line + + + Line style of the median line - Determines whether the whiskers are shown as lines, boxes or not at all - - - - Magics++1.3 + to="string" + values="box/off/line" + > + Determines whether the whiskers are shown as lines, boxes or not at all + + + + Colour of the whisker box + + + Width of the whisker box in centimeters + + + Determines whether the whisker box border is drawn or not + + + + Colour of the whisker box border + + + Thickness of the whisker box border + + + Line style of the whisker box border + + + Colour of the whisker line + + + Thickness of the whisker line + + + Line style of the whisker line diff --git a/src/params/CMakeLists.txt b/src/params/CMakeLists.txt index 557516946..981e9f44e 100644 --- a/src/params/CMakeLists.txt +++ b/src/params/CMakeLists.txt @@ -13,6 +13,8 @@ BinaryObject.xml BinningObject.xml BothValuePlotMethod.xml Boundaries.xml +BoxPlotVisualiser.xml +BoxPlotDecoder.xml CalculateColourTechnique.xml GradientsColourTechnique.xml PaletteColourTechnique.xml @@ -207,14 +209,8 @@ YLogarithmicCoordinate.xml YRegularCoordinate.xml ) -list( APPEND _magics_xmls BoxPlotBox.xml - BoxPlotBoxBorder.xml - BoxPlotDecoder.xml - BoxPlotMedian.xml - BoxPlotVisualiser.xml - BoxPlotWhiskerBorder.xml - BoxPlotWhiskerBox.xml - BoxPlotWhiskerLine.xml +list( APPEND _magics_xmls + CdfGraph.xml EpsCloud.xml EpsDirection.xml diff --git a/src/params/EpsGraph.xml b/src/params/EpsGraph.xml index 6388879df..9177b0160 100644 --- a/src/params/EpsGraph.xml +++ b/src/params/EpsGraph.xml @@ -187,12 +187,12 @@ does it submit to any jurisdiction. name="eps_deterministic_legend_text"> Text to be used in the legend - - plot the deterministic Forecast + plot the control Forecast ignore legend + + if On ( default) the legend will use a grey scale ootherwise it will use user defined colour + Line thickness of the deterministic forecast + + show teh precnetiles + + + List of the precentiles to display + + + List of colours to use to display the percentiles + + + List of line-style to use to display the percentiles + + + List of line-thickness to use to display the percentiles + colours used for plumes shading + + Background level list + + + Background colour list + + + Background colour list + + + + + + diff --git a/src/params/EpsWave.xml b/src/params/EpsWave.xml index c78cfa2e1..a3e46dd32 100644 --- a/src/params/EpsWave.xml +++ b/src/params/EpsWave.xml @@ -22,5 +22,12 @@ does it submit to any jurisdiction. name="eps_rose_wave_colour"> Rose wind darker colour + + plot the control Forecast + diff --git a/src/params/GeoJSon.xml b/src/params/GeoJSon.xml index 8c539088b..7d98c8c64 100644 --- a/src/params/GeoJSon.xml +++ b/src/params/GeoJSon.xml @@ -42,5 +42,12 @@ does it submit to any jurisdiction. name="geojson_binning_grid_resolution"> String containing the GeoJson data + + String containing the GeoJson data + diff --git a/src/params/GribDecoder.xml b/src/params/GribDecoder.xml index 51861e286..97b1a55f0 100644 --- a/src/params/GribDecoder.xml +++ b/src/params/GribDecoder.xml @@ -23,6 +23,30 @@ does it submit to any jurisdiction. Magics++0.1 The name of the input file containing the GRIB code field(s) + + + The name of the input file containing the u-component of wind + + + + The name of the input file containing the u-component of wind + + + + The name of the input file containing the v-component of wind + The position in the input file of a field other than a wind component + + used when the offset is too big + The position in the input file of a wind component field The position in the input file of a wind component field used to colour the flag + + The position in the input file of a wind component field + + + The position in the input file of a wind component field + + + The position in the input file of a wind component field used to colour the flag + - Magics++2.4 This can speed up the reading of the matrix. Automatic : No Hint : Magics will create the matrix from the values of the parameters netcdf_x_variable and netcdf_y_variable. Direct : Little hint for Magics : it can load the matrix direcly Transposed : Little hint for Magics : It has to transpose the Matrix + + Ignore or not missing value when setting automatic projection: useful for tiemseries containing missing values. + diff --git a/src/params/NetcdfXYpointsInterpretor.xml b/src/params/NetcdfXYpointsInterpretor.xml index 17681a0f7..7c976295c 100644 --- a/src/params/NetcdfXYpointsInterpretor.xml +++ b/src/params/NetcdfXYpointsInterpretor.xml @@ -13,5 +13,9 @@ does it submit to any jurisdiction. directory="decoders" prefix="netcdf" action="pnetcdf" - include="NetcdfGeopointsInterpretor.h"> + include="NetcdfGeopointsInterpretor.h"> + + + + diff --git a/src/params/ObsPlotting.xml b/src/params/ObsPlotting.xml index 002408a5f..82a9bca78 100644 --- a/src/params/ObsPlotting.xml +++ b/src/params/ObsPlotting.xml @@ -51,11 +51,11 @@ does it submit to any jurisdiction. - Colour used to display the present weather + Colour used to display the present weather. [automatic] will use [obs_colour], [coloured_present_weather] will use the calssical colours for the symbols Colour used to display wind + + Thickness of the wind flags + Turn legend on or off (ON/OFF) : New Parameter! - - Turn legend on or off (ON/OFF) : New Parameter! - - - - Turn legend on or off (ON/OFF) : New Parameter! - - - Turn legend on or off (ON/OFF) : New Parameter! + name="symbol_height_unit" + values= "cm/geograhical"> + if set to geographical, the height will be interpreted in degres of latitude + + values="number/text/marker/wind/property"> Defines the type of symbol plotting required @@ -264,5 +251,114 @@ 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 : list of colours to use + + + With GeoSon : list of heights to use + + + + With GeoSon : list of colours 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/params/TextVisitor.xml b/src/params/TextVisitor.xml index 54ee230aa..a860b6ae9 100644 --- a/src/params/TextVisitor.xml +++ b/src/params/TextVisitor.xml @@ -7,11 +7,12 @@ granted to it by virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. --> - diff --git a/src/params/TileDecoder.xml b/src/params/TileDecoder.xml index e62d76434..d7ee18159 100644 --- a/src/params/TileDecoder.xml +++ b/src/params/TileDecoder.xml @@ -28,6 +28,11 @@ does it submit to any jurisdiction. default="cylindrical" from="string" name="grib_tile_projection"> + slecet only one member + + Used in the visibility product to define the y value + diff --git a/src/visualisers/Axis.cc b/src/visualisers/Axis.cc index 1e2520016..615d94ee0 100644 --- a/src/visualisers/Axis.cc +++ b/src/visualisers/Axis.cc @@ -389,6 +389,7 @@ void VerticalAxis::label(VerticalAxisVisitor& axis) { + bool out = false; if (magCompare(label_position_, "inter_tick")) { @@ -529,12 +530,47 @@ void VerticalAxis::title(VerticalAxisVisitor& out) { out.push_back(text); } +void HorizontalAxis::highlight(DrawingVisitor& out) const { + if ( highlighted_values_.empty() ) + return; + double bottom = out.minY(); + double top = out.maxY(); + const Transformation& transformation = out.transformation(); + + for ( auto highlight = highlighted_values_.begin(); highlight != highlighted_values_.end(); ++highlight ) { + Polyline* high = new Polyline(); + high->push_back(PaperPoint(transformation.x(*highlight), bottom)); + high->push_back(PaperPoint(transformation.x(*highlight), top)); + high->setColour(*highlighted_values_colour_); + high->setLineStyle(highlighted_values_style_); + high->setThickness(highlighted_values_thickness_); + out.push_back(high); + } +} + + void HorizontalAxis::grid(DrawingVisitor& out) const { double bottom = out.minY(); double top = out.maxY(); + double left = out.minX(); + double right = out.maxX(); double pos; const Transformation& transformation = out.transformation(); + if (!grid_background_colour_->none()) { + Polyline* area = new Polyline(); + area->setColour(*grid_background_colour_); + area->setFilled(true); + area->setShading(new FillShadingProperties()); + area->setFillColour(*grid_background_colour_); + out.push_back(area); + area->push_back(PaperPoint(left, bottom)); + area->push_back(PaperPoint(left, top)); + area->push_back(PaperPoint(right, top)); + area->push_back(PaperPoint(right, bottom)); + area->push_back(PaperPoint(left, bottom)); + } + if (!grid_) { if (grid_reference_level_ != INT_MAX) { for (AxisItems::const_iterator x = items_.begin(); x != items_.end(); ++x) { @@ -597,6 +633,26 @@ void HorizontalAxis::grid(DrawingVisitor& out) const { } } +void VerticalAxis::highlight(DrawingVisitor& out) const { + if ( highlighted_values_.empty() ) + return; + double left = out.minX(); + double right = out.maxX(); + const Transformation& transformation = out.transformation(); + + for ( auto highlight = highlighted_values_.begin(); highlight != highlighted_values_.end(); ++highlight ) { + Polyline* high = new Polyline(); + high->push_back(PaperPoint(left, transformation.y(*highlight))); + high->push_back(PaperPoint(right, transformation.y(*highlight))); + high->setColour(*highlighted_values_colour_); + high->setLineStyle(highlighted_values_style_); + high->setThickness(highlighted_values_thickness_); + out.push_back(high); + } + + +} + void VerticalAxis::grid(DrawingVisitor& out) const { double left = out.minX(); double right = out.maxX(); diff --git a/src/visualisers/Axis.h b/src/visualisers/Axis.h index 1b64f46d7..c3ec33b67 100644 --- a/src/visualisers/Axis.h +++ b/src/visualisers/Axis.h @@ -71,6 +71,9 @@ class Axis : public BasicSceneObject, public AxisAttributes { virtual void grid(DrawingVisitor&) const {} + virtual void highlight(DrawingVisitor&) const {} + + string createLabel(const AxisItem&); double min() const { return method_->min(); } @@ -136,6 +139,7 @@ class HorizontalAxis : public Axis { method_->prepare(*this, items_); } grid(visitor); + highlight(visitor); } void visit(TopAxisVisitor& visitor) override { @@ -167,6 +171,9 @@ class HorizontalAxis : public Axis { void tip(BottomAxisVisitor& out) const override; void grid(DrawingVisitor&) const override; + + void highlight(DrawingVisitor&) const override; + }; class VerticalAxis : public Axis { @@ -192,6 +199,7 @@ class VerticalAxis : public Axis { method_->prepare(*this, items_); } grid(visitor); + highlight(visitor); } void visit(LeftAxisVisitor& visitor) override { if (magCompare(position_, "left")) @@ -220,6 +228,9 @@ class VerticalAxis : public Axis { void tip(RightAxisVisitor& out) const override; void grid(DrawingVisitor&) const override; + + void highlight(DrawingVisitor&) const override; + }; } // namespace magics diff --git a/src/visualisers/BoxPlotVisualiser.cc b/src/visualisers/BoxPlotVisualiser.cc index 37fc16ba1..dae7b8f84 100644 --- a/src/visualisers/BoxPlotVisualiser.cc +++ b/src/visualisers/BoxPlotVisualiser.cc @@ -66,8 +66,8 @@ void BoxPlotVisualiser::operator()(Data& data, BasicGraphicsObjectContainer& vis return; - box_->cm(user); - whisker_->cm(user); + cm_ = user; + for (const auto& point : points) { @@ -80,13 +80,168 @@ void BoxPlotVisualiser::operator()(Data& data, BasicGraphicsObjectContainer& vis } - (*box_)(visitor, *point); + box(visitor, *point); - whisker_->top(visitor, *point); - whisker_->bottom(visitor, *point); + if ( magCompare(whisker_, "line")) { + whisker_line_top(visitor, *point); + whisker_line_bottom(visitor, *point); + } + if ( magCompare(whisker_, "box")) { + whisker_box_top(visitor, *point); + whisker_box_bottom(visitor, *point); + } } + + + } void BoxPlotVisualiser::visit(LegendVisitor&) { // Not Yet! } + + +void BoxPlotVisualiser::box(BasicGraphicsObjectContainer& visitor, const CustomisedPoint& point) const { + if ( !box_) + return; + const Transformation& transformation = visitor.transformation(); + Polyline* box = new Polyline(); + box->setFilled(true); + box->setFillColour(*box_colour_); + box->setShading(new FillShadingProperties()); + + double width = (box_width_ * cm_) / 2; // Could later be expressed in % + CustomisedPoint::const_iterator upper = point.find("upper"); + CustomisedPoint::const_iterator lower = point.find("lower"); + CustomisedPoint::const_iterator x = point.find("x"); + if (x == point.end() || upper == point.end() || lower == point.end()) + return; + box->push_back(transformation(UserPoint(x->second - width, upper->second))); + box->push_back(transformation(UserPoint(x->second + width, upper->second))); + box->push_back(transformation(UserPoint(x->second + width, lower->second))); + box->push_back(transformation(UserPoint(x->second - width, lower->second))); + box->push_back(transformation(UserPoint(x->second - width, upper->second))); + + box_border(*box); + visitor.push_back(box); + + CustomisedPoint::const_iterator median = point.find("median"); + + if (median == point.end()) + return; + + if ( median_ ) { + Polyline* line = new Polyline(); + + line->push_back(transformation(UserPoint(x->second - width, median->second))); + line->push_back(transformation(UserPoint(x->second + width, median->second))); + + line->setColour(*median_colour_); + line->setLineStyle(median_style_); + line->setThickness(median_thickness_); + visitor.push_back(line); + } +} + +void BoxPlotVisualiser::box_border(Polyline& box) const { + if (!box_border_) + return; + box.setColour(*box_border_colour_); + box.setLineStyle(box_border_style_); + box.setThickness(box_border_thickness_); +} + + + + +void BoxPlotVisualiser::whisker_box_top(BasicGraphicsObjectContainer& visitor, const CustomisedPoint& point) const { + const Transformation& transformation = visitor.transformation(); + Polyline* whisker = new Polyline(); + whisker->setFilled(true); + whisker->setFillColour(*whisker_box_colour_); + whisker->setShading(new FillShadingProperties()); + double width = (whisker_box_width_ * cm_) / 2; // Could later be expressed in % + CustomisedPoint::const_iterator max = point.find("max"); + CustomisedPoint::const_iterator upper = point.find("upper"); + CustomisedPoint::const_iterator x = point.find("x"); + if (x == point.end() || max == point.end() || upper == point.end()) + return; + whisker->push_back(transformation(UserPoint(x->second - width, max->second))); + whisker->push_back(transformation(UserPoint(x->second + width, max->second))); + whisker->push_back(transformation(UserPoint(x->second + width, upper->second))); + whisker->push_back(transformation(UserPoint(x->second - width, upper->second))); + whisker->push_back(transformation(UserPoint(x->second - width, max->second))); + + whisker_border(*whisker); + visitor.push_back(whisker); +} + +void BoxPlotVisualiser::whisker_box_bottom(BasicGraphicsObjectContainer& visitor, const CustomisedPoint& point) const { + + const Transformation& transformation = visitor.transformation(); + Polyline* whisker = new Polyline(); + whisker->setFilled(true); + whisker->setFillColour(*whisker_box_colour_); + whisker->setShading(new FillShadingProperties()); + double width = (whisker_box_width_ * cm_) / 2; // Could later be expressed in % + CustomisedPoint::const_iterator min = point.find("min"); + CustomisedPoint::const_iterator lower = point.find("lower"); + CustomisedPoint::const_iterator x = point.find("x"); + if (x == point.end() || min == point.end() || lower == point.end()) + return; + whisker->push_back(transformation(UserPoint(x->second - width, min->second))); + whisker->push_back(transformation(UserPoint(x->second + width, min->second))); + whisker->push_back(transformation(UserPoint(x->second + width, lower->second))); + whisker->push_back(transformation(UserPoint(x->second - width, lower->second))); + whisker->push_back(transformation(UserPoint(x->second - width, min->second))); + + whisker_border(*whisker); + visitor.push_back(whisker); +} + + +void BoxPlotVisualiser::whisker_line_top(BasicGraphicsObjectContainer& visitor, const CustomisedPoint& point) const { + const Transformation& transformation = visitor.transformation(); + Polyline* whisker = new Polyline(); + whisker->setColour(*whisker_line_colour_); + whisker->setLineStyle(whisker_line_style_); + whisker->setThickness(whisker_line_thickness_); + + CustomisedPoint::const_iterator max = point.find("max"); + CustomisedPoint::const_iterator upper = point.find("upper"); + CustomisedPoint::const_iterator x = point.find("x"); + if (x == point.end() || max == point.end() || upper == point.end()) + return; + whisker->push_back(transformation(UserPoint(x->second, max->second))); + whisker->push_back(transformation(UserPoint(x->second, upper->second))); + + + visitor.push_back(whisker); +} + +void BoxPlotVisualiser::whisker_line_bottom(BasicGraphicsObjectContainer& visitor, const CustomisedPoint& point) const { + const Transformation& transformation = visitor.transformation(); + Polyline* whisker = new Polyline(); + whisker->setColour(*whisker_line_colour_); + whisker->setLineStyle(whisker_line_style_); + whisker->setThickness(whisker_line_thickness_); + + CustomisedPoint::const_iterator min = point.find("min"); + CustomisedPoint::const_iterator lower = point.find("lower"); + CustomisedPoint::const_iterator x = point.find("x"); + if (x == point.end() || min == point.end() || lower == point.end()) + return; + whisker->push_back(transformation(UserPoint(x->second, min->second))); + whisker->push_back(transformation(UserPoint(x->second, lower->second))); + + + visitor.push_back(whisker); +} + +void BoxPlotVisualiser::whisker_border(Polyline& whisker) const { + if ( ! whisker_box_border_ ) + return; + whisker.setColour(*whisker_box_border_colour_); + whisker.setLineStyle(whisker_box_border_style_); + whisker.setThickness(whisker_box_border_thickness_); +} \ No newline at end of file diff --git a/src/visualisers/BoxPlotVisualiser.h b/src/visualisers/BoxPlotVisualiser.h index c738d120a..a6919b056 100644 --- a/src/visualisers/BoxPlotVisualiser.h +++ b/src/visualisers/BoxPlotVisualiser.h @@ -57,7 +57,15 @@ class BoxPlotVisualiser : public BoxPlotVisualiserAttributes, public Visdef { virtual void print(ostream&) const override; double resolution_; - + void box(BasicGraphicsObjectContainer& visitor, const CustomisedPoint& point) const; + void box_border(Polyline&) const; + void whisker_line_top(BasicGraphicsObjectContainer&, const CustomisedPoint&) const; + void whisker_line_bottom(BasicGraphicsObjectContainer&, const CustomisedPoint&) const; + void whisker_box_top(BasicGraphicsObjectContainer&, const CustomisedPoint&) const; + void whisker_box_bottom(BasicGraphicsObjectContainer&, const CustomisedPoint&) const; + void whisker_border(Polyline&) const; + + double cm_; private: //! Copy constructor - No copy allowed BoxPlotVisualiser(const BoxPlotVisualiser&); diff --git a/src/visualisers/CMakeLists.txt b/src/visualisers/CMakeLists.txt index 4923f16b1..9b90eae1f 100644 --- a/src/visualisers/CMakeLists.txt +++ b/src/visualisers/CMakeLists.txt @@ -22,9 +22,6 @@ Bar.h BothValuePlotMethod.h Boundaries.cc Boundaries.h -BoxPlotBasicItem.h -BoxPlotItem.cc -BoxPlotItem.h BoxPlotVisualiser.cc BoxPlotVisualiser.h CalculateColourTechnique.cc diff --git a/src/visualisers/CalcStreamlines.cc b/src/visualisers/CalcStreamlines.cc index c47db9bed..3171f4b0b 100644 --- a/src/visualisers/CalcStreamlines.cc +++ b/src/visualisers/CalcStreamlines.cc @@ -24,6 +24,8 @@ #include #include #include +#include +#include #include "CalcStreamlines.h" @@ -798,3 +800,188 @@ int CalcStreamlines(int density, const float* dir, const GSStruct* gs, OneLineCl return 1; } + + + +namespace { +// Utility function used only for the streamline point order adjustments. +// Computes the nearest valid value to the specified x,y coordintes. Field vals defined on the same +// regular gs grid that is used for the streamline computations. The accepted grid structure is +// rather restrictive!!! +bool nearestValidValue(float x, float y, const GSStruct* gs, const float* vals, float& resVal) +{ + assert (gs->dy>0.); + assert (gs->dx>0.); + assert (gs->period_x==0); + assert (gs->gs_geo==0); + + if (gs->dx<=0 || gs->dy <=0 || gs->period_x != 0 || gs->gs_geo != 0) { + return false; + } + + int num = gs->nx * gs->ny; + +#if 0 + std::cout << "\n nearestValidValue" << std::endl; + std::cout << "startx=" << gs->startx << " starty=" << gs->starty << " dx=" << gs->dx << " dy=" << gs->dy << std::endl; + std::cout << "x=" << x << " y=" << y << std::endl; +#endif + auto startX = gs->startx; + auto startY = gs->starty; + + //-- index for column on the west + int ix1 = int((x - startX) / gs->dx); + if (ix1 > (gs->nx - 1) || ix1 < 0) { + return false; + } + + //-- index for column on the east + int ix2 = ix1 + 1; + if (ix2 > (gs->nx - 1) || ix2 < 0) { + return false; + } + + // NS + int iy1 = int((y - startY) / gs->dy); + int iy2 = iy1 + 1; + if (iy2 > (gs->ny - 1) || iy2 < 0 ) { + return false; + } + if (iy2 > (gs->ny - 1) || iy2 < 0 ) { + return false; + } + + std::vector valVec, distVec; + + // point 11 + int index = gs->nx * iy1 + ix1; + if (index <0 || index >= num) { + return false; + } + float val = vals[index]; + if (val == val) { + valVec.push_back(val); + float dx = x - gs->startx + ix1 * gs->dx; + float dy = y - gs->starty + iy1 * gs->dy; + distVec.push_back(dx*dx + dy*dy); + } + + // point 12 + index = gs->nx * iy1 + ix2; + val = vals[index]; + if (index <0 || index >= num) { + return false; + } + if (val == val) { + valVec.push_back(val); + float dx = x - gs->startx + ix2 * gs->dx; + float dy = y - gs->starty + iy1 * gs->dy; + distVec.push_back(dx*dx + dy*dy); + } + + // point 21 + index = gs->nx * iy2 + ix1; + val = vals[index]; + if (index <0 || index >= num) { + return false; + } + if (val == val) { + valVec.push_back(val); + float dx = x - gs->startx + ix1 * gs->dx; + float dy = y - gs->starty + iy2 * gs->dy; + distVec.push_back(dx*dx + dy*dy); + } + + // point 22 + index = gs->nx * iy2 + ix2; + val = vals[index]; + if (index <0 || index >= num) { + return false; + } + if (val == val) { + valVec.push_back(val); + float dx = x - gs->startx + ix2 * gs->dx; + float dy = y - gs->starty + iy2 * gs->dy; + distVec.push_back(dx*dx + dy*dy); + } + + if (!distVec.empty()) { + std::vector idxVec(distVec.size()); + std::iota(idxVec.begin(), idxVec.end(), 0); + std::sort(idxVec.begin(), idxVec.end(), + [&distVec](size_t i1, size_t i2) { return(distVec[i1] < distVec[i2]);}); + + resVal = valVec[idxVec.front()]; + return true; + } + return false; +} + +} + +// Adjust the order of the streamline points so that they can follow the wind field direction. +// It must be called after the streamlines were computed and the polyline clipping was already applied. +// See JIRA issue MAGP-1349 for details. +// Args: +// dir: wind direction field +// gs: grid structure +// poly: the streamline with projected coordinates +// polyUnprojected: the streamline with unrojected coordinates +// Retval: +// true if the adjustment could be performed +bool AdjustStreamlinesDirection(const float* dir, const GSStruct* gs, magics::Polyline* poly, magics::Polyline* polyUnprojected) +{ + if (!dir || !gs || !poly || !polyUnprojected) + return false; + + assert(poly->size() == polyUnprojected->size()); + if (poly->size() != polyUnprojected->size()) { + return false; + } + + if (poly->size() > 2) { + int swapCnt=0; + int cnt = 0; + for (int i=0; i < std::min(5, static_cast(polyUnprojected->size())-1); i++) { + auto x1 = polyUnprojected->get(i).x(); + auto y1 = polyUnprojected->get(i).y(); + auto x2 = polyUnprojected->get(i+1).x(); + auto y2 = polyUnprojected->get(i+1).y(); + float resVal=0.; + + // get the nearest wind direction value + if (nearestValidValue(x1, y1, gs, dir,resVal)) + { + // vector along the line + auto dx = x2 - x1; + auto dy = y2 - y1; + + // in the input field (vals) the wind direction is the angle of the wind vector measured + // from N in clockwise direction. We need to convert it to the standard + // polar vector angle (measured from E in anti-clockwise direction). + auto wDir = 2.5 * M_PI - resVal; + + // normalised wind vector + auto wDx = cos(wDir); + auto wDy = sin(wDir); + + // compute the scalar product between the wind vector and line vector and use the + // sign of it to decide whether they point in the same direction + auto sp = dx*wDx + dy*wDy; + swapCnt += (sp < 0)?1:-1; + cnt++; +#if 0 + std::cout << i << " resVal=" << resVal << " x1=" << x1 << " y1=" << y1 << + " dx=" << dx << " dy=" << dy << " wDir=" << wDir << " sp=" << sp << + std::endl; +#endif + } + } + if (cnt == 0) { + return false; + } else if (swapCnt > 0) { + poly->reverse(); + } + } + return true; +} diff --git a/src/visualisers/CalcStreamlines.h b/src/visualisers/CalcStreamlines.h index f6ce0b4d2..d76f54bfa 100644 --- a/src/visualisers/CalcStreamlines.h +++ b/src/visualisers/CalcStreamlines.h @@ -22,6 +22,7 @@ #ifndef CalcStreamlines_h #define CalcStreamlines_h +#include "Polyline.h" // Shift the value between 'xstart' and 'xstart+period' // -> x in [xstart,xstart+period] @@ -79,6 +80,6 @@ class OneLineClass { // Streamline calculator function int CalcStreamlines(int density, const float* dir, const GSStruct* gs, OneLineClass**& str_lines, int& linenum); - +bool AdjustStreamlinesDirection(const float* dir, const GSStruct* gs, magics::Polyline* poly, magics::Polyline* polyUnprojected); #endif diff --git a/src/visualisers/CalculateColourTechnique.h b/src/visualisers/CalculateColourTechnique.h index 392ae13a1..522e3aba8 100644 --- a/src/visualisers/CalculateColourTechnique.h +++ b/src/visualisers/CalculateColourTechnique.h @@ -39,6 +39,11 @@ class CalculateColourTechnique : public ColourTechnique, public CalculateColourT void set(const ColourTechniqueInterface&) override; + void copy(const CalculateColourTechnique&) { + CalculateColourTechniqueAttributes::copy(*this); + ColourTechniqueAttributes::copy(*this); + } + virtual ColourTechnique* clone() const override { CalculateColourTechnique* object = new CalculateColourTechnique(); diff --git a/src/visualisers/ColourTechnique.h b/src/visualisers/ColourTechnique.h index 99e915e00..bfc794c19 100644 --- a/src/visualisers/ColourTechnique.h +++ b/src/visualisers/ColourTechnique.h @@ -59,7 +59,8 @@ class ColourTechniqueInterface { }; -class ColourTechnique : public map { +class ColourTechnique : public map, + public ColourTechniqueAttributes { public: ColourTechnique(); virtual ~ColourTechnique(); @@ -124,6 +125,13 @@ class PaletteColourTechnique : public ColourTechnique, void set(const ColourTechniqueInterface&) override; + virtual void copy(const PaletteColourTechnique&) { + PaletteColourTechniqueAttributes::copy(*this); + ColourTechniqueAttributes::copy(*this); + } + + + virtual ColourTechnique* clone() const override { PaletteColourTechnique* object = new PaletteColourTechnique(); diff --git a/src/visualisers/EpsGraph.cc b/src/visualisers/EpsGraph.cc index a80ab7a69..1998281f2 100644 --- a/src/visualisers/EpsGraph.cc +++ b/src/visualisers/EpsGraph.cc @@ -627,6 +627,10 @@ magics::Polyline* EpsGraph::newForecast() { } void EpsGraph::pushControl(magics::Polyline* control, BasicGraphicsObjectContainer& visitor) { + if ( !eps_control_ ) { + control_ = false; + return; + } const Transformation& transformation = visitor.transformation(); if (!control->empty() && whisker_) { transformation(*control, visitor); @@ -1689,17 +1693,19 @@ void EpsWave::operator()(Data& data, BasicGraphicsObjectContainer& visitor) { } // Draw the Control - if (point->find("control") != point->end()) { - magics::Polyline* control = new magics::Polyline(); - control->setColour(Colour("red")); - control->setThickness(2); - control->setLineStyle(LineStyle::DASH); - - double angle = (*point)["control"] - 180.; - - control->push_back(PaperPoint(x, 0)); - control->push_back(PaperPoint(x + (l100 * sin(angle * (3.14 / 180.))), l100 * cos(angle * (3.14 / 180.)))); - visitor.push_back(control); + if (eps_control_) { + if (point->find("control") != point->end()) { + magics::Polyline* control = new magics::Polyline(); + control->setColour(Colour("red")); + control->setThickness(2); + control->setLineStyle(LineStyle::DASH); + + double angle = (*point)["control"] - 180.; + + control->push_back(PaperPoint(x, 0)); + control->push_back(PaperPoint(x + (l100 * sin(angle * (3.14 / 180.))), l100 * cos(angle * (3.14 / 180.)))); + visitor.push_back(control); + } } // Draw the Forecast @@ -2487,6 +2493,13 @@ void EpsPlume::visit(LegendVisitor& legend) { median->setLineStyle(median_line_style_); legend.add(new LineEntry("Median", median)); } + // if (percentiles_) { + // magics::Polyline* median = new magics::Polyline(); + // median->setColour(*median_line_colour_); + // median->setThickness(median_line_thickness_); + // median->setLineStyle(median_line_style_); + // legend.add(new LineEntry("Median", median)); + // } } void EpsPlume::timeserie(Data& data, BasicGraphicsObjectContainer& visitor) { @@ -2515,11 +2528,21 @@ void EpsPlume::timeserie(Data& data, BasicGraphicsObjectContainer& visitor) { median->setColour(*median_line_colour_); median->setThickness(median_line_thickness_); median->setLineStyle(median_line_style_); + + + map> shading; + map> percentiles; + if (shading_) { for (vector::iterator level = shading_levels_.begin(); level != shading_levels_.end(); ++level) shading.insert(make_pair(*level, vector())); } + if (percentiles_) { + for (vector::iterator level = percentiles_list_.begin(); level != percentiles_list_.end(); ++level) { + percentiles.insert(make_pair(*level, vector())); + } + } for (const auto& point : points) { double x = (*point)["step"] + (*point)["shift"]; double missing = (*point)["missing"]; @@ -2559,6 +2582,11 @@ void EpsPlume::timeserie(Data& data, BasicGraphicsObjectContainer& visitor) { std::sort(members.begin(), members.end()); median->push_back(PaperPoint(x, members[m])); } + if (percentiles_) { + int m = members.size()/2; + std::sort(members.begin(), members.end()); + median->push_back(PaperPoint(x, members[m])); + } if (shading_) { for (vector::iterator level = shading_levels_.begin(); level != shading_levels_.end(); ++level) { int i = *level * (members.size()/100.); @@ -2567,7 +2595,16 @@ void EpsPlume::timeserie(Data& data, BasicGraphicsObjectContainer& visitor) { shading[*level].push_back(PaperPoint(x, members[i])); } } + if (percentiles_) { + for (vector::iterator level = percentiles_list_.begin(); level != percentiles_list_.end(); ++level) { + int i = *level * (members.size()/100.); + if (i >= members.size()) + i = members.size() - 1; + percentiles[*level].push_back(PaperPoint(x, members[i])); + } + } } + vector::iterator colour = shading_colours_.begin(); @@ -2588,9 +2625,10 @@ void EpsPlume::timeserie(Data& data, BasicGraphicsObjectContainer& visitor) { for (vector::reverse_iterator point = shading[top].rbegin(); point != shading[top].rend(); ++point) line->push_back(*point); - double grey = ((col.red() + col.blue() + col.green()) / 3.); - - col.setColour(grey, grey, grey); + if ( legend_grey_style_ ) { + double grey = ((col.red() + col.blue() + col.green()) / 3.); + col.setColour(grey, grey, grey); + } ++colour; shading_legend_.push_back(col); @@ -2605,6 +2643,36 @@ void EpsPlume::timeserie(Data& data, BasicGraphicsObjectContainer& visitor) { transformation(*forecast, visitor); if (median_) transformation(*median, visitor); + if (percentiles_) { + if ( percentiles_line_colour_list_.empty() ) + percentiles_line_colour_list_.push_back("black"); + if ( percentiles_line_thickness_list_.empty() ) + percentiles_line_thickness_list_.push_back(2); + if ( percentiles_line_style_list_.empty() ) + percentiles_line_style_list_.push_back("solid"); + + auto percentiles_line_colour = percentiles_line_colour_list_.begin(); + auto percentiles_line_thickness = percentiles_line_thickness_list_.begin(); + auto percentiles_line_style = percentiles_line_style_list_.begin(); + + for ( auto percentile = percentiles.begin(); percentile != percentiles.end (); ++percentile ) { + magics::Polyline* line = new magics::Polyline(); + line->setColour(Colour(*percentiles_line_colour)); + line->setLineStyle(MagTranslator()(*percentiles_line_style)); + line->setThickness(*percentiles_line_thickness); + + if (++percentiles_line_colour == percentiles_line_colour_list_.end() ) --percentiles_line_colour; + if (++percentiles_line_thickness == percentiles_line_thickness_list_.end() ) --percentiles_line_thickness; + if (++percentiles_line_style == percentiles_line_style_list_.end() ) --percentiles_line_style; + + for (vector::iterator point = percentile->second.begin(); point != percentile->second.end(); ++point) + line->push_back(*point); + + transformation(*line, visitor); + } + + + } } void EpsPlume::verticalprofile(Data& data, BasicGraphicsObjectContainer& visitor) { @@ -2660,7 +2728,82 @@ void EpsPlume::verticalprofile(Data& data, BasicGraphicsObjectContainer& visitor visitor.push_back(control); visitor.push_back(forecast); } + +void EpsPlume::background(BasicGraphicsObjectContainer& visitor) { + // Add background + const Transformation& transformation = visitor.transformation(); + if ( background_level_list_.empty() ) + return; + + if ( background_colour_list_.size() < background_level_list_.size() -1 ) { + MagLog::error() << "Note enough colours for the EpsPlumes background " << endl; + MagLog::error() << "should be at least " << background_level_list_.size() -1 << " but found " << background_colour_list_.size() << endl; + MagLog::error() << " Please check your colour list " << endl; + return; + } + + + + double min = transformation.getMinY(); + double max = transformation.getMaxY(); + + auto colour = background_colour_list_.begin(); + + auto level = background_level_list_.begin(); + auto label = background_label_list_.begin(); + double from = *level; + ++level; + + while ( level != background_level_list_.end()) { + double to = *level; + if ( from < min ) + from = min; + if ( to > max ) + to = max; + + if ( to > from && to <= max ) { + Polyline* area = new Polyline(); + area->setColour(Colour(*colour)); + area->setFilled(true); + area->setShading(new FillShadingProperties()); + area->setFillColour(Colour(*colour)); + visitor.push_back(area); + area->push_back(PaperPoint(transformation.getMinX(), from)); + area->push_back(PaperPoint(transformation.getMinX(), to)); + area->push_back(PaperPoint(transformation.getMaxX(), to)); + area->push_back(PaperPoint(transformation.getMaxX(), from)); + area->push_back(PaperPoint(transformation.getMinX(), from)); + + + } + double shift =(transformation.getMaxY() - transformation.getMinY())*0.02; + + if ( label != background_label_list_.end() ) { + + Text* text = new Text(); + text->setText(*label); + text->setJustification(Justification::LEFT); + MagFont font(background_label_font_, background_label_font_style_, background_label_font_size_); + font.colour(*background_label_font_colour_); + text->setFont(font); + double x = transformation.getMinX() + (transformation.getMaxX() - transformation.getMinX())*0.01; + + double y = from + shift; + if ( y < transformation.getMaxY() ) + text->push_back(PaperPoint(x, y)); + visitor.push_back(text); + ++label; + } + from = *level; + ++colour; + ++level; + } + + +} + void EpsPlume::operator()(Data& data, BasicGraphicsObjectContainer& visitor) { + background(visitor); method_ = lowerCase(method_); std::map::iterator method = methods_.find(method_); if (method == methods_.end()) { @@ -2668,6 +2811,7 @@ void EpsPlume::operator()(Data& data, BasicGraphicsObjectContainer& visitor) { return; } (this->*method->second)(data, visitor); + } diff --git a/src/visualisers/EpsGraph.h b/src/visualisers/EpsGraph.h index 1c70ea878..0d7854fea 100644 --- a/src/visualisers/EpsGraph.h +++ b/src/visualisers/EpsGraph.h @@ -34,6 +34,7 @@ #include "EpsPlumeAttributes.h" #include "EpsShadeAttributes.h" #include "EpsWindAttributes.h" +#include "EpsWaveAttributes.h" #include "BasicGraphicsObject.h" @@ -257,13 +258,13 @@ class EpsBar : public Visdef, public EpsCloudAttributes { } }; -class EpsWave : public Visdef { +class EpsWave : public EpsWaveAttributes, public Visdef { public: EpsWave() {} virtual ~EpsWave() override {} // Implements the set method ... - void set(const map&) {} // EpsWindAttributes::set(map); } - void set(const XmlNode&) {} // EpsWindAttributes::set(node); } + void set(const map& map) override { EpsWaveAttributes::set(map); } // EpsWindAttributes::set(map); } + void set(const XmlNode& node) override { EpsWaveAttributes::set(node) ;} // EpsWindAttributes::set(node); } virtual void operator()(Data&, BasicGraphicsObjectContainer&) override; virtual void visit(LegendVisitor&) override; @@ -437,7 +438,7 @@ class EpsPlume : public Visdef, public EpsPlumeAttributes { vector shading_legend_; void timeserie(Data&, BasicGraphicsObjectContainer&); void verticalprofile(Data&, BasicGraphicsObjectContainer&); - + void background(BasicGraphicsObjectContainer& visitor); private: //! Copy constructor - No copy allowed EpsPlume(const EpsPlume&); diff --git a/src/visualisers/GradientsColourTechnique.h b/src/visualisers/GradientsColourTechnique.h index b56af53f5..defd94808 100644 --- a/src/visualisers/GradientsColourTechnique.h +++ b/src/visualisers/GradientsColourTechnique.h @@ -38,6 +38,12 @@ class GradientsColourTechnique : public ColourTechnique, public GradientsColourT bool accept(const string& node) override { return GradientsColourTechniqueAttributes::accept(node); } void set(const ColourTechniqueInterface&) override; + + void copy(const GradientsColourTechnique&) { + GradientsColourTechniqueAttributes::copy(*this); + ColourTechniqueAttributes::copy(*this); + } + virtual ColourTechnique* clone() const override { diff --git a/src/visualisers/IsoShading.h b/src/visualisers/IsoShading.h index ff1d8e7e2..641c2afd1 100644 --- a/src/visualisers/IsoShading.h +++ b/src/visualisers/IsoShading.h @@ -76,6 +76,7 @@ class NoIsoShading { virtual bool needClipping() { return false; } virtual bool method(ContourMethod*) { return false; } virtual void reset() {} + virtual bool isShading() { return false; } protected: //! Method to print string about this class on to a stream of type ostream (virtual). @@ -109,6 +110,8 @@ class IsoShading : public NoIsoShading, public IsoShadingAttributes { object->copy(*this); return object; } + + bool isShading() override { return true; } CellArray* array(MatrixHandler& matrix, IntervalMap& range, const Transformation& transformation, int width, int height, float resolution, const string& technique) override { @@ -129,20 +132,15 @@ class IsoShading : public NoIsoShading, public IsoShadingAttributes { virtual bool needClipping() override { return (*this->technique_).needClipping(); } virtual bool operator()(LevelSelection& list) override { - LevelSelection filter; - for (LevelSelection::const_iterator level = list.begin(); level != list.end(); ++level) - if (this->min_ <= *level && *level <= this->max_) - filter.push_back(*level); - (*this->colourMethod_).prepare(list, filter); + (*this->colourMethod_).prepare(list, list); + if (!list.empty() && (list.back() == list.front())) + list.push_back(list.front()); - if (!filter.empty() && (filter.back() == filter.front())) - filter.push_back(filter.front()); - - return (*this->technique_).prepare(filter, *this->colourMethod_); + return (*this->technique_).prepare(list, *this->colourMethod_); } // returns true, if the contouring lines have to be created... False, is the shading is finished... virtual void visit(LegendVisitor& legend) override { diff --git a/src/visualisers/ListColourTechnique.h b/src/visualisers/ListColourTechnique.h index 789f90441..c71465377 100644 --- a/src/visualisers/ListColourTechnique.h +++ b/src/visualisers/ListColourTechnique.h @@ -41,6 +41,12 @@ class ListColourTechnique : public ColourTechnique, public ListColourTechniqueAt object->copy(*this); return object; } + void copy(const ListColourTechnique&) { + ListColourTechniqueAttributes::copy(*this); + ColourTechniqueAttributes::copy(*this); + } + + virtual void set(LevelSelection&, LevelSelection&, ColourTable&, int) override; void set(const ColourTechniqueInterface&) override; diff --git a/src/visualisers/ObsItemFamily.cc b/src/visualisers/ObsItemFamily.cc index 0cfa52e18..3ecac4daf 100644 --- a/src/visualisers/ObsItemFamily.cc +++ b/src/visualisers/ObsItemFamily.cc @@ -41,6 +41,15 @@ void ObsItemBox::set(const map& def) { key_ = find(def, "key", ""); format_ = find(def, "format", ""); justification_ = translate(find(def, "justification", "centre")); + +} + +void ObsWind::set(const map& def) { + row_ = atoi(find(def, "row").c_str()); + column_ = atoi(find(def, "column").c_str()); + colour_ = find(def, "colour"); + speed_ = find(def, "wind_speed", "wind_speed"); + direction_ = find(def, "wind_direction", "wind_direction"); } @@ -53,6 +62,8 @@ void ObsWind::visit(std::set& tokens) { return; tokens.insert(speed_); tokens.insert(direction_); + + } void ObsWind::operator()(CustomisedPoint& point, ComplexSymbol& symbol) const { if (!owner_->wind_visible_) @@ -60,10 +71,10 @@ void ObsWind::operator()(CustomisedPoint& point, ComplexSymbol& symbol) const { map::iterator it = point.begin(); map::iterator en = point.end(); - // for (; it != en; ++it) { - // F MagLog::debug() << " >>> " << it->first << " -> " << it->second << endl; - // F} - Colour colour = owner_->wind_colour_->automatic() ? *owner_->colour_ : *owner_->wind_colour_; + + string colouring = (colour_.size() ) ? colour_ : owner_->wind_colour_; + Colour colour; + CustomisedPoint::const_iterator speed = point.find(speed_); if (speed == point.end()) @@ -71,17 +82,32 @@ void ObsWind::operator()(CustomisedPoint& point, ComplexSymbol& symbol) const { CustomisedPoint::const_iterator direction = point.find(direction_); if (direction == point.end()) return; + + if ( magCompare(colouring, "automatic") ) + colour = *owner_->colour_; + if ( magCompare(colouring, "coloured_wind") ) + { + if ( speed->second < 1. ) + colour = Colour("green"); + if ( speed->second > 1.5 && speed->second <2 ) + colour = Colour("yellow"); + if ( speed->second > 2.5 && speed->second <3 ) + colour = Colour("orange"); + if ( speed->second > 3.5 && speed->second <4 ) + colour = Colour("red"); + if ( speed->second > 4 ) + colour = Colour("purple"); + } + else { + colour = Colour(owner_->wind_colour_); + } FlagItem* flag = new FlagItem(); flag->setColour(colour); + flag->setThickness(owner_->wind_thickness_); flag->length(owner_->size_ * 2.5); // Size to be adjusted later! - const string origin = "circle"; - - - // FMagLog::debug() << "OBS ITEM - ObsWind - Lon/Lat: " << point.longitude() << " / " << point.latitude() - // F << "\n\twind_speed: " << point[speed_] << "\n\twind_direction: " << point[direction_] - // F << "\n\tcloud amount: " << point["total_cloud"] << " -> " << origin << std::endl; + const string origin = "circle"; // Duck for hackathon flag->setOriginHeight(owner_->ring_size_); @@ -124,18 +150,18 @@ void ObsCloudAndWind::setOrigins() { void ObsCloudAndWind::operator()(CustomisedPoint& point, ComplexSymbol& symbol) const { if (!owner_->wind_visible_) return; + + + string colouring = owner_->wind_colour_; + Colour colour; - Colour colour = owner_->wind_colour_->automatic() ? *owner_->colour_ : *owner_->wind_colour_; map::iterator it = point.begin(); map::iterator en = point.end(); - // Ffor (; it != en; ++it) { - // F MagLog::debug() << " >>> " << it->first << " -> " << it->second << endl; - // F} + symbol.setHeight(owner_->size_); int total_cloud = maground((point["total_cloud"] / 100.) * 8); - // FMagLog::debug() << "total_cloud-->" << point["total_cloud"] << "--->" << total_cloud << endl; map::const_iterator marker = origins_.find(total_cloud); string origin; @@ -152,6 +178,26 @@ void ObsCloudAndWind::operator()(CustomisedPoint& point, ComplexSymbol& symbol) CustomisedPoint::const_iterator idirection = point.find("wind_direction"); double direction = (idirection == point.end()) ? 0 : idirection->second; + if ( magCompare(colouring, "automatic") ) + colour = *owner_->colour_; + if ( magCompare(colouring, "coloured_wind") ) + { + if ( speed < 1. ) + colour = Colour("green"); + if ( speed > 1.5 && speed <2 ) + colour = Colour("yellow"); + if ( speed > 2.5 && speed <3 ) + colour = Colour("orange"); + if ( speed > 3.5 && speed <4 ) + colour = Colour("red"); + if ( speed > 4 ) + colour = Colour("purple"); + } + else { + colour = Colour(owner_->wind_colour_); + } + + if (speed == 0 && direction == 0) { // No wind information ...Just plot the nebulosity SymbolItem* object = new SymbolItem(); @@ -176,11 +222,7 @@ void ObsCloudAndWind::operator()(CustomisedPoint& point, ComplexSymbol& symbol) flag->thickness(1.5); - // FMagLog::debug() << "OBS ITEM - ObsWind - Lon/Lat: " << point.longitude() << " / " << point.latitude() - // F << "\n\twind_speed: " << point["wind_speed"] - // F << "\n\twind_direction: " << point["wind_direction"] - // F << "\n\tcloud amount: " << point["total_cloud"] << "--->" << total_cloud << "--->" << origin - // F << std::endl; + flag->setOriginHeight(owner_->ring_size_ * 1.75); flag->setOriginMarker(origin); @@ -234,7 +276,6 @@ void ObsPressure::operator()(CustomisedPoint& point, ComplexSymbol& symbol) cons object->text(os.str()); - // FMagLog::debug() << "\tPressure: " << value->second << " = " << pressure << " -> " << os.str() << "\n"; object->font(font); symbol.add(object); @@ -319,7 +360,6 @@ void ObsPressureTendency::operator()(CustomisedPoint& point, ComplexSymbol& symb oss << "a_" << value->second; tendancy->symbol(oss.str()); - // FMagLog::debug() << "\tPressure tendency--->" << oss.str() << "\n"; tendancy->height(owner_->size_ * 0.8); // A bit too big ! symbol.add(tendancy); @@ -349,7 +389,6 @@ void ObsDewPoint::operator()(CustomisedPoint& point, ComplexSymbol& symbol) cons // The temperature is displayed in Celsius. const double tempe = maground(value->second - 273.15); - // FMagLog::debug() << "\tDewPoint--->" << point["dewpoint_2meters"] << " = " << tempe << "\n"; object->text(tostring(tempe)); object->font(font); @@ -395,7 +434,6 @@ void ObsVisibility::operator()(CustomisedPoint& point, ComplexSymbol& symbol) co object->text(val); - // FMagLog::debug() << "\tVisibility: " << vv << " = " << val << "\n"; font.size(owner_->size_); object->font(font); @@ -412,6 +450,23 @@ void ObsPresentWeather::visit(std::set& tokens) { static map presentweather; void ObsPresentWeather::operator()(CustomisedPoint& point, ComplexSymbol& symbol) const { + vector colour_list = { "none", "none", "none", "none", "cream", "cream", "cream", "cream", +"cream", "cream","yellow", "yellow", "yellow", "red", "kelly_green", +"kelly_green", "kelly_green", "red", "red", "red", "kelly_green", +"kelly_green", "white", "white", "red", "kelly_green", "white", +"red", "yellow", "red", "cream", "cream", "cream", "cream", "cream", +"cream", "white", "white", "white", "white", "yellow", "yellow", +"yellow", "yellow", "yellow", "yellow", "yellow", "yellow", "yellow", +"yellow", "kelly_green", "kelly_green", "kelly_green", "kelly_green", +"kelly_green", "kelly_green", "red", "red", "kelly_green", +"kelly_green", "kelly_green", "kelly_green", "kelly_green", +"kelly_green", "kelly_green", "kelly_green", "red", "red", "white", +"white", "white", "white","white", "white", "white", "white", "red", +"red", "red", "orange", "kelly_green", "kelly_green", "kelly_green", +"white", "white","white", "white", "red", "red", "red", "red", "red", +"red", "red", "red", "red", "red", "red", "red", "red"}; + + if (!owner_->present_ww_visible_) return; if (presentweather.empty()) { @@ -448,6 +503,7 @@ void ObsPresentWeather::operator()(CustomisedPoint& point, ComplexSymbol& symbol presentweather[183] = "ww_81"; presentweather[189] = "ww_89"; } + CustomisedPoint::const_iterator value = point.find("present_weather"); if (value == point.end()) return; @@ -457,10 +513,19 @@ void ObsPresentWeather::operator()(CustomisedPoint& point, ComplexSymbol& symbol return; string ww; + string colour = owner_->present_ww_colour_; + + if ( magCompare(colour, "automatic") ) + colour = owner_->colour_->name(); + + + if (value->second < 100) { ostringstream os; os << "ww_" << setw(2) << setfill('0') << value->second; ww = os.str(); + if ( magCompare(colour, "coloured_present_weather") ) + colour = colour_list[value->second]; } else { map::iterator w = presentweather.find(value->second); @@ -471,20 +536,15 @@ void ObsPresentWeather::operator()(CustomisedPoint& point, ComplexSymbol& symbol else ww = w->second; } - if (ww.empty()) return; SymbolItem* object = new SymbolItem(); object->x(column_); object->y(row_); - Colour colour = owner_->present_ww_colour_->automatic() ? *owner_->colour_ : *owner_->present_ww_colour_; - object->colour(colour); - - + object->colour(Colour(colour)); object->symbol(ww); - // FMagLog::debug() << "\tPresent Weather--->" << ww << " in " << colour << "\n"; - // time->setJustification(MRIGHT); + object->height(owner_->size_); symbol.add(object); } @@ -532,7 +592,6 @@ void ObsTimePlot::operator()(CustomisedPoint& point, ComplexSymbol& symbol) cons if (value == point.end()) return; - // FMagLog::debug() << "\tTimePlot: " << value->second << "at[" << column_ << ", " << row_ << "]" << endl; Colour colour = owner_->time_plot_colour_->automatic() ? *owner_->colour_ : *owner_->time_plot_colour_; @@ -566,7 +625,6 @@ void ObsHeight::operator()(CustomisedPoint& point, ComplexSymbol& symbol) const return; double geop = maground(value->second / 98.1); - // FMagLog::debug() << "\tGeopotential: " << geop << "at[" << column_ << ", " << row_ << "]" << endl; Colour colour = owner_->height_colour_->automatic() ? *owner_->colour_ : *owner_->height_colour_; TextItem* height = new TextItem(); MagFont font("sansserif"); @@ -597,9 +655,7 @@ void ObsThickness::operator()(CustomisedPoint& point, ComplexSymbol& symbol) con if (value == point.end()) return; const double thickness = maground(value->second / 98.1); -#ifdef OBS_DEBUG_ - // FMagLog::debug() << "\tThickness: " << thickness << "at[" << column_ << ", " << row_ << "]" << endl; -#endif + Colour colour = owner_->thickness_colour_->automatic() ? *owner_->colour_ : *owner_->thickness_colour_; TextItem* object = new TextItem(); MagFont font("sansserif"); @@ -626,10 +682,7 @@ void ObsIdentifier::operator()(CustomisedPoint& point, ComplexSymbol& symbol) co if (!owner_->identifier_visible_) return; TextItem* time = new TextItem(); -#ifdef OBS_DEBUG_ - // FMagLog::debug() << "Identification for " << point.identifier() << "at[" << column_ << ", " << row_ << "]" << - // endl; -#endif + Colour colour = owner_->identifier_colour_->automatic() ? *owner_->colour_ : *owner_->identifier_colour_; MagFont font("sansserif"); font.colour(colour); @@ -912,7 +965,6 @@ void ObsCloud::operator()(CustomisedPoint& point, ComplexSymbol& symbol) const { cloud->colour(*owner_->medium_colour_); cloud->symbol(medium->second); - // FMagLog::debug() << "\tMedium Cloud--->" << value->second << " --> " << medium->second << "\n"; cloud->height(owner_->size_); symbol.add(cloud); @@ -930,7 +982,6 @@ void ObsCloud::operator()(CustomisedPoint& point, ComplexSymbol& symbol) const { cloud->colour(*owner_->high_colour_); cloud->symbol(high->second); - // FMagLog::debug() << "\tHigh Cloud--->" << value->second << "-->" << high->second << "\n"; cloud->height(owner_->size_); symbol.add(cloud); @@ -957,7 +1008,6 @@ void ObsDemoItem1::visit(std::set& tokens) { void ObsDemoItem1::operator()(CustomisedPoint& point, ComplexSymbol& symbol) const { if (point.find("temperature") == point.end()) { - // FMagLog::debug() << "No info for temperature given!" << endl; return; } @@ -1144,7 +1194,6 @@ void ObsWave::operator()(CustomisedPoint& point, ComplexSymbol& symbol) const { if (period == point.end() || height == point.end()) return; - // FMagLog::debug() << "\theight: " << height->second << " period " << period->second << "\n"; // height of waves in units of 0.5 double h = maground(height->second / 0.5); double p = maground(period->second); diff --git a/src/visualisers/ObsItemFamily.h b/src/visualisers/ObsItemFamily.h index 846fab09e..86e0dbbb5 100644 --- a/src/visualisers/ObsItemFamily.h +++ b/src/visualisers/ObsItemFamily.h @@ -46,14 +46,15 @@ class ObsStationRing : public ObsItemBox { } void operator()(CustomisedPoint&, ComplexSymbol& symbol) const override { + if (!owner_->station_ring_visible_) return; SymbolItem* station = new SymbolItem(); station->x(column_); station->y(row_); station->colour(*owner_->station_ring_colour_); - station->symbol("circle"); - station->height(owner_->ring_size_); + station->symbol("N_8"); + station->height(owner_->ring_size_*2); symbol.add(station); } @@ -104,13 +105,7 @@ class ObsWind : public ObsItemBox { void visit(std::set& tokens) override; virtual void operator()(CustomisedPoint&, ComplexSymbol&) const override; - virtual void set(const map& def) override { - row_ = atoi(find(def, "row").c_str()); - column_ = atoi(find(def, "column").c_str()); - colour_ = find(def, "colour"); - speed_ = find(def, "wind_speed", "wind_speed"); - direction_ = find(def, "wind_direction", "wind_direction"); - } + void set(const map& def) override; protected: string speed_; diff --git a/src/visualisers/ObsPlotting.cc b/src/visualisers/ObsPlotting.cc index 08fd1f460..30bfd4220 100644 --- a/src/visualisers/ObsPlotting.cc +++ b/src/visualisers/ObsPlotting.cc @@ -43,7 +43,6 @@ void ObsPlotting::operator()(Data& data, BasicGraphicsObjectContainer& out) { std::set needs; std::set info; multimap types; - info.insert("type"); data.getInfo(info, types); @@ -73,6 +72,9 @@ void ObsPlotting::operator()(Data& data, BasicGraphicsObjectContainer& out) { out.push_back(new ClearObject()); + + + for (multimap::const_iterator type = types.find("type"); type != types.end(); ++type) { try { const ObsTemplate& obs = ObsTable::getTemplate(type->second); diff --git a/src/visualisers/ObsTable.cc b/src/visualisers/ObsTable.cc index 825ed745b..4e21845aa 100644 --- a/src/visualisers/ObsTable.cc +++ b/src/visualisers/ObsTable.cc @@ -112,8 +112,7 @@ void ObsTable::add(const string& tag, const map& def) { if (MagicsGlobal::strict()) { throw; } - // FMagLog::dev() << "cannot find ObsItem for : " << tag << "\n"; - cout << "cannot find ObsItem for : " << tag << "\n"; + MagLog::warning() << "cannot find ObsItem for : " << tag << "\n"; } } } @@ -131,6 +130,8 @@ const ObsTemplate& ObsTable::get(const string& type) { void ObsTemplate::operator()(CustomisedPoint& obs, BasicGraphicsObjectContainer& out) const { + + if (empty()) return; // Nothing to display. @@ -149,6 +150,8 @@ void ObsTemplate::operator()(CustomisedPoint& obs, BasicGraphicsObjectContainer& out.push_back(symbol); + + for (const_iterator item = begin(); item != end(); ++item) (*(*item))(obs, *symbol); } diff --git a/src/visualisers/ObsTable.h b/src/visualisers/ObsTable.h index 67d2011b4..088d19337 100644 --- a/src/visualisers/ObsTable.h +++ b/src/visualisers/ObsTable.h @@ -28,6 +28,8 @@ class ObsTemplate : public vector { columns_ = (val != def.end()) ? atoi(val->second.c_str()) : 3; val = def.find("rows"); rows_ = (val != def.end()) ? atoi(val->second.c_str()) : 3; + for (const_iterator item = begin(); item != end(); ++item) + (*item)->set(def); } virtual ~ObsTemplate() {} void visit(std::set& tokens) const { diff --git a/src/visualisers/Streamlines.cc b/src/visualisers/Streamlines.cc index 0b64aed8d..22c823ef8 100644 --- a/src/visualisers/Streamlines.cc +++ b/src/visualisers/Streamlines.cc @@ -25,6 +25,9 @@ #include "LegendVisitor.h" #include "Polyline.h" #include "Timer.h" + +#include + using namespace magics; bool Streamlines::operator()(Data& data, BasicGraphicsObjectContainer& parent) { @@ -170,7 +173,6 @@ bool Streamlines::operator()(Data& data, BasicGraphicsObjectContainer& parent) { i++; } - GSStruct* gs = new GSStruct(); gs->nx = nbcolumns; gs->ny = handler.rows(); @@ -190,7 +192,6 @@ bool Streamlines::operator()(Data& data, BasicGraphicsObjectContainer& parent) { OneLineClass** result = 0; int size; - CalcStreamlines(min_density_, direction, gs, result, size); for (int l = 0; l < size; l++) { @@ -266,11 +267,45 @@ bool Streamlines::operator()(Data& data, BasicGraphicsObjectContainer& parent) { poly.push_back(pt); prevpt = pt; } - if (poly.size() >= 2) - transformation(poly, parent); + if (poly.size() >= 2) { + // clip the polyline + vector clippedPoly; + transformation(poly, clippedPoly); + // process each resulting polyline + for (auto rPoly = clippedPoly.begin(); rPoly != clippedPoly.end(); ++rPoly) { + // Copy the properties + (*rPoly)->copy(poly); + + // The order of the streamline points has to be adjusted. See MAGP-1349. + // To do so we need the unprojected polyline coordinates too. + auto rUnprojected = (*rPoly)->clone(); + assert(rUnprojected); + deque& polygon = rUnprojected->polygon(); + for (size_t k=0; k < polygon.size(); k++) { + UserPoint usp; + transformation.revert(polygon[k], usp); + polygon[k] = PaperPoint(usp.x(), usp.y()); + } + // adjust the point order in rPoly + if (AdjustStreamlinesDirection(direction, gs, *rPoly, rUnprojected)) { + parent.push_back(*rPoly); + } + delete rUnprojected; + } + } poly.clear(); } } + + delete gs; + + if (result) { + for (int l = 0; l < size; l++) { + delete result[l]; + } + delete [] result; + } + // ************ MF RV *************** // Leak ;-) delete[] direction; diff --git a/src/visualisers/SymbolAdvancedTableMode.cc b/src/visualisers/SymbolAdvancedTableMode.cc index 76a440539..6b31fa7a9 100644 --- a/src/visualisers/SymbolAdvancedTableMode.cc +++ b/src/visualisers/SymbolAdvancedTableMode.cc @@ -69,8 +69,9 @@ bool SymbolAdvancedTableMode::accept(double value) const { void SymbolAdvancedTableMode::prepare() {} -void SymbolAdvancedTableMode::adjust(double min, double max, bool scale, const Transformation& transformation, +void SymbolAdvancedTableMode::adjust(double min, double max, const Transformation& transformation, double scaling) { + static map texthandlers; if (texthandlers.empty()) { texthandlers["none"] = TextPosition::NONE; @@ -79,6 +80,7 @@ void SymbolAdvancedTableMode::adjust(double min, double max, bool scale, const T texthandlers["bottom"] = TextPosition::BELOW; texthandlers["right"] = TextPosition::RIGHT; } + scaling_ = scaling; map_.clear(); MagLog::dev() << "Data going from " << min << " to " << max << endl; levels_->set(*this); @@ -93,6 +95,8 @@ void SymbolAdvancedTableMode::adjust(double min, double max, bool scale, const T colourMethod_->prepare(*levels_, *levels_); height_method_->prepare(*levels_); + + if (markers_.empty()) { markers_.push_back(15); } @@ -131,9 +135,7 @@ void SymbolAdvancedTableMode::adjust(double min, double max, bool scale, const T MagLog::debug() << "[" << *level << ", " << *(level + 1) << "]=" << *marker << "(marker)" << *text << "(text)" << endl; - double height = height_method_->height(*level); - if (scale) - height = transformation.ratio() * height * scaling; + double height = height_method_->height(*level) * scaling_; SymbolProperties properties; if (index) properties = SymbolProperties(colourMethod_->right(*level), height, *marker, *text); @@ -225,7 +227,8 @@ void SymbolAdvancedTableMode::visit(Data& data, LegendVisitor& legend) { Symbol* symbol = new Symbol(); (*symbol).setColour(interval->second.colour_); (*symbol).setSymbol(interval->second.marker_); - (*symbol).setHeight(interval->second.height_); + // (*symbol).setHeight(interval->second.height_); + (*symbol).setHeight(0.5); string str = data.legendText(interval->first.min_, interval->first.max_); if (str.empty()) { diff --git a/src/visualisers/SymbolAdvancedTableMode.h b/src/visualisers/SymbolAdvancedTableMode.h index 07a9c3d9c..1dd4e23c4 100644 --- a/src/visualisers/SymbolAdvancedTableMode.h +++ b/src/visualisers/SymbolAdvancedTableMode.h @@ -68,7 +68,7 @@ class SymbolAdvancedTableMode : public SymbolMode, object->copy(*this); return object; } - void adjust(double, double, bool, const Transformation&, double) override; + void adjust(double, double, const Transformation&, double) override; void copy(const SymbolAdvancedTableMode& other) { SymbolAdvancedTableModeAttributes::copy(other); SymbolModeAttributes::copy(other); diff --git a/src/visualisers/SymbolMode.cc b/src/visualisers/SymbolMode.cc index b824be43b..8cf55b0d1 100644 --- a/src/visualisers/SymbolMode.cc +++ b/src/visualisers/SymbolMode.cc @@ -31,7 +31,7 @@ using namespace magics; -SymbolMode::SymbolMode() {} +SymbolMode::SymbolMode(): scaling_(1) {} SymbolMode::~SymbolMode() {} @@ -71,27 +71,21 @@ void SymbolIndividualMode::properties() const { texthandlers["top"] = TextPosition::ABOVE; texthandlers["bottom"] = TextPosition::BELOW; texthandlers["right"] = TextPosition::RIGHT; - texthandlers["centre"] = TextPosition::CENTRE; + texthandlers["centre"] = TextPosition::NONE; } TextPosition position; - if (magCompare(type_, "number")) { - position = TextPosition::NONE; - properties_.colour_ = *colour_; - properties_.height_ = height_; + string type = lowerCase(text_position_); + + map::iterator pos = texthandlers.find(type); + position = (pos != texthandlers.end()) ? pos->second : TextPosition::ABOVE; + if (magCompare(type_, "text") || magCompare(type_, "number")) { + properties_.height_ = 0.05; // make a very small symbol } else { - string type = lowerCase(text_position_); - map::iterator pos = texthandlers.find(type); - position = (pos != texthandlers.end()) ? pos->second : TextPosition::ABOVE; - if (magCompare(type_, "text")) { - properties_.height_ = 0.01; // make a very small symbol - properties_.colour_ = Colour("none"); - } - else { - properties_.colour_ = *colour_; - properties_.height_ = height_; - } + properties_.colour_ = *colour_; + properties_.height_ = height_*scaling_; } + if (magCompare(marker_mode_, "image")) { properties_.image_ = true; properties_.image_path_ = image_path_; @@ -183,7 +177,7 @@ void SymbolTableMode::prepare() { int index = 0; for (doublearray::const_iterator min = min_.begin(); min != min_.end(); ++min) { - map_[Interval(*min, *max)] = SymbolProperties(Colour(*colour), *height, *symbol); + map_[Interval(*min, *max)] = SymbolProperties(Colour(*colour), *height*scaling_, *symbol); map_[Interval(*min, *max)].blanking_ = parent_->text_blanking_; if (++colour == colour_.end()) --colour; @@ -244,11 +238,11 @@ void SymbolIndividualMode::visit(LegendVisitor& legend) { Symbol* symbol = properties_.symbol("marker"); // overwrite with the legend_height if set.. if (legend_height_ != -1) - symbol->setHeight(legend_height_); + // symbol->setHeight(legend_height_); + symbol->setHeight(0.5); legend.add(new SimpleSymbolEntry(legend_text_, symbol)); } -void SymbolIndividualMode::adjust(double, double, bool, const Transformation&, double) {} -void SymbolTableMode::adjust(double, double, bool, const Transformation&, double) {} + void SymbolIndividualMode::visit(Data& data, LegendVisitor& legend) { Symbol* symbol = properties_.symbol("marker"); if (legend_height_ != -1) diff --git a/src/visualisers/SymbolMode.h b/src/visualisers/SymbolMode.h index c032e8e73..e1046fc7e 100644 --- a/src/visualisers/SymbolMode.h +++ b/src/visualisers/SymbolMode.h @@ -71,7 +71,9 @@ class SymbolMode : public SymbolModeAttributes { virtual void visit(Data&, HistoVisitor&); - virtual void adjust(double, double, bool, const Transformation&, double) {} + virtual void adjust(double, double, const Transformation&, double scaling) { + scaling_ = scaling; + } void set(const string& type) { type_ = type; } protected: @@ -79,6 +81,7 @@ class SymbolMode : public SymbolModeAttributes { virtual void print(ostream&) const override; SymbolPlotting* parent_; string type_; + double scaling_; private: //! Copy constructor - No copy allowed @@ -118,7 +121,7 @@ class SymbolIndividualMode : public SymbolMode, public SymbolIndividualModeAttri return object; } - void adjust(double, double, bool, const Transformation&, double) override; + virtual void visit(LegendVisitor&) override; void prepare() override { update(); @@ -129,6 +132,11 @@ class SymbolIndividualMode : public SymbolMode, public SymbolIndividualModeAttri SymbolProperties operator()(double) const override { return properties_; } void visit(Data&, LegendVisitor&) override; + void adjust(double, double, const Transformation&, double scaling) override { + scaling_ = scaling; + properties(); + } + protected: //! Method to print string about this class on to a stream of type ostream (virtual). virtual void print(ostream&) const override; @@ -184,8 +192,7 @@ class SymbolTableMode : public SymbolMode, public SymbolTableModeAttributes { } virtual bool accept(const string& node) override { return SymbolTableModeAttributes::accept(node); } - void adjust(double, double, bool, const Transformation&, double) override; - + void visit(LegendVisitor&) override; void visit(Data&, LegendVisitor&) override; void visit(Data&, HistoVisitor&) override; diff --git a/src/visualisers/SymbolPlotting.cc b/src/visualisers/SymbolPlotting.cc index 46283bcbf..cd8908985 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; @@ -45,12 +47,9 @@ void SymbolPlotting::print(ostream& out) const { } double SymbolPlotting::height(const Transformation& transformation, double height) { - if (scaling_method_ == false) - return height; - - // get Area ! + - return transformation.ratio() * scaling_level_0_ * scaling_factor_; + return height; } void SymbolPlotting::getReady(const LegendVisitor& legend) { @@ -120,10 +119,108 @@ 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_hue_name_); + needs.insert(property_lightness_name_); + + + if ( property_hue_list_.empty() ) + property_hue_list_.push_back(1); + if ( property_lightness_list_.empty() ) + property_lightness_list_.push_back(0.5); + + + 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_hue + 1 == property_hue_values_list_.end()) + break; + + 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()) ; + + 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; + + + 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_); + + 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 ) { + 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"); @@ -131,6 +228,14 @@ void SymbolPlotting::operator()(Data& data, BasicGraphicsObjectContainer& out) { check.push_back("both"); check.push_back("marker_text"); + const Transformation& transformation = out.transformation(); + + double factor = ( out.absoluteHeight()*transformation.patchDistance(1))/(transformation.getMaxPCY()-transformation.getMinPCY()) ; + + factor = magCompare(unit_method_, "geographical") ? + ( out.absoluteHeight()*transformation.patchDistance(1))/(transformation.getMaxPCY()-transformation.getMinPCY()) : 1; + + bool valid = false; for (vector::iterator c = check.begin(); c != check.end(); ++c) { @@ -156,7 +261,7 @@ void SymbolPlotting::operator()(Data& data, BasicGraphicsObjectContainer& out) { // Some Mode need to know the min and max of the data, in order to adjust the // computation of the levels - (*mode_).adjust(points.min(), points.max(), scaling_method_, transformation, scaling_factor_); + (*mode_).adjust(points.min(), points.max(), transformation, factor); if (legend_only_) return; @@ -164,8 +269,6 @@ void SymbolPlotting::operator()(Data& data, BasicGraphicsObjectContainer& out) { while (points.more()) { PaperPoint xy = transformation(points.current()); (*this)(xy, out); - - points.advance(); } 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; diff --git a/src/visualisers/VisDefInfo.cc b/src/visualisers/VisDefInfo.cc index c1611caf0..1654040df 100644 --- a/src/visualisers/VisDefInfo.cc +++ b/src/visualisers/VisDefInfo.cc @@ -21,7 +21,7 @@ // //=============================================================== -VisDefInfoBase::VisDefInfoBase(string fConf, DataType dataType) : fConf_(fConf), dataType_(dataType) { +VisDefInfoBase::VisDefInfoBase(const string& fConf, DataType dataType) : fConf_(fConf), dataType_(dataType) { loaded_ = false; dataTypeName_[GribType] = "GRIB"; } @@ -38,7 +38,7 @@ void VisDefInfoBase::clear() { items_.clear(); } -VisDefInfoItem* VisDefInfoBase::addItem(string name) { +VisDefInfoItem* VisDefInfoBase::addItem(const string& name) { VisDefInfoItem* item = new VisDefInfoItem(name); items_.push_back(item); return item; @@ -70,7 +70,7 @@ void VisDefInfoBase::collectKeys() { //=============================================================== -ObstatVisDefInfo::ObstatVisDefInfo(string fConf, DataType dataType) : VisDefInfoBase(fConf, dataType) { +ObstatVisDefInfo::ObstatVisDefInfo(const string& fConf, DataType dataType) : VisDefInfoBase(fConf, dataType) { fConf_ = buildSharePath("ObstatGribVisDef.txt"); loadItems(); @@ -201,7 +201,7 @@ void ObstatVisDefInfo::getAttributes(MetaDataCollector& meta, map> num; @@ -217,7 +217,7 @@ string ObstatVisDefInfo::removeZerosFromNumber(string s) { // //=================================================== -VisDefInfoBase* VisDefInfoFactory::makeItem(string type) { +VisDefInfoBase* VisDefInfoFactory::makeItem(const string& type) { if (type == "ObstatGrib") { return new ObstatVisDefInfo("", VisDefInfoBase::GribType); } diff --git a/src/visualisers/VisDefInfo.h b/src/visualisers/VisDefInfo.h index beae7a080..a63b4747f 100644 --- a/src/visualisers/VisDefInfo.h +++ b/src/visualisers/VisDefInfo.h @@ -30,13 +30,13 @@ class MetaDataCollector; class VisDefInfoItem { public: - VisDefInfoItem(string name) : name_(name){}; + VisDefInfoItem(const string& name) : name_(name){}; - string name() { return name_; } + string name() const { return name_; } const map >& keys() const { return keys_; } const map& attributes() const { return attributes_; } - void addKey(string name, string value) { keys_[name].push_back(value); } - void addAttribute(string name, string value) { attributes_[name] = value; } + void addKey(const string& name, const string& value) { keys_[name].push_back(value); } + void addAttribute(const string& name, const string& value) { attributes_[name] = value; } public: string name_; @@ -53,9 +53,9 @@ class VisDefInfoBase { virtual ~VisDefInfoBase(); - VisDefInfoItem* addItem(string); + VisDefInfoItem* addItem(const string&); const vector& keys() { return keys_; } - string type() { return type_; } + string type() const { return type_; } // virtual vector visDefFile(MvKeyProfile*,int) {return QStringList() ;} // virtual MvRequest visDefRequest(MvKeyProfile*,int) {return MvRequest() ;} @@ -63,14 +63,14 @@ class VisDefInfoBase { virtual void getAttributes(MetaDataCollector&, map&) {} - bool isLoaded() { return loaded_; } + bool isLoaded() const { return loaded_; } void clear(); void deleteItem(int); virtual void loadItems() = 0; virtual void saveItems() = 0; protected: - VisDefInfoBase(string, DataType); + VisDefInfoBase(const string&, DataType); void collectKeys(); string fConf_; @@ -98,7 +98,7 @@ class VisDefInfoBase { class ObstatVisDefInfo : public VisDefInfoBase { public: - ObstatVisDefInfo(string, DataType); + ObstatVisDefInfo(const string&, DataType); ~ObstatVisDefInfo() override{}; void getAttributes(MetaDataCollector&, map&) override; @@ -106,13 +106,13 @@ class ObstatVisDefInfo : public VisDefInfoBase { void saveItems() override{}; protected: - string removeZerosFromNumber(string); + string removeZerosFromNumber(const string&); }; class VisDefInfoFactory { public: VisDefInfoFactory(){}; - static VisDefInfoBase* makeItem(string); + static VisDefInfoBase* makeItem(const string&); }; } // namespace magics diff --git a/src/visualisers/WindPlotting.cc b/src/visualisers/WindPlotting.cc index fdd469c9b..0041b4f43 100644 --- a/src/visualisers/WindPlotting.cc +++ b/src/visualisers/WindPlotting.cc @@ -70,13 +70,15 @@ void WindPlotting::setAdvanced(double& min, double& max) { colourMethod_->set(*this); levels_->calculate(min, max, false); LevelSelection::const_iterator level = levels_->begin(); + if ( levels_->size() == 1 ) + levels_->push_back(levels_->back()*1.00001); colourMethod_->prepare(*levels_, *levels_); Colour last; map_.clear(); while (true) { if (level + 1 == levels_->end()) break; - MagLog::debug() << "[" << *level << ", " << *(level + 1) << "]=" << colourMethod_->right(*level) << endl; + MagLog::debug() << "[" << *level << ", " << *(level + 1) << "]=" << colourMethod_->right(*level) << endl; map_[Interval(*level, *(level + 1))] = colourMethod_->right(*level); last = colourMethod_->right(*level); ++level; diff --git a/src/web/GeoJSon.cc b/src/web/GeoJSon.cc index 68e1fc8a8..310ba7215 100644 --- a/src/web/GeoJSon.cc +++ b/src/web/GeoJSon.cc @@ -92,9 +92,9 @@ class GeoObject { } } vector objects_; + string value_; virtual GeoObject* push_back(GeoObject* o) { objects_.push_back(o); - o->parent_ = this; return o; } @@ -134,6 +134,8 @@ class GeoFeature : public GeoObject { virtual ~GeoFeature() {} + + void boundingBox(double& min, double& max) { min = 900000; max = -min; @@ -211,11 +213,9 @@ class GeoPoint : public GeoObject { while (lon_ > max) lon_ -= 360; } - - UserPoint* point = - new UserPoint(lon_, lat_, tonumber(getProperty("value", "0")), false, false, getProperty("name")); - + new UserPoint(lon_, lat_, tonumber(getProperty(value_, "0")), false, false, getProperty("name")); + out.push_back(point); } void shift(PointsList& out, double value) { @@ -226,15 +226,25 @@ class GeoPoint : public GeoObject { } void set(const std::set& needs, CustomisedPoint& point) { + if (value_ == "value") { + point.type("mosmix"); + } + + else + point.type(value_); for (std::set::iterator need = needs.begin(); need != needs.end(); ++need) { + string value = getProperty(*need); + if (value.empty()) continue; point.insert(make_pair(*need, tonumber(value))); } + } void create(const std::set& needs, CustomisedPointsList& out) { + CustomisedPoint* point = new CustomisedPoint(lon_, lat_, getProperty("name")); set(needs, *point); out.push_back(point); @@ -267,7 +277,7 @@ class MultiLineString : public GeoObject { } vector > > lines_; void create(PointsList& out, const string& ref) { - double value = tonumber(getProperty("value", "0")); + double value = tonumber(getProperty(value_, "0")); string name = getProperty("name"); for (vector > >::iterator line = lines_.begin(); line != lines_.end(); ++line) { for (vector >::iterator point = line->begin(); point != line->end(); ++point) { @@ -278,7 +288,7 @@ class MultiLineString : public GeoObject { } } void shift(PointsList& out) { - double value = tonumber(getProperty("value", "0")); + double value = tonumber(getProperty(value_, "0")); string name = getProperty("name"); for (vector > >::iterator line = lines_.begin(); line != lines_.end(); ++line) { for (vector >::iterator point = line->begin(); point != line->end(); ++point) { @@ -499,6 +509,7 @@ void GeoJSon::features(const Value& value) { } } void GeoJSon::geometry(const Value& value) { + dig(value); } @@ -515,19 +526,20 @@ void GeoJSon::dig(const Value& value) { // Find the type : string type = find(object, "type"); - + GeoObject* previous = current_; if (type != "") { GeoObject* current = SimpleObjectMaker::create(type); + current->value_ = value_; previous = current_; current_ = (current_) ? current_->push_back(current) : current; + current_ = current; if (!parent_) parent_ = current_; } for (auto entry = object.begin(); entry != object.end(); ++entry) { map::iterator method = methods_.find(entry->first); - if (method != methods_.end()) { ((this->*method->second)(entry->second)); } @@ -572,7 +584,7 @@ void GeoJSon::decode() { if (MagicsGlobal::strict()) { throw; } - MagLog::error() << "Could not processed the file: " << path_ << ": " << e.what() << endl; + MagLog::error() << "GEOJSON:Could not processed the file: " << path_ << ": " << e.what() << endl; abort(); } if (parent_) { @@ -590,14 +602,21 @@ PointsHandler& GeoJSon::points(const Transformation& transformation, bool) { decode(); pointsHandlers_.push_back(new PointsHandler(*this)); return *(pointsHandlers_.back()); + } void GeoJSon::customisedPoints(const Transformation&, const std::set& needs, CustomisedPointsList& out, bool) { decode(); - - + if (parent_) { parent_->create(needs, out); parent_->shift(needs, out); } } +void GeoJSon::getInfo(const std::set& what, + multimap& info) +{ + + info.insert(make_pair("type", value_)); + +} diff --git a/src/web/GeoJSon.h b/src/web/GeoJSon.h index 66db165fd..9d5340527 100644 --- a/src/web/GeoJSon.h +++ b/src/web/GeoJSon.h @@ -62,6 +62,8 @@ class GeoJSon : public Data, public PointsList, public GeoJSonAttributes { GeoObject* current_; GeoObject* parent_; Matrix* matrix_; + void getInfo(const std::set& what, multimap& info) override; + private: //! Copy constructor - No copy allowed diff --git a/src/web/WrepJSon.cc b/src/web/WrepJSon.cc index 56a27f5fd..3627a34c9 100644 --- a/src/web/WrepJSon.cc +++ b/src/web/WrepJSon.cc @@ -71,6 +71,7 @@ WrepJSon::WrepJSon() : decoders_["eps"] = &WrepJSon::eps; + decoders_["visibility"] = &WrepJSon::eps; decoders_["clim"] = &WrepJSon::eps; decoders_["profile"] = &WrepJSon::profile; @@ -86,6 +87,7 @@ WrepJSon::WrepJSon() : transformationHandlers_["eps"] = &WrepJSon::eps; + transformationHandlers_["visibility"] = &WrepJSon::eps; transformationHandlers_["cdf"] = &WrepJSon::cdf; transformationHandlers_["efi"] = &WrepJSon::efi; transformationHandlers_["profile"] = &WrepJSon::profile; @@ -1936,7 +1938,7 @@ void WrepJSon::visit(TextVisitor& text) { text.update("json", "station_name", station_name_); if (!expver_.empty() && expver_ != "0001") text.update("json", "expver", " [" + expver_ + "] "); - text.update("json", "ens_height", tostring(epsz_)); + text.update("json", "ens_height", tostring(maground(epsz_))); } text.update("json", "product_info", product_info_); @@ -1958,7 +1960,11 @@ void WrepJSon::points(const Transformation& transformation, vector& p x -= shift; } // doubble v = (*point)->find("value") != (*point)->end() ) : (**point)["value"] : 0; - points.push_back(UserPoint(x, (**point)["y"], (**point)["value"])); + if ( family_ == "visibility") + points.push_back(UserPoint(x, y_axis_value_, (**point)["y"])); + else + points.push_back(UserPoint(x, (**point)["y"], (**point)["value"])); + if ((*point)->missing()) points.back().flagMissing(); } @@ -1975,7 +1981,10 @@ PointsHandler& WrepJSon::points(const Transformation& transformation, bool) { x -= shift; } - list_.push_back(new UserPoint(x, (**point)["y"], (**point)["value"])); + if ( family_ == "visibility") + list_.push_back(new UserPoint(x, y_axis_value_, (**point)["y"])); + else + list_.push_back(new UserPoint(x, (**point)["y"], (**point)["value"])); if ((*point)->missing()) list_.back()->flagMissing(); } diff --git a/tools/xml2cc.py b/tools/xml2cc.py index eade2d313..88abed4af 100755 --- a/tools/xml2cc.py +++ b/tools/xml2cc.py @@ -16,6 +16,7 @@ class ObjectHandler(ContentHandler): basic = { "bool": "getBool", "int": "getInt", + "unsigned long long": "getULong", "float": "getDouble", "string": "getString", "stringarray": "getStringArray", diff --git a/tools/xml2cc_mv.py b/tools/xml2cc_mv.py index 2f5793842..79ba64c59 100755 --- a/tools/xml2cc_mv.py +++ b/tools/xml2cc_mv.py @@ -17,6 +17,7 @@ class ObjectHandler(ContentHandler): basic = { "bool": "getBool", "int": "getInt", + "unsigned long long": "getULong", "float": "getDouble", "string": "getString", "stringarray": "getStringArray", diff --git a/tools/xml2milana.py b/tools/xml2milana.py index 060fab4f3..837c5e595 100644 --- a/tools/xml2milana.py +++ b/tools/xml2milana.py @@ -1,10 +1,60 @@ import xmltodict -with open("../src/params/CoastPlotting.xml") as fd: - definition = xmltodict.parse(fd) +import ipywidgets as widgets -print definition +with open("../src/params/BoxPlotVisualiser.xml") as fd: + l = fd.read() + definition = xmltodict.parse(l) -for params in definition["magics"]["class"]: - print params + +print (definition["magics"]["class"]) + +def boolean(data): + name = data["@name"] + return 'widgets.ToggleButtons(description={}, options = ["on", "off"])'.format(name) + +def colour(data): + name = data["@name"] + return 'widgets.DropDown(description={}, options = ["red", "blue", "green", "navy", "pink"])'.format(name) + +def style(data): + name = data["@name"] + return 'widgets.DropDown(description={}, options = ["dash", "solid", "dot"])'.format(name) + + +def choice(data): + name = data["@name"] + values = data.get("@values", None) + if values: + return 'widgets.DropDown(description={}, options = {})'.format(name, values.split("/")) + return "" + + +def ignore(data): + name = data["@name"] + + return "ignore" + +def float(data): + name = data["@name"] + return 'widgets.IntSlider(description={}'.format(name) + +def int(data): + name = data["@name"] + return 'widgets.FloatSlider(description={}'.format(name) + +helpers = { + "bool" : boolean, + "Colour" : colour, + "float" : float, + "int" : int, + "LineStyle" : style, + "string" : choice, +} + + +for e in definition["magics"]["class"]["parameter"]: + print (e["@name"], e["@to"]) + to = e["@to"] + print(helpers.get(to, ignore)(e)) \ No newline at end of file From 2af865ac8e5b34e4f64be0010846dcf0608ef2d5 Mon Sep 17 00:00:00 2001 From: Sylvie Lamy-Thepaut Date: Thu, 16 Nov 2023 17:26:00 +0000 Subject: [PATCH 02/18] Rmove out-of-bon functionalities --- src/attributes/NoBoxPlotAttributes.cc | 99 ++++++++++++++++++++ src/attributes/NoBoxPlotAttributes.h | 63 +++++++++++++ src/attributes/NoBoxPlotBoxAttributes.cc | 99 ++++++++++++++++++++ src/attributes/NoBoxPlotBoxAttributes.h | 63 +++++++++++++ src/attributes/NoBoxPlotBoxWrapper.cc | 67 +++++++++++++ src/attributes/NoBoxPlotBoxWrapper.h | 91 ++++++++++++++++++ src/attributes/NoBoxPlotWhiskerAttributes.cc | 99 ++++++++++++++++++++ src/attributes/NoBoxPlotWhiskerAttributes.h | 63 +++++++++++++ src/attributes/NoBoxPlotWhiskerWrapper.cc | 67 +++++++++++++ src/attributes/NoBoxPlotWhiskerWrapper.h | 91 ++++++++++++++++++ src/attributes/NoBoxPlotWrapper.cc | 67 +++++++++++++ src/attributes/NoBoxPlotWrapper.h | 91 ++++++++++++++++++ src/params/NoBoxPlot.xml | 15 +++ src/params/NoBoxPlotBox.xml | 15 +++ src/params/NoBoxPlotWhisker.xml | 15 +++ 15 files changed, 1005 insertions(+) create mode 100644 src/attributes/NoBoxPlotAttributes.cc create mode 100644 src/attributes/NoBoxPlotAttributes.h create mode 100644 src/attributes/NoBoxPlotBoxAttributes.cc create mode 100644 src/attributes/NoBoxPlotBoxAttributes.h create mode 100644 src/attributes/NoBoxPlotBoxWrapper.cc create mode 100644 src/attributes/NoBoxPlotBoxWrapper.h create mode 100644 src/attributes/NoBoxPlotWhiskerAttributes.cc create mode 100644 src/attributes/NoBoxPlotWhiskerAttributes.h create mode 100644 src/attributes/NoBoxPlotWhiskerWrapper.cc create mode 100644 src/attributes/NoBoxPlotWhiskerWrapper.h create mode 100644 src/attributes/NoBoxPlotWrapper.cc create mode 100644 src/attributes/NoBoxPlotWrapper.h create mode 100644 src/params/NoBoxPlot.xml create mode 100644 src/params/NoBoxPlotBox.xml create mode 100644 src/params/NoBoxPlotWhisker.xml diff --git a/src/attributes/NoBoxPlotAttributes.cc b/src/attributes/NoBoxPlotAttributes.cc new file mode 100644 index 000000000..a6d8d0c29 --- /dev/null +++ b/src/attributes/NoBoxPlotAttributes.cc @@ -0,0 +1,99 @@ + +/****************************** LICENSE ******************************* + + * (C) Copyright 1996-2017 ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * In applying this licence, ECMWF does not waive the privileges and immunities + * granted to it by virtue of its status as an intergovernmental organisation nor + * does it submit to any jurisdiction. + + ******************************* LICENSE *******************************/ + +/*! \\file NoBoxPlotAttributes.h + \\brief Definition of NoBoxPlot Attributes class. + + This file is automatically generated. + Do Not Edit! +*/ + +#include "NoBoxPlotAttributes.h" +#include "MagicsParameter.h" +#include "ParameterSettings.h" + +using namespace magics; + +NoBoxPlotAttributes::NoBoxPlotAttributes() + + +{ +} + + +NoBoxPlotAttributes::~NoBoxPlotAttributes() +{ + +} + + +void NoBoxPlotAttributes::set(const std::map& params) +{ + vector prefix(1); + int i = 0; + prefix[i++] = "boxplot"; + + + +} + +void NoBoxPlotAttributes::copy(const NoBoxPlotAttributes& other) +{ + +} + + +bool NoBoxPlotAttributes::accept(const string& node) +{ + + if ( magCompare(node, "boxplot") ) + return true; + + return false; +} + +void NoBoxPlotAttributes::set(const XmlNode& node) +{ + bool apply = false; + + if ( this->accept(node.name()) == false ) + return; + + if ( magCompare(node.name(), "boxplot") ) + apply = true; + + + if ( apply ) + set(node.attributes()); + else { + + } + for (auto &elt : node.elements()) + { + + } +} + +void NoBoxPlotAttributes::print(ostream& out) const +{ + out << "Attributes["; + + out << "]" << "\n"; +} + +void NoBoxPlotAttributes::toxml(ostream& out) const +{ + out << "\"boxplot\""; + +} + diff --git a/src/attributes/NoBoxPlotAttributes.h b/src/attributes/NoBoxPlotAttributes.h new file mode 100644 index 000000000..018ed8932 --- /dev/null +++ b/src/attributes/NoBoxPlotAttributes.h @@ -0,0 +1,63 @@ + +/******************************* LICENSE ******************************* + + * (C) Copyright 1996-2016 ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * In applying this licence, ECMWF does not waive the privileges and immunities + * granted to it by virtue of its status as an intergovernmental organisation nor + * does it submit to any jurisdiction. + + ******************************* LICENSE *******************************/ + +/*! \fileNoBoxPlotAttributes.h + \brief Definition of NoBoxPlot Attributes class. + + This file is automatically generated. + Do Not Edit! + + Generated: +*/ + + +#ifndef NoBoxPlotAttributes_H +#define NoBoxPlotAttributes_H + +#include "magics.h" +namespace magics { + +class XmlNode; +class NoBoxPlotAttributes +{ +public: +// -- constructor + NoBoxPlotAttributes(); + +// -- destructor + virtual ~NoBoxPlotAttributes(); + + virtual void set(const std::map&); + virtual void set(const XmlNode&); + virtual void copy(const NoBoxPlotAttributes&); + virtual bool accept(const std::string&); + + void setTag(const std::string& tag) { tag_ = tag; } + +public: + // -- method + virtual void print(std::ostream&) const; + virtual void toxml(std::ostream& out) const; + // -- members: + string tag_; + + +private: + friend ostream& operator<<(ostream& s,const NoBoxPlotAttributes& p) + { p.print(s); return s; } +}; + +} // namespace magics + +#endif + diff --git a/src/attributes/NoBoxPlotBoxAttributes.cc b/src/attributes/NoBoxPlotBoxAttributes.cc new file mode 100644 index 000000000..c215ddd1e --- /dev/null +++ b/src/attributes/NoBoxPlotBoxAttributes.cc @@ -0,0 +1,99 @@ + +/****************************** LICENSE ******************************* + + * (C) Copyright 1996-2017 ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * In applying this licence, ECMWF does not waive the privileges and immunities + * granted to it by virtue of its status as an intergovernmental organisation nor + * does it submit to any jurisdiction. + + ******************************* LICENSE *******************************/ + +/*! \\file NoBoxPlotBoxAttributes.h + \\brief Definition of NoBoxPlotBox Attributes class. + + This file is automatically generated. + Do Not Edit! +*/ + +#include "NoBoxPlotBoxAttributes.h" +#include "MagicsParameter.h" +#include "ParameterSettings.h" + +using namespace magics; + +NoBoxPlotBoxAttributes::NoBoxPlotBoxAttributes() + + +{ +} + + +NoBoxPlotBoxAttributes::~NoBoxPlotBoxAttributes() +{ + +} + + +void NoBoxPlotBoxAttributes::set(const std::map& params) +{ + vector prefix(1); + int i = 0; + prefix[i++] = "boxplot"; + + + +} + +void NoBoxPlotBoxAttributes::copy(const NoBoxPlotBoxAttributes& other) +{ + +} + + +bool NoBoxPlotBoxAttributes::accept(const string& node) +{ + + if ( magCompare(node, "boxplot") ) + return true; + + return false; +} + +void NoBoxPlotBoxAttributes::set(const XmlNode& node) +{ + bool apply = false; + + if ( this->accept(node.name()) == false ) + return; + + if ( magCompare(node.name(), "boxplot") ) + apply = true; + + + if ( apply ) + set(node.attributes()); + else { + + } + for (auto &elt : node.elements()) + { + + } +} + +void NoBoxPlotBoxAttributes::print(ostream& out) const +{ + out << "Attributes["; + + out << "]" << "\n"; +} + +void NoBoxPlotBoxAttributes::toxml(ostream& out) const +{ + out << "\"boxplot\""; + +} + diff --git a/src/attributes/NoBoxPlotBoxAttributes.h b/src/attributes/NoBoxPlotBoxAttributes.h new file mode 100644 index 000000000..ddb177109 --- /dev/null +++ b/src/attributes/NoBoxPlotBoxAttributes.h @@ -0,0 +1,63 @@ + +/******************************* LICENSE ******************************* + + * (C) Copyright 1996-2016 ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * In applying this licence, ECMWF does not waive the privileges and immunities + * granted to it by virtue of its status as an intergovernmental organisation nor + * does it submit to any jurisdiction. + + ******************************* LICENSE *******************************/ + +/*! \fileNoBoxPlotBoxAttributes.h + \brief Definition of NoBoxPlotBox Attributes class. + + This file is automatically generated. + Do Not Edit! + + Generated: +*/ + + +#ifndef NoBoxPlotBoxAttributes_H +#define NoBoxPlotBoxAttributes_H + +#include "magics.h" +namespace magics { + +class XmlNode; +class NoBoxPlotBoxAttributes +{ +public: +// -- constructor + NoBoxPlotBoxAttributes(); + +// -- destructor + virtual ~NoBoxPlotBoxAttributes(); + + virtual void set(const std::map&); + virtual void set(const XmlNode&); + virtual void copy(const NoBoxPlotBoxAttributes&); + virtual bool accept(const std::string&); + + void setTag(const std::string& tag) { tag_ = tag; } + +public: + // -- method + virtual void print(std::ostream&) const; + virtual void toxml(std::ostream& out) const; + // -- members: + string tag_; + + +private: + friend ostream& operator<<(ostream& s,const NoBoxPlotBoxAttributes& p) + { p.print(s); return s; } +}; + +} // namespace magics + +#endif + diff --git a/src/attributes/NoBoxPlotBoxWrapper.cc b/src/attributes/NoBoxPlotBoxWrapper.cc new file mode 100644 index 000000000..5458c6002 --- /dev/null +++ b/src/attributes/NoBoxPlotBoxWrapper.cc @@ -0,0 +1,67 @@ + +/****************************** LICENSE ******************************* + + * (C) Copyright 1996-2017 ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * In applying this licence, ECMWF does not waive the privileges and immunities + * granted to it by virtue of its status as an intergovernmental organisation nor + * does it submit to any jurisdiction. + + ******************************* LICENSE *******************************/ + +/*! \\file NoBoxPlotBoxAttributes.h + \\brief Definition of NoBoxPlotBox Attributes class. + + This file is automatically generated. + Do Not Edit! + +*/ + +#include "MagRequest.h" +#include "NoBoxPlotBoxWrapper.h" +#include "MagicsParameter.h" +#include "Factory.h" +#include "MagTranslator.h" +#include "MagicsGlobal.h" + +using namespace magics; + + + +NoBoxPlotBoxWrapper::NoBoxPlotBoxWrapper(): noboxplotbox_(new NoBoxPlotBox()) + + +{ + + + + +} +NoBoxPlotBoxWrapper::NoBoxPlotBoxWrapper(NoBoxPlotBox* noboxplotbox): noboxplotbox_(noboxplotbox) +{ + + +} + +NoBoxPlotBoxWrapper::~NoBoxPlotBoxWrapper() +{ + +} + +void NoBoxPlotBoxWrapper::set(const MagRequest& request) +{ + + + + + +} + +void NoBoxPlotBoxWrapper::print(ostream& out) const +{ + out << "NoBoxPlotBoxWrapper[]"; +} + + diff --git a/src/attributes/NoBoxPlotBoxWrapper.h b/src/attributes/NoBoxPlotBoxWrapper.h new file mode 100644 index 000000000..7d573a447 --- /dev/null +++ b/src/attributes/NoBoxPlotBoxWrapper.h @@ -0,0 +1,91 @@ + +/******************************* LICENSE ******************************* + + * (C) Copyright 1996-2016 ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * In applying this licence, ECMWF does not waive the privileges and immunities + * granted to it by virtue of its status as an intergovernmental organisation nor + * does it submit to any jurisdiction. + + ******************************* LICENSE *******************************/ + +/*! \fileNoBoxPlotBoxAttributes.h + \brief Definition of NoBoxPlotBox Attributes class. + + This file is automatically generated. + Do Not Edit! + + Generated: +*/ + + +#ifndef NoBoxPlotBoxWrapper_H +#define NoBoxPlotBoxWrapper_H + +#include "magics.h" +#include "ParameterManager.h" +#include "Factory.h" + + + +#include "BoxPlotItem.h" + + + + + + + + + + +namespace magics { + +class MagRequest; + + + +class NoBoxPlotBoxWrapper + +{ +public: +// -- constructor + NoBoxPlotBoxWrapper(); + NoBoxPlotBoxWrapper(NoBoxPlotBox*); +// -- destructor + virtual ~NoBoxPlotBoxWrapper(); + virtual void set(const MagRequest&); + + NoBoxPlotBox* me() { return noboxplotbox_; } + + virtual NoBoxPlotBox* object() { return noboxplotbox_; } + + + virtual void object(NoBoxPlotBox* o) { + // Remember to delete the previous object + noboxplotbox_ = o; + + + } + + + +protected: + NoBoxPlotBox* noboxplotbox_; + + +// -- method + virtual void print(ostream&) const; + + +private: + string tag_; + friend ostream& operator<<(ostream& s,const NoBoxPlotBoxWrapper& p) + { p.print(s); return s; } +}; + +} // namespace magics + +#endif \ No newline at end of file diff --git a/src/attributes/NoBoxPlotWhiskerAttributes.cc b/src/attributes/NoBoxPlotWhiskerAttributes.cc new file mode 100644 index 000000000..dc6d49cb1 --- /dev/null +++ b/src/attributes/NoBoxPlotWhiskerAttributes.cc @@ -0,0 +1,99 @@ + +/****************************** LICENSE ******************************* + + * (C) Copyright 1996-2017 ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * In applying this licence, ECMWF does not waive the privileges and immunities + * granted to it by virtue of its status as an intergovernmental organisation nor + * does it submit to any jurisdiction. + + ******************************* LICENSE *******************************/ + +/*! \\file NoBoxPlotWhiskerAttributes.h + \\brief Definition of NoBoxPlotWhisker Attributes class. + + This file is automatically generated. + Do Not Edit! +*/ + +#include "NoBoxPlotWhiskerAttributes.h" +#include "MagicsParameter.h" +#include "ParameterSettings.h" + +using namespace magics; + +NoBoxPlotWhiskerAttributes::NoBoxPlotWhiskerAttributes() + + +{ +} + + +NoBoxPlotWhiskerAttributes::~NoBoxPlotWhiskerAttributes() +{ + +} + + +void NoBoxPlotWhiskerAttributes::set(const std::map& params) +{ + vector prefix(1); + int i = 0; + prefix[i++] = "boxplot"; + + + +} + +void NoBoxPlotWhiskerAttributes::copy(const NoBoxPlotWhiskerAttributes& other) +{ + +} + + +bool NoBoxPlotWhiskerAttributes::accept(const string& node) +{ + + if ( magCompare(node, "boxplot") ) + return true; + + return false; +} + +void NoBoxPlotWhiskerAttributes::set(const XmlNode& node) +{ + bool apply = false; + + if ( this->accept(node.name()) == false ) + return; + + if ( magCompare(node.name(), "boxplot") ) + apply = true; + + + if ( apply ) + set(node.attributes()); + else { + + } + for (auto &elt : node.elements()) + { + + } +} + +void NoBoxPlotWhiskerAttributes::print(ostream& out) const +{ + out << "Attributes["; + + out << "]" << "\n"; +} + +void NoBoxPlotWhiskerAttributes::toxml(ostream& out) const +{ + out << "\"boxplot\""; + +} + diff --git a/src/attributes/NoBoxPlotWhiskerAttributes.h b/src/attributes/NoBoxPlotWhiskerAttributes.h new file mode 100644 index 000000000..6beadab70 --- /dev/null +++ b/src/attributes/NoBoxPlotWhiskerAttributes.h @@ -0,0 +1,63 @@ + +/******************************* LICENSE ******************************* + + * (C) Copyright 1996-2016 ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * In applying this licence, ECMWF does not waive the privileges and immunities + * granted to it by virtue of its status as an intergovernmental organisation nor + * does it submit to any jurisdiction. + + ******************************* LICENSE *******************************/ + +/*! \fileNoBoxPlotWhiskerAttributes.h + \brief Definition of NoBoxPlotWhisker Attributes class. + + This file is automatically generated. + Do Not Edit! + + Generated: +*/ + + +#ifndef NoBoxPlotWhiskerAttributes_H +#define NoBoxPlotWhiskerAttributes_H + +#include "magics.h" +namespace magics { + +class XmlNode; +class NoBoxPlotWhiskerAttributes +{ +public: +// -- constructor + NoBoxPlotWhiskerAttributes(); + +// -- destructor + virtual ~NoBoxPlotWhiskerAttributes(); + + virtual void set(const std::map&); + virtual void set(const XmlNode&); + virtual void copy(const NoBoxPlotWhiskerAttributes&); + virtual bool accept(const std::string&); + + void setTag(const std::string& tag) { tag_ = tag; } + +public: + // -- method + virtual void print(std::ostream&) const; + virtual void toxml(std::ostream& out) const; + // -- members: + string tag_; + + +private: + friend ostream& operator<<(ostream& s,const NoBoxPlotWhiskerAttributes& p) + { p.print(s); return s; } +}; + +} // namespace magics + +#endif + diff --git a/src/attributes/NoBoxPlotWhiskerWrapper.cc b/src/attributes/NoBoxPlotWhiskerWrapper.cc new file mode 100644 index 000000000..8bd638cb1 --- /dev/null +++ b/src/attributes/NoBoxPlotWhiskerWrapper.cc @@ -0,0 +1,67 @@ + +/****************************** LICENSE ******************************* + + * (C) Copyright 1996-2017 ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * In applying this licence, ECMWF does not waive the privileges and immunities + * granted to it by virtue of its status as an intergovernmental organisation nor + * does it submit to any jurisdiction. + + ******************************* LICENSE *******************************/ + +/*! \\file NoBoxPlotWhiskerAttributes.h + \\brief Definition of NoBoxPlotWhisker Attributes class. + + This file is automatically generated. + Do Not Edit! + +*/ + +#include "MagRequest.h" +#include "NoBoxPlotWhiskerWrapper.h" +#include "MagicsParameter.h" +#include "Factory.h" +#include "MagTranslator.h" +#include "MagicsGlobal.h" + +using namespace magics; + + + +NoBoxPlotWhiskerWrapper::NoBoxPlotWhiskerWrapper(): noboxplotwhisker_(new NoBoxPlotWhisker()) + + +{ + + + + +} +NoBoxPlotWhiskerWrapper::NoBoxPlotWhiskerWrapper(NoBoxPlotWhisker* noboxplotwhisker): noboxplotwhisker_(noboxplotwhisker) +{ + + +} + +NoBoxPlotWhiskerWrapper::~NoBoxPlotWhiskerWrapper() +{ + +} + +void NoBoxPlotWhiskerWrapper::set(const MagRequest& request) +{ + + + + + +} + +void NoBoxPlotWhiskerWrapper::print(ostream& out) const +{ + out << "NoBoxPlotWhiskerWrapper[]"; +} + + diff --git a/src/attributes/NoBoxPlotWhiskerWrapper.h b/src/attributes/NoBoxPlotWhiskerWrapper.h new file mode 100644 index 000000000..7258f3f1a --- /dev/null +++ b/src/attributes/NoBoxPlotWhiskerWrapper.h @@ -0,0 +1,91 @@ + +/******************************* LICENSE ******************************* + + * (C) Copyright 1996-2016 ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * In applying this licence, ECMWF does not waive the privileges and immunities + * granted to it by virtue of its status as an intergovernmental organisation nor + * does it submit to any jurisdiction. + + ******************************* LICENSE *******************************/ + +/*! \fileNoBoxPlotWhiskerAttributes.h + \brief Definition of NoBoxPlotWhisker Attributes class. + + This file is automatically generated. + Do Not Edit! + + Generated: +*/ + + +#ifndef NoBoxPlotWhiskerWrapper_H +#define NoBoxPlotWhiskerWrapper_H + +#include "magics.h" +#include "ParameterManager.h" +#include "Factory.h" + + + +#include "BoxPlotItem.h" + + + + + + + + + + +namespace magics { + +class MagRequest; + + + +class NoBoxPlotWhiskerWrapper + +{ +public: +// -- constructor + NoBoxPlotWhiskerWrapper(); + NoBoxPlotWhiskerWrapper(NoBoxPlotWhisker*); +// -- destructor + virtual ~NoBoxPlotWhiskerWrapper(); + virtual void set(const MagRequest&); + + NoBoxPlotWhisker* me() { return noboxplotwhisker_; } + + virtual NoBoxPlotWhisker* object() { return noboxplotwhisker_; } + + + virtual void object(NoBoxPlotWhisker* o) { + // Remember to delete the previous object + noboxplotwhisker_ = o; + + + } + + + +protected: + NoBoxPlotWhisker* noboxplotwhisker_; + + +// -- method + virtual void print(ostream&) const; + + +private: + string tag_; + friend ostream& operator<<(ostream& s,const NoBoxPlotWhiskerWrapper& p) + { p.print(s); return s; } +}; + +} // namespace magics + +#endif \ No newline at end of file diff --git a/src/attributes/NoBoxPlotWrapper.cc b/src/attributes/NoBoxPlotWrapper.cc new file mode 100644 index 000000000..5b48f7a6d --- /dev/null +++ b/src/attributes/NoBoxPlotWrapper.cc @@ -0,0 +1,67 @@ + +/****************************** LICENSE ******************************* + + * (C) Copyright 1996-2017 ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * In applying this licence, ECMWF does not waive the privileges and immunities + * granted to it by virtue of its status as an intergovernmental organisation nor + * does it submit to any jurisdiction. + + ******************************* LICENSE *******************************/ + +/*! \\file NoBoxPlotAttributes.h + \\brief Definition of NoBoxPlot Attributes class. + + This file is automatically generated. + Do Not Edit! + +*/ + +#include "MagRequest.h" +#include "NoBoxPlotWrapper.h" +#include "MagicsParameter.h" +#include "Factory.h" +#include "MagTranslator.h" +#include "MagicsGlobal.h" + +using namespace magics; + + + +NoBoxPlotWrapper::NoBoxPlotWrapper(): noboxplot_(new NoBoxPlot()) + + +{ + + + + +} +NoBoxPlotWrapper::NoBoxPlotWrapper(NoBoxPlot* noboxplot): noboxplot_(noboxplot) +{ + + +} + +NoBoxPlotWrapper::~NoBoxPlotWrapper() +{ + +} + +void NoBoxPlotWrapper::set(const MagRequest& request) +{ + + + + + +} + +void NoBoxPlotWrapper::print(ostream& out) const +{ + out << "NoBoxPlotWrapper[]"; +} + + diff --git a/src/attributes/NoBoxPlotWrapper.h b/src/attributes/NoBoxPlotWrapper.h new file mode 100644 index 000000000..d634b7542 --- /dev/null +++ b/src/attributes/NoBoxPlotWrapper.h @@ -0,0 +1,91 @@ + +/******************************* LICENSE ******************************* + + * (C) Copyright 1996-2016 ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * In applying this licence, ECMWF does not waive the privileges and immunities + * granted to it by virtue of its status as an intergovernmental organisation nor + * does it submit to any jurisdiction. + + ******************************* LICENSE *******************************/ + +/*! \fileNoBoxPlotAttributes.h + \brief Definition of NoBoxPlot Attributes class. + + This file is automatically generated. + Do Not Edit! + + Generated: +*/ + + +#ifndef NoBoxPlotWrapper_H +#define NoBoxPlotWrapper_H + +#include "magics.h" +#include "ParameterManager.h" +#include "Factory.h" + + + +#include "BoxPlotItem.h" + + + + + + + + + + +namespace magics { + +class MagRequest; + + + +class NoBoxPlotWrapper + +{ +public: +// -- constructor + NoBoxPlotWrapper(); + NoBoxPlotWrapper(NoBoxPlot*); +// -- destructor + virtual ~NoBoxPlotWrapper(); + virtual void set(const MagRequest&); + + NoBoxPlot* me() { return noboxplot_; } + + virtual NoBoxPlot* object() { return noboxplot_; } + + + virtual void object(NoBoxPlot* o) { + // Remember to delete the previous object + noboxplot_ = o; + + + } + + + +protected: + NoBoxPlot* noboxplot_; + + +// -- method + virtual void print(ostream&) const; + + +private: + string tag_; + friend ostream& operator<<(ostream& s,const NoBoxPlotWrapper& p) + { p.print(s); return s; } +}; + +} // namespace magics + +#endif \ No newline at end of file diff --git a/src/params/NoBoxPlot.xml b/src/params/NoBoxPlot.xml new file mode 100644 index 000000000..de1625af7 --- /dev/null +++ b/src/params/NoBoxPlot.xml @@ -0,0 +1,15 @@ + + + + diff --git a/src/params/NoBoxPlotBox.xml b/src/params/NoBoxPlotBox.xml new file mode 100644 index 000000000..6e28745db --- /dev/null +++ b/src/params/NoBoxPlotBox.xml @@ -0,0 +1,15 @@ + + + + diff --git a/src/params/NoBoxPlotWhisker.xml b/src/params/NoBoxPlotWhisker.xml new file mode 100644 index 000000000..ef2de0bff --- /dev/null +++ b/src/params/NoBoxPlotWhisker.xml @@ -0,0 +1,15 @@ + + + + From e6b7dea4089e6076aa154c60f856ba9dba32d216 Mon Sep 17 00:00:00 2001 From: Sylvie Lamy-Thepaut Date: Mon, 20 Nov 2023 15:09:18 +0000 Subject: [PATCH 03/18] Prepare version 4.15.0 --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2f8f063d3..395d95918 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -15,7 +15,7 @@ cmake_minimum_required( VERSION 3.12 FATAL_ERROR ) set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake" ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/../ecbuild/cmake") find_package( ecbuild 3.4 REQUIRED ) -project( magics VERSION 4.12.1 LANGUAGES CXX ) +project( magics VERSION 4.15.0 LANGUAGES CXX ) # make sure that the header files are installed into include/magics # note that this needs to be done before ecbuild_declare_project() From 04dcb8867feae425e57aabe17c6337bfe7740e86 Mon Sep 17 00:00:00 2001 From: Sylvie Lamy-Thepaut Date: Tue, 21 Nov 2023 13:51:13 +0000 Subject: [PATCH 04/18] Opencharts : Symbol Plotting by property --- src/visualisers/SymbolPlotting.cc | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/visualisers/SymbolPlotting.cc b/src/visualisers/SymbolPlotting.cc index cd8908985..362f29e88 100644 --- a/src/visualisers/SymbolPlotting.cc +++ b/src/visualisers/SymbolPlotting.cc @@ -200,8 +200,10 @@ void SymbolPlotting::by_property(Data& data, BasicGraphicsObjectContainer& out) height = height*property_height_scaling_factor_*factor; symbol->setHeight(height); + + PaperPoint xy = transformation(UserPoint(point->longitude(), point->latitude())); - symbol->push_back(transformation(PaperPoint(point->longitude(), point->latitude()))); + symbol->push_back(xy); out.push_back(symbol); @@ -251,7 +253,7 @@ void SymbolPlotting::operator()(Data& data, BasicGraphicsObjectContainer& out) { try { - const Transformation& transformation = out.transformation(); + // If we need to connect the symbols with a line, we need all the poinst // to enable proper clipping of the line! Othewise wee just nedde to get the point @@ -267,6 +269,7 @@ void SymbolPlotting::operator()(Data& data, BasicGraphicsObjectContainer& out) { points.setToFirst(); while (points.more()) { + PaperPoint xy = transformation(points.current()); (*this)(xy, out); points.advance(); From dae13d181674b4471e8ef7cba8d5ad8a1bd1faf3 Mon Sep 17 00:00:00 2001 From: Sylvie Lamy-Thepaut Date: Tue, 21 Nov 2023 17:21:44 +0000 Subject: [PATCH 05/18] Wind fix --- src/decoders/GribDecoder.cc | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/decoders/GribDecoder.cc b/src/decoders/GribDecoder.cc index 5ecabd94d..174789088 100644 --- a/src/decoders/GribDecoder.cc +++ b/src/decoders/GribDecoder.cc @@ -751,6 +751,9 @@ void GribDecoder::decode2D(const Transformation&) { } void GribDecoder::openField() { + + current_position_ = (large_field_position_) ? large_field_position_ : field_position_; + current_file_name_ = file_name_; field_ = open(field_); } @@ -758,7 +761,15 @@ void GribDecoder::openField() { void GribDecoder::openFirstComponent() { current_position_ = position_1_; - field_ = open(field_); + if (second_file_name_ == "grib_input_file_name") { + current_position_ = ( position_2_ == -1 ) ? 2 : position_2_; + current_file_name_= file_name_; + } + else { + current_position_ = ( position_2_ == -1 ) ? 1 : position_2_; + current_file_name_= second_file_name_; + } + } void GribDecoder::openSecondComponent() { From 44b871f48f3469b3690c7cdfa17552ed3ad2dc6a Mon Sep 17 00:00:00 2001 From: Sylvie Lamy-Thepaut Date: Tue, 21 Nov 2023 17:34:23 +0000 Subject: [PATCH 06/18] Fix grib decoding --- src/decoders/GribDecoder.cc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/decoders/GribDecoder.cc b/src/decoders/GribDecoder.cc index 174789088..a794082ec 100644 --- a/src/decoders/GribDecoder.cc +++ b/src/decoders/GribDecoder.cc @@ -1675,6 +1675,9 @@ string GribDecoder::representation() { current_handle_ = field_; // Now warning, no caching string proj = getstring("projTargetString", false, false); + // Here if proj contains latlong we ignore the setting . + if (proj.find("longlat") != std::string::npos) + proj = ""; return (proj.size()) ? "proj" : grid; } From 7c1910a36f5b8812a425749100f6fa9fe7b4078f Mon Sep 17 00:00:00 2001 From: Sylvie Lamy-Thepaut Date: Wed, 22 Nov 2023 11:47:00 +0000 Subject: [PATCH 07/18] Opencharts : Symbol Plotting by property --- src/visualisers/SymbolPlotting.cc | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/visualisers/SymbolPlotting.cc b/src/visualisers/SymbolPlotting.cc index 362f29e88..aedc5782d 100644 --- a/src/visualisers/SymbolPlotting.cc +++ b/src/visualisers/SymbolPlotting.cc @@ -200,10 +200,20 @@ void SymbolPlotting::by_property(Data& data, BasicGraphicsObjectContainer& out) height = height*property_height_scaling_factor_*factor; symbol->setHeight(height); + + UserPoint geo = UserPoint(point->longitude(), point->latitude()); + std::stack duplicates; + transformation.wraparound(geo, duplicates); + while (duplicates.empty() == false) { + PaperPoint xy = transformation(duplicates.top()); + symbol->push_back(xy); + duplicates.pop(); + + } - PaperPoint xy = transformation(UserPoint(point->longitude(), point->latitude())); + // PaperPoint xy = transformation(UserPoint(point->longitude(), point->latitude())); - symbol->push_back(xy); + // symbol->push_back(xy); out.push_back(symbol); From 5950f3540b16882e368fde93e4f81ca8125a95bb Mon Sep 17 00:00:00 2001 From: Sylvie Lamy-Thepaut Date: Wed, 22 Nov 2023 17:47:20 +0000 Subject: [PATCH 08/18] Revert in progress --- src/basic/FortranMagics.cc | 10 +++-- src/decoders/GribDecoder.cc | 16 +++++--- src/decoders/GribRegularInterpretor.cc | 2 +- src/visualisers/GradientsColourTechnique.cc | 8 ++-- src/visualisers/IntervalSelectionType.cc | 44 +++++++++++---------- 5 files changed, 45 insertions(+), 35 deletions(-) diff --git a/src/basic/FortranMagics.cc b/src/basic/FortranMagics.cc index bf0ea4110..cfd91bc10 100644 --- a/src/basic/FortranMagics.cc +++ b/src/basic/FortranMagics.cc @@ -8,7 +8,7 @@ * nor does it submit to any jurisdiction. */ -/*! \file FortranMagics.cc +/*! \file ics.cc \brief Implementation of the Template class FortranMagics. Magics Team - ECMWF 2007 @@ -435,7 +435,9 @@ void FortranMagics::pobs() { if (!action_ || obsinput_todo_ ) { action_ = new VisualAction(); ObsDecoder* obs = new ObsDecoder(); + cout << "OBS" << endl; if (obs->defined()) { + cout << "defined" << endl; action_->data(obs); top()->push_back(action_); @@ -446,9 +448,9 @@ void FortranMagics::pobs() { top()->push_back(action_); } } - action_ = new VisualAction(); - action_->data(new ObsJSon()); - top()->push_back(action_); + // action_ = new VisualAction(); + // action_->data(new ObsJSon()); + // top()->push_back(action_); action_->visdef(new ObsPlotting()); } diff --git a/src/decoders/GribDecoder.cc b/src/decoders/GribDecoder.cc index a794082ec..fca87cbbe 100644 --- a/src/decoders/GribDecoder.cc +++ b/src/decoders/GribDecoder.cc @@ -760,20 +760,21 @@ void GribDecoder::openField() { void GribDecoder::openFirstComponent() { current_position_ = position_1_; - - if (second_file_name_ == "grib_input_file_name") { - current_position_ = ( position_2_ == -1 ) ? 2 : position_2_; + + if (first_file_name_ == "grib_input_file_name") { current_file_name_= file_name_; } else { - current_position_ = ( position_2_ == -1 ) ? 1 : position_2_; - current_file_name_= second_file_name_; + current_file_name_= first_file_name_; } + MagLog::debug() << "received-> " << current_position_ << " from file " << current_file_name_ < " << position_2_ << " from file " << second_file_name_ < levels; - double lmax, lmin; - if (shading) { - if (max_shade_ < min_shade_) - MagLog::warning() << "contour_shade_max_level (" << max_shade_ << ") < contour_shade_min_level (" - << min_shade_ << "): Please check your code" << endl; - if (same(max_, 1.0e+21)) { - max_ = max_shade_; - } - if (same(min_, -1.0e+21)) { - min_ = min_shade_; - } - } - + double min_level=min; + double max_level=max; - lmax = same(max_, 1.0e+21) ? max : max_; - lmin = same(min_, -1.0e+21) ? min : min_; + if ( MINSET(min_) ) + min_level = min_; + + if ( MAXSET(max_) ) + max_level = max_; + if ( shading && MINSET(min_shade_) ) + min_level = min_shade_; + + if ( shading && MAXSET(max_shade_) ) + max_level = max_shade_; + - levels.insert(lmin); - levels.insert(lmax); + levels.insert(min_level); + levels.insert(max_level); + double level = reference_; double newref; int i = 1; - while (level < lmax && !same(level, lmax)) { - if (level > lmin) + while (level < max_level && !same(level, max_level)) { + if (level > min_level) levels.insert(level); level = reference_ + (i * interval_); i++; } level = reference_; i = 1; - while (level > lmin && !same(level, lmin)) { - if (level < lmax) + while (level > min_level && !same(level, min_level)) { + if (level < max_level) levels.insert(level); level = reference_ - (i * interval_); i++; From 8244a4dd4ad9a6e1b9fe009bab1b64e887b7f70d Mon Sep 17 00:00:00 2001 From: Sylvie Lamy-Thepaut Date: Fri, 24 Nov 2023 09:28:38 +0000 Subject: [PATCH 09/18] Reverting grib_field_large_position --- src/attributes/GribDecoderAttributes.cc | 7 ------- src/attributes/GribDecoderAttributes.h | 1 - src/attributes/GribDecoderWrapper.cc | 4 ---- src/decoders/GribDecoder.cc | 3 ++- src/params/GribDecoder.xml | 4 ++-- 5 files changed, 4 insertions(+), 15 deletions(-) diff --git a/src/attributes/GribDecoderAttributes.cc b/src/attributes/GribDecoderAttributes.cc index 8c44856a1..6251e0677 100644 --- a/src/attributes/GribDecoderAttributes.cc +++ b/src/attributes/GribDecoderAttributes.cc @@ -41,7 +41,6 @@ GribDecoderAttributes::GribDecoderAttributes(): expver_(ParameterManager::getBool("grib_text_experiment")), units_(ParameterManager::getBool("grib_text_units")), field_position_(ParameterManager::getInt("grib_field_position")), - large_field_position_(ParameterManager::getULong("grib_field_large_position")), position_1_(ParameterManager::getInt("grib_wind_position_1")), position_2_(ParameterManager::getInt("grib_wind_position_2")), colour_position_(ParameterManager::getInt("grib_wind_position_colour")), @@ -87,7 +86,6 @@ void GribDecoderAttributes::set(const std::map& params) setAttribute(prefix, "grib_text_experiment", expver_, params); setAttribute(prefix, "grib_text_units", units_, params); setAttribute(prefix, "grib_field_position", field_position_, params); - setAttribute(prefix, "grib_field_large_position", large_field_position_, params); setAttribute(prefix, "grib_wind_position_1", position_1_, params); setAttribute(prefix, "grib_wind_position_2", position_2_, params); setAttribute(prefix, "grib_wind_position_colour", colour_position_, params); @@ -120,7 +118,6 @@ void GribDecoderAttributes::copy(const GribDecoderAttributes& other) expver_ = other.expver_; units_ = other.units_; field_position_ = other.field_position_; - large_field_position_ = other.large_field_position_; position_1_ = other.position_1_; position_2_ = other.position_2_; colour_position_ = other.colour_position_; @@ -193,7 +190,6 @@ void GribDecoderAttributes::print(ostream& out) const out << " expver = " << expver_; out << " units = " << units_; out << " field_position = " << field_position_; - out << " large_field_position = " << large_field_position_; out << " position_1 = " << position_1_; out << " position_2 = " << position_2_; out << " colour_position = " << colour_position_; @@ -243,8 +239,6 @@ void GribDecoderAttributes::toxml(ostream& out) const niceprint(out,units_); out << ", \"grib_field_position\":"; niceprint(out,field_position_); - out << ", \"grib_field_large_position\":"; - niceprint(out,large_field_position_); out << ", \"grib_wind_position_1\":"; niceprint(out,position_1_); out << ", \"grib_wind_position_2\":"; @@ -284,7 +278,6 @@ static MagicsParameter grib_interpolation_method_missing_fill_count("grib_i static MagicsParameter grib_text_experiment("grib_text_experiment", "off"); static MagicsParameter grib_text_units("grib_text_units", "off"); static MagicsParameter grib_field_position("grib_field_position", 1); -static MagicsParameter grib_field_large_position("grib_field_large_position", 0); static MagicsParameter grib_wind_position_1("grib_wind_position_1", 1); static MagicsParameter grib_wind_position_2("grib_wind_position_2", -1); static MagicsParameter grib_wind_position_colour("grib_wind_position_colour", -1); diff --git a/src/attributes/GribDecoderAttributes.h b/src/attributes/GribDecoderAttributes.h index 090aa4ba8..9397e46a0 100644 --- a/src/attributes/GribDecoderAttributes.h +++ b/src/attributes/GribDecoderAttributes.h @@ -68,7 +68,6 @@ class GribDecoderAttributes bool expver_; bool units_; int field_position_; - unsigned long long large_field_position_; int position_1_; int position_2_; int colour_position_; diff --git a/src/attributes/GribDecoderWrapper.cc b/src/attributes/GribDecoderWrapper.cc index cec441ce6..903cd432f 100644 --- a/src/attributes/GribDecoderWrapper.cc +++ b/src/attributes/GribDecoderWrapper.cc @@ -129,10 +129,6 @@ void GribDecoderWrapper::set(const MagRequest& request) int field_position_value = request("GRIB_FIELD_POSITION"); gribdecoder_->field_position_ = field_position_value; } - if (request.countValues("GRIB_FIELD_LARGE_POSITION") ) { - unsigned long long large_field_position_value = request("GRIB_FIELD_LARGE_POSITION"); - gribdecoder_->large_field_position_ = large_field_position_value; - } if (request.countValues("GRIB_WIND_POSITION_1") ) { int position_1_value = request("GRIB_WIND_POSITION_1"); gribdecoder_->position_1_ = position_1_value; diff --git a/src/decoders/GribDecoder.cc b/src/decoders/GribDecoder.cc index fca87cbbe..729929120 100644 --- a/src/decoders/GribDecoder.cc +++ b/src/decoders/GribDecoder.cc @@ -752,7 +752,8 @@ void GribDecoder::decode2D(const Transformation&) { void GribDecoder::openField() { - current_position_ = (large_field_position_) ? large_field_position_ : field_position_; + // current_position_ = (large_field_position_) ? large_field_position_ : field_position_; + current_position_ = field_position_; current_file_name_ = file_name_; field_ = open(field_); diff --git a/src/params/GribDecoder.xml b/src/params/GribDecoder.xml index 97b1a55f0..831b43d69 100644 --- a/src/params/GribDecoder.xml +++ b/src/params/GribDecoder.xml @@ -163,13 +163,13 @@ does it submit to any jurisdiction. name="grib_field_position"> The position in the input file of a field other than a wind component - used when the offset is too big - + Date: Fri, 24 Nov 2023 11:08:22 +0000 Subject: [PATCH 10/18] Reverting grib_wind_large_position and --- src/attributes/GribDecoderAttributes.cc | 21 --------------------- src/attributes/GribDecoderAttributes.h | 3 --- src/attributes/GribDecoderWrapper.cc | 12 ------------ src/params/GribDecoder.xml | 4 ++-- 4 files changed, 2 insertions(+), 38 deletions(-) diff --git a/src/attributes/GribDecoderAttributes.cc b/src/attributes/GribDecoderAttributes.cc index 6251e0677..23385a67a 100644 --- a/src/attributes/GribDecoderAttributes.cc +++ b/src/attributes/GribDecoderAttributes.cc @@ -44,9 +44,6 @@ GribDecoderAttributes::GribDecoderAttributes(): position_1_(ParameterManager::getInt("grib_wind_position_1")), position_2_(ParameterManager::getInt("grib_wind_position_2")), colour_position_(ParameterManager::getInt("grib_wind_position_colour")), - large_position_1_(ParameterManager::getULong("grib_wind_large_position_1")), - large_position_2_(ParameterManager::getULong("grib_wind_large_position_2")), - large_colour_position_(ParameterManager::getULong("grib_wind_large_position_colour")), missing_value_(ParameterManager::getDouble("grib_missing_value_indicator")), wind_style_(ParameterManager::getBool("grib_wind_style")) , @@ -89,9 +86,6 @@ void GribDecoderAttributes::set(const std::map& params) setAttribute(prefix, "grib_wind_position_1", position_1_, params); setAttribute(prefix, "grib_wind_position_2", position_2_, params); setAttribute(prefix, "grib_wind_position_colour", colour_position_, params); - setAttribute(prefix, "grib_wind_large_position_1", large_position_1_, params); - setAttribute(prefix, "grib_wind_large_position_2", large_position_2_, params); - setAttribute(prefix, "grib_wind_large_position_colour", large_colour_position_, params); setAttribute(prefix, "grib_missing_value_indicator", missing_value_, params); setAttribute(prefix, "grib_wind_style", wind_style_, params); @@ -121,9 +115,6 @@ void GribDecoderAttributes::copy(const GribDecoderAttributes& other) position_1_ = other.position_1_; position_2_ = other.position_2_; colour_position_ = other.colour_position_; - large_position_1_ = other.large_position_1_; - large_position_2_ = other.large_position_2_; - large_colour_position_ = other.large_colour_position_; missing_value_ = other.missing_value_; wind_style_ = other.wind_style_; address_mode_ = unique_ptr(other.address_mode_->clone()); @@ -193,9 +184,6 @@ void GribDecoderAttributes::print(ostream& out) const out << " position_1 = " << position_1_; out << " position_2 = " << position_2_; out << " colour_position = " << colour_position_; - out << " large_position_1 = " << large_position_1_; - out << " large_position_2 = " << large_position_2_; - out << " large_colour_position = " << large_colour_position_; out << " missing_value = " << missing_value_; out << " wind_style = " << wind_style_; out << " address_mode = " << *address_mode_; @@ -245,12 +233,6 @@ void GribDecoderAttributes::toxml(ostream& out) const niceprint(out,position_2_); out << ", \"grib_wind_position_colour\":"; niceprint(out,colour_position_); - out << ", \"grib_wind_large_position_1\":"; - niceprint(out,large_position_1_); - out << ", \"grib_wind_large_position_2\":"; - niceprint(out,large_position_2_); - out << ", \"grib_wind_large_position_colour\":"; - niceprint(out,large_colour_position_); out << ", \"grib_missing_value_indicator\":"; niceprint(out,missing_value_); out << ", \"grib_wind_style\":"; @@ -281,9 +263,6 @@ static MagicsParameter grib_field_position("grib_field_position", 1); static MagicsParameter grib_wind_position_1("grib_wind_position_1", 1); static MagicsParameter grib_wind_position_2("grib_wind_position_2", -1); static MagicsParameter grib_wind_position_colour("grib_wind_position_colour", -1); -static MagicsParameter grib_wind_large_position_1("grib_wind_large_position_1", 0); -static MagicsParameter grib_wind_large_position_2("grib_wind_large_position_2", 0); -static MagicsParameter grib_wind_large_position_colour("grib_wind_large_position_colour", 0); static MagicsParameter grib_missing_value_indicator("grib_missing_value_indicator", -1.5e+21); static MagicsParameter grib_wind_style("grib_wind_style", "off"); static MagicsParameter grib_file_address_mode("grib_file_address_mode", "record"); diff --git a/src/attributes/GribDecoderAttributes.h b/src/attributes/GribDecoderAttributes.h index 9397e46a0..e096edeaf 100644 --- a/src/attributes/GribDecoderAttributes.h +++ b/src/attributes/GribDecoderAttributes.h @@ -71,9 +71,6 @@ class GribDecoderAttributes int position_1_; int position_2_; int colour_position_; - unsigned long long large_position_1_; - unsigned long long large_position_2_; - unsigned long long large_colour_position_; double missing_value_; bool wind_style_; unique_ptr address_mode_; diff --git a/src/attributes/GribDecoderWrapper.cc b/src/attributes/GribDecoderWrapper.cc index 903cd432f..008b6cf54 100644 --- a/src/attributes/GribDecoderWrapper.cc +++ b/src/attributes/GribDecoderWrapper.cc @@ -141,18 +141,6 @@ void GribDecoderWrapper::set(const MagRequest& request) int colour_position_value = request("GRIB_WIND_POSITION_COLOUR"); gribdecoder_->colour_position_ = colour_position_value; } - if (request.countValues("GRIB_WIND_LARGE_POSITION_1") ) { - unsigned long long large_position_1_value = request("GRIB_WIND_LARGE_POSITION_1"); - gribdecoder_->large_position_1_ = large_position_1_value; - } - if (request.countValues("GRIB_WIND_LARGE_POSITION_2") ) { - unsigned long long large_position_2_value = request("GRIB_WIND_LARGE_POSITION_2"); - gribdecoder_->large_position_2_ = large_position_2_value; - } - if (request.countValues("GRIB_WIND_LARGE_POSITION_COLOUR") ) { - unsigned long long large_colour_position_value = request("GRIB_WIND_LARGE_POSITION_COLOUR"); - gribdecoder_->large_colour_position_ = large_colour_position_value; - } if (request.countValues("GRIB_MISSING_VALUE_INDICATOR") ) { double missing_value_value = request("GRIB_MISSING_VALUE_INDICATOR"); gribdecoder_->missing_value_ = missing_value_value; diff --git a/src/params/GribDecoder.xml b/src/params/GribDecoder.xml index 831b43d69..ac740dd39 100644 --- a/src/params/GribDecoder.xml +++ b/src/params/GribDecoder.xml @@ -191,7 +191,7 @@ does it submit to any jurisdiction. name="grib_wind_position_colour"> The position in the input file of a wind component field used to colour the flag - The position in the input file of a wind component field used to colour the flag - + Date: Fri, 24 Nov 2023 11:57:11 +0000 Subject: [PATCH 11/18] Symbol Plotting legend for CAMS plots. --- src/attributes/SymbolPlottingAttributes.cc | 21 ------ src/attributes/SymbolPlottingAttributes.h | 3 - src/attributes/SymbolPlottingWrapper.cc | 12 --- src/params/SymbolPlotting.xml | 25 +------ src/visualisers/SymbolPlotting.cc | 86 +++++++++++++++------- src/visualisers/SymbolPlotting.h | 6 +- 6 files changed, 65 insertions(+), 88 deletions(-) diff --git a/src/attributes/SymbolPlottingAttributes.cc b/src/attributes/SymbolPlottingAttributes.cc index 72b0c0f68..217725b34 100644 --- a/src/attributes/SymbolPlottingAttributes.cc +++ b/src/attributes/SymbolPlottingAttributes.cc @@ -46,9 +46,6 @@ SymbolPlottingAttributes::SymbolPlottingAttributes(): 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")), - 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")), @@ -94,9 +91,6 @@ void SymbolPlottingAttributes::set(const std::map& 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); - 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); @@ -130,9 +124,6 @@ void SymbolPlottingAttributes::copy(const SymbolPlottingAttributes& other) 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_; - 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()); @@ -202,9 +193,6 @@ void SymbolPlottingAttributes::print(ostream& out) const 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_; - 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_; @@ -260,12 +248,6 @@ void SymbolPlottingAttributes::toxml(ostream& out) const 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\":"; @@ -302,9 +284,6 @@ static MagicsParameter symbol_property_lightness_values_list("symbo 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", ""); -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"); diff --git a/src/attributes/SymbolPlottingAttributes.h b/src/attributes/SymbolPlottingAttributes.h index d41a04925..2d46d6ff7 100644 --- a/src/attributes/SymbolPlottingAttributes.h +++ b/src/attributes/SymbolPlottingAttributes.h @@ -73,9 +73,6 @@ class SymbolPlottingAttributes double property_saturation_value_; 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_; diff --git a/src/attributes/SymbolPlottingWrapper.cc b/src/attributes/SymbolPlottingWrapper.cc index bdd416614..f57fd136b 100644 --- a/src/attributes/SymbolPlottingWrapper.cc +++ b/src/attributes/SymbolPlottingWrapper.cc @@ -155,18 +155,6 @@ void SymbolPlottingWrapper::set(const MagRequest& request) 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; diff --git a/src/params/SymbolPlotting.xml b/src/params/SymbolPlotting.xml index 571a3d491..e2c28d46a 100644 --- a/src/params/SymbolPlotting.xml +++ b/src/params/SymbolPlotting.xml @@ -328,30 +328,7 @@ does it submit to any jurisdiction. 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 - + needs; - - needs.insert(property_height_name_); - needs.insert(property_hue_name_); - needs.insert(property_lightness_name_); - - - if ( property_hue_list_.empty() ) - property_hue_list_.push_back(1); - if ( property_lightness_list_.empty() ) - property_lightness_list_.push_back(0.5); - - - IntervalMap hueFinder; +void SymbolPlotting::by_property_prepare(IntervalMap& hueFinder, IntervalMap& lightnessFinder) +{ 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(); @@ -162,10 +143,32 @@ void SymbolPlotting::by_property(Data& data, BasicGraphicsObjectContainer& out) lightness++; ++value_lightness; } +} +void SymbolPlotting::by_property(Data& data, BasicGraphicsObjectContainer& out) { + const Transformation& transformation = out.transformation(); - Colour red("red"); + std::set needs; + + needs.insert(property_height_name_); + needs.insert(property_hue_name_); + needs.insert(property_lightness_name_); + + + if ( property_hue_list_.empty() ) + property_hue_list_.push_back(1); + if ( property_lightness_list_.empty() ) + property_lightness_list_.push_back(0.5); + + + IntervalMap hueFinder; + IntervalMap lightnessFinder; + + by_property_prepare(hueFinder, lightnessFinder); + + + Colour red("blue"); double factor = ( out.absoluteHeight()*transformation.patchDistance(1))/(transformation.getMaxPCY()-transformation.getMinPCY()) ; @@ -189,6 +192,7 @@ void SymbolPlotting::by_property(Data& data, BasicGraphicsObjectContainer& out) Hsl hsl(hueFinder.find(hue, 0), property_saturation_value_, lightnessFinder.find(lightness, 0.5)); Colour colour(hsl); + cout << colour << endl; symbol->setColour(colour); @@ -210,11 +214,6 @@ void SymbolPlotting::by_property(Data& data, BasicGraphicsObjectContainer& out) duplicates.pop(); } - - // PaperPoint xy = transformation(UserPoint(point->longitude(), point->latitude())); - - // symbol->push_back(xy); - out.push_back(symbol); } @@ -312,11 +311,44 @@ void SymbolPlotting::operator()(Data& data, BasicGraphicsObjectContainer& out) { } } + +void SymbolPlotting::by_property_legend(Data& data, LegendVisitor& legend) { + + IntervalMap hueFinder; + IntervalMap lightnessFinder; + + by_property_prepare(hueFinder, lightnessFinder); + + + + for (IntervalMap::const_iterator hue = hueFinder.begin(); hue != hueFinder.end(); ++hue) + for (IntervalMap::const_iterator lightness = lightnessFinder.begin(); lightness != lightnessFinder.end(); ++lightness) + { + Polyline* box = new Polyline(); + double min = lightness->first.min_; + double max = lightness->first.max_; + + box->setShading(new FillShadingProperties()); + + Hsl hsl(hue->second, property_saturation_value_, lightness->second); + Colour colour(hsl); + cout << "add legend " << colour << endl; + + box->setFillColour(colour); + box->setFilled(true); + + legend.add(new BoxEntry(min, max, box)); + } +} + void SymbolPlotting::visit(Data& data, LegendVisitor& legend) { MagLog::debug() << " SymbolPlotting::visit to create a legend ... " << "\n"; if (!legend_) return; + if ( magCompare("property", type_) ) + return by_property_legend(data, legend); + (*mode_).visit(data, legend); } diff --git a/src/visualisers/SymbolPlotting.h b/src/visualisers/SymbolPlotting.h index 3811571ca..322849b11 100644 --- a/src/visualisers/SymbolPlotting.h +++ b/src/visualisers/SymbolPlotting.h @@ -44,9 +44,13 @@ class SymbolPlotting : public SymbolPlottingAttributes, public Visdef { virtual void operator()(Data&, BasicGraphicsObjectContainer&) override; - void by_property(Data&, BasicGraphicsObjectContainer&); + virtual void visit(Data&, LegendVisitor&) override; + void by_property(Data&, BasicGraphicsObjectContainer&); + void by_property_legend(Data&, LegendVisitor&); + void by_property_prepare(IntervalMap&, IntervalMap&); bool needLegend() override { return legend_; } + virtual void visit(Data&, HistoVisitor&) override; void operator()(const PaperPoint&, BasicGraphicsObjectContainer&) const; void getReady(const LegendVisitor& legend) override; From b4f86cef9fef1b0cd11621109cf9a45a2dd3395a Mon Sep 17 00:00:00 2001 From: Sylvie Lamy-Thepaut Date: Tue, 28 Nov 2023 17:46:32 +0000 Subject: [PATCH 12/18] Adding Point and SegmentJoiner in the Magics namespace to avoid confusion with other definitions. --- src/visualisers/SegmentJoiner.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/visualisers/SegmentJoiner.h b/src/visualisers/SegmentJoiner.h index 9e7f901a9..10ff53014 100644 --- a/src/visualisers/SegmentJoiner.h +++ b/src/visualisers/SegmentJoiner.h @@ -23,6 +23,8 @@ using namespace std; +namespace magics { + struct Point { double x_; double y_; @@ -143,4 +145,6 @@ class SegmentJoiner { bool dirty_; }; +} + #endif From 973a1462ac714b259d7a39951aedc8335b40c221 Mon Sep 17 00:00:00 2001 From: Sylvie Lamy-Thepaut Date: Wed, 29 Nov 2023 10:57:19 +0000 Subject: [PATCH 13/18] Compilation issues aftre the merge --- src/attributes/GeoJSonAttributes.cc | 3 +- src/attributes/GribDecoderAttributes.cc | 25 ----- src/attributes/GribDecoderAttributes.h | 4 - src/attributes/GribDecoderWrapper.cc | 16 --- .../NoBoxPlotBoxBorderAttributes.cc | 100 ++++++++++++++++++ src/attributes/NoBoxPlotBoxBorderAttributes.h | 63 +++++++++++ src/attributes/NoBoxPlotBoxBorderWrapper.cc | 67 ++++++++++++ src/attributes/NoBoxPlotBoxBorderWrapper.h | 91 ++++++++++++++++ src/attributes/NoBoxPlotMedianAttributes.cc | 100 ++++++++++++++++++ src/attributes/NoBoxPlotMedianAttributes.h | 63 +++++++++++ src/attributes/NoBoxPlotMedianWrapper.cc | 67 ++++++++++++ src/attributes/NoBoxPlotMedianWrapper.h | 91 ++++++++++++++++ src/attributes/SymbolPlottingAttributes.h | 1 - src/params/GribDecoder.xml | 25 +---- src/params/SymbolPlotting.xml | 4 +- src/visualisers/IntervalSelectionType.cc | 8 +- 16 files changed, 649 insertions(+), 79 deletions(-) create mode 100644 src/attributes/NoBoxPlotBoxBorderAttributes.cc create mode 100644 src/attributes/NoBoxPlotBoxBorderAttributes.h create mode 100644 src/attributes/NoBoxPlotBoxBorderWrapper.cc create mode 100644 src/attributes/NoBoxPlotBoxBorderWrapper.h create mode 100644 src/attributes/NoBoxPlotMedianAttributes.cc create mode 100644 src/attributes/NoBoxPlotMedianAttributes.h create mode 100644 src/attributes/NoBoxPlotMedianWrapper.cc create mode 100644 src/attributes/NoBoxPlotMedianWrapper.h diff --git a/src/attributes/GeoJSonAttributes.cc b/src/attributes/GeoJSonAttributes.cc index 2c3672dd4..ab58f95be 100644 --- a/src/attributes/GeoJSonAttributes.cc +++ b/src/attributes/GeoJSonAttributes.cc @@ -30,7 +30,7 @@ GeoJSonAttributes::GeoJSonAttributes(): input_(ParameterManager::getString("geojson_input")), binning_resolution_(ParameterManager::getDouble("geojson_binning_grid_resolution")), value_(ParameterManager::getString("geojson_value_property")) - + { } @@ -54,7 +54,6 @@ void GeoJSonAttributes::set(const std::map& params) setAttribute(prefix, "geojson_binning_grid_resolution", binning_resolution_, params); setAttribute(prefix, "geojson_value_property", value_, params); - cout << value_ << endl; } diff --git a/src/attributes/GribDecoderAttributes.cc b/src/attributes/GribDecoderAttributes.cc index 3c567c1d9..23385a67a 100644 --- a/src/attributes/GribDecoderAttributes.cc +++ b/src/attributes/GribDecoderAttributes.cc @@ -41,13 +41,9 @@ GribDecoderAttributes::GribDecoderAttributes(): expver_(ParameterManager::getBool("grib_text_experiment")), units_(ParameterManager::getBool("grib_text_units")), field_position_(ParameterManager::getInt("grib_field_position")), - large_field_position_(ParameterManager::getULong("grib_field_large_position")), position_1_(ParameterManager::getInt("grib_wind_position_1")), position_2_(ParameterManager::getInt("grib_wind_position_2")), colour_position_(ParameterManager::getInt("grib_wind_position_colour")), - large_position_1_(ParameterManager::getULong("grib_wind_large_position_1")), - large_position_2_(ParameterManager::getULong("grib_wind_large_position_2")), - large_colour_position_(ParameterManager::getULong("grib_wind_large_position_colour")), missing_value_(ParameterManager::getDouble("grib_missing_value_indicator")), wind_style_(ParameterManager::getBool("grib_wind_style")) , @@ -87,13 +83,9 @@ void GribDecoderAttributes::set(const std::map& params) setAttribute(prefix, "grib_text_experiment", expver_, params); setAttribute(prefix, "grib_text_units", units_, params); setAttribute(prefix, "grib_field_position", field_position_, params); - setAttribute(prefix, "grib_field_large_position", large_field_position_, params); setAttribute(prefix, "grib_wind_position_1", position_1_, params); setAttribute(prefix, "grib_wind_position_2", position_2_, params); setAttribute(prefix, "grib_wind_position_colour", colour_position_, params); - setAttribute(prefix, "grib_wind_large_position_1", large_position_1_, params); - setAttribute(prefix, "grib_wind_large_position_2", large_position_2_, params); - setAttribute(prefix, "grib_wind_large_position_colour", large_colour_position_, params); setAttribute(prefix, "grib_missing_value_indicator", missing_value_, params); setAttribute(prefix, "grib_wind_style", wind_style_, params); @@ -120,13 +112,9 @@ void GribDecoderAttributes::copy(const GribDecoderAttributes& other) expver_ = other.expver_; units_ = other.units_; field_position_ = other.field_position_; - large_field_position_ = other.large_field_position_; position_1_ = other.position_1_; position_2_ = other.position_2_; colour_position_ = other.colour_position_; - large_position_1_ = other.large_position_1_; - large_position_2_ = other.large_position_2_; - large_colour_position_ = other.large_colour_position_; missing_value_ = other.missing_value_; wind_style_ = other.wind_style_; address_mode_ = unique_ptr(other.address_mode_->clone()); @@ -193,13 +181,9 @@ void GribDecoderAttributes::print(ostream& out) const out << " expver = " << expver_; out << " units = " << units_; out << " field_position = " << field_position_; - out << " large_field_position = " << large_field_position_; out << " position_1 = " << position_1_; out << " position_2 = " << position_2_; out << " colour_position = " << colour_position_; - out << " large_position_1 = " << large_position_1_; - out << " large_position_2 = " << large_position_2_; - out << " large_colour_position = " << large_colour_position_; out << " missing_value = " << missing_value_; out << " wind_style = " << wind_style_; out << " address_mode = " << *address_mode_; @@ -243,20 +227,12 @@ void GribDecoderAttributes::toxml(ostream& out) const niceprint(out,units_); out << ", \"grib_field_position\":"; niceprint(out,field_position_); - out << ", \"grib_field_large_position\":"; - niceprint(out,large_field_position_); out << ", \"grib_wind_position_1\":"; niceprint(out,position_1_); out << ", \"grib_wind_position_2\":"; niceprint(out,position_2_); out << ", \"grib_wind_position_colour\":"; niceprint(out,colour_position_); - out << ", \"grib_wind_large_position_1\":"; - niceprint(out,large_position_1_); - out << ", \"grib_wind_large_position_2\":"; - niceprint(out,large_position_2_); - out << ", \"grib_wind_large_position_colour\":"; - niceprint(out,large_colour_position_); out << ", \"grib_missing_value_indicator\":"; niceprint(out,missing_value_); out << ", \"grib_wind_style\":"; @@ -284,7 +260,6 @@ static MagicsParameter grib_interpolation_method_missing_fill_count("grib_i static MagicsParameter grib_text_experiment("grib_text_experiment", "off"); static MagicsParameter grib_text_units("grib_text_units", "off"); static MagicsParameter grib_field_position("grib_field_position", 1); -static MagicsParameter grib_field_large_position("grib_field_large_position", 0); static MagicsParameter grib_wind_position_1("grib_wind_position_1", 1); static MagicsParameter grib_wind_position_2("grib_wind_position_2", -1); static MagicsParameter grib_wind_position_colour("grib_wind_position_colour", -1); diff --git a/src/attributes/GribDecoderAttributes.h b/src/attributes/GribDecoderAttributes.h index 090aa4ba8..e096edeaf 100644 --- a/src/attributes/GribDecoderAttributes.h +++ b/src/attributes/GribDecoderAttributes.h @@ -68,13 +68,9 @@ class GribDecoderAttributes bool expver_; bool units_; int field_position_; - unsigned long long large_field_position_; int position_1_; int position_2_; int colour_position_; - unsigned long long large_position_1_; - unsigned long long large_position_2_; - unsigned long long large_colour_position_; double missing_value_; bool wind_style_; unique_ptr address_mode_; diff --git a/src/attributes/GribDecoderWrapper.cc b/src/attributes/GribDecoderWrapper.cc index 50e0c340e..008b6cf54 100644 --- a/src/attributes/GribDecoderWrapper.cc +++ b/src/attributes/GribDecoderWrapper.cc @@ -129,10 +129,6 @@ void GribDecoderWrapper::set(const MagRequest& request) int field_position_value = request("GRIB_FIELD_POSITION"); gribdecoder_->field_position_ = field_position_value; } - if (request.countValues("GRIB_FIELD_LARGE_POSITION") ) { - // unsigned long long large_field_position_value = request("GRIB_FIELD_LARGE_POSITION"); - // gribdecoder_->large_field_position_ = large_field_position_value; - } if (request.countValues("GRIB_WIND_POSITION_1") ) { int position_1_value = request("GRIB_WIND_POSITION_1"); gribdecoder_->position_1_ = position_1_value; @@ -145,18 +141,6 @@ void GribDecoderWrapper::set(const MagRequest& request) int colour_position_value = request("GRIB_WIND_POSITION_COLOUR"); gribdecoder_->colour_position_ = colour_position_value; } - if (request.countValues("GRIB_WIND_LARGE_POSITION_1") ) { - // unsigned long long large_position_1_value = request("GRIB_WIND_LARGE_POSITION_1"); - // gribdecoder_->large_position_1_ = large_position_1_value; - } - if (request.countValues("GRIB_WIND_LARGE_POSITION_2") ) { - // unsigned long long large_position_2_value = request("GRIB_WIND_LARGE_POSITION_2"); - // gribdecoder_->large_position_2_ = large_position_2_value; - } - if (request.countValues("GRIB_WIND_LARGE_POSITION_COLOUR") ) { - // unsigned long long large_colour_position_value = request("GRIB_WIND_LARGE_POSITION_COLOUR"); - // gribdecoder_->large_colour_position_ = large_colour_position_value; - } if (request.countValues("GRIB_MISSING_VALUE_INDICATOR") ) { double missing_value_value = request("GRIB_MISSING_VALUE_INDICATOR"); gribdecoder_->missing_value_ = missing_value_value; diff --git a/src/attributes/NoBoxPlotBoxBorderAttributes.cc b/src/attributes/NoBoxPlotBoxBorderAttributes.cc new file mode 100644 index 000000000..fdfea170c --- /dev/null +++ b/src/attributes/NoBoxPlotBoxBorderAttributes.cc @@ -0,0 +1,100 @@ + +/****************************** LICENSE ******************************* + + * (C) Copyright 1996-2017 ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * In applying this licence, ECMWF does not waive the privileges and immunities + * granted to it by virtue of its status as an intergovernmental organisation nor + * does it submit to any jurisdiction. + + ******************************* LICENSE *******************************/ + +/*! \\file NoBoxPlotBoxBorderAttributes.h + \\brief Definition of NoBoxPlotBoxBorder Attributes class. + + This file is automatically generated. + Do Not Edit! +*/ + +#include "NoBoxPlotBoxBorderAttributes.h" +#include "MagicsParameter.h" +#include "ParameterSettings.h" + +using namespace magics; + +NoBoxPlotBoxBorderAttributes::NoBoxPlotBoxBorderAttributes() + + +{ +} + + +NoBoxPlotBoxBorderAttributes::~NoBoxPlotBoxBorderAttributes() +{ + +} + + +void NoBoxPlotBoxBorderAttributes::set(const std::map& params) +{ + vector prefix(2); + int i = 0; + prefix[i++] = "boxplot"; + prefix[i++] = "boxplot_median"; + + + +} + +void NoBoxPlotBoxBorderAttributes::copy(const NoBoxPlotBoxBorderAttributes& other) +{ + +} + + +bool NoBoxPlotBoxBorderAttributes::accept(const string& node) +{ + + if ( magCompare(node, "median") ) + return true; + + return false; +} + +void NoBoxPlotBoxBorderAttributes::set(const XmlNode& node) +{ + bool apply = false; + + if ( this->accept(node.name()) == false ) + return; + + if ( magCompare(node.name(), "median") ) + apply = true; + + + if ( apply ) + set(node.attributes()); + else { + + } + for (auto &elt : node.elements()) + { + + } +} + +void NoBoxPlotBoxBorderAttributes::print(ostream& out) const +{ + out << "Attributes["; + + out << "]" << "\n"; +} + +void NoBoxPlotBoxBorderAttributes::toxml(ostream& out) const +{ + out << "\"median\""; + +} + diff --git a/src/attributes/NoBoxPlotBoxBorderAttributes.h b/src/attributes/NoBoxPlotBoxBorderAttributes.h new file mode 100644 index 000000000..cd9e91048 --- /dev/null +++ b/src/attributes/NoBoxPlotBoxBorderAttributes.h @@ -0,0 +1,63 @@ + +/******************************* LICENSE ******************************* + + * (C) Copyright 1996-2016 ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * In applying this licence, ECMWF does not waive the privileges and immunities + * granted to it by virtue of its status as an intergovernmental organisation nor + * does it submit to any jurisdiction. + + ******************************* LICENSE *******************************/ + +/*! \fileNoBoxPlotBoxBorderAttributes.h + \brief Definition of NoBoxPlotBoxBorder Attributes class. + + This file is automatically generated. + Do Not Edit! + + Generated: +*/ + + +#ifndef NoBoxPlotBoxBorderAttributes_H +#define NoBoxPlotBoxBorderAttributes_H + +#include "magics.h" +namespace magics { + +class XmlNode; +class NoBoxPlotBoxBorderAttributes +{ +public: +// -- constructor + NoBoxPlotBoxBorderAttributes(); + +// -- destructor + virtual ~NoBoxPlotBoxBorderAttributes(); + + virtual void set(const std::map&); + virtual void set(const XmlNode&); + virtual void copy(const NoBoxPlotBoxBorderAttributes&); + virtual bool accept(const std::string&); + + void setTag(const std::string& tag) { tag_ = tag; } + +public: + // -- method + virtual void print(std::ostream&) const; + virtual void toxml(std::ostream& out) const; + // -- members: + string tag_; + + +private: + friend ostream& operator<<(ostream& s,const NoBoxPlotBoxBorderAttributes& p) + { p.print(s); return s; } +}; + +} // namespace magics + +#endif + diff --git a/src/attributes/NoBoxPlotBoxBorderWrapper.cc b/src/attributes/NoBoxPlotBoxBorderWrapper.cc new file mode 100644 index 000000000..14fb00eb2 --- /dev/null +++ b/src/attributes/NoBoxPlotBoxBorderWrapper.cc @@ -0,0 +1,67 @@ + +/****************************** LICENSE ******************************* + + * (C) Copyright 1996-2017 ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * In applying this licence, ECMWF does not waive the privileges and immunities + * granted to it by virtue of its status as an intergovernmental organisation nor + * does it submit to any jurisdiction. + + ******************************* LICENSE *******************************/ + +/*! \\file NoBoxPlotBoxBorderAttributes.h + \\brief Definition of NoBoxPlotBoxBorder Attributes class. + + This file is automatically generated. + Do Not Edit! + +*/ + +#include "MagRequest.h" +#include "NoBoxPlotBoxBorderWrapper.h" +#include "MagicsParameter.h" +#include "Factory.h" +#include "MagTranslator.h" +#include "MagicsGlobal.h" + +using namespace magics; + + + +NoBoxPlotBoxBorderWrapper::NoBoxPlotBoxBorderWrapper(): noboxplotboxborder_(new NoBoxPlotBoxBorder()) + + +{ + + + + +} +NoBoxPlotBoxBorderWrapper::NoBoxPlotBoxBorderWrapper(NoBoxPlotBoxBorder* noboxplotboxborder): noboxplotboxborder_(noboxplotboxborder) +{ + + +} + +NoBoxPlotBoxBorderWrapper::~NoBoxPlotBoxBorderWrapper() +{ + +} + +void NoBoxPlotBoxBorderWrapper::set(const MagRequest& request) +{ + + + + + +} + +void NoBoxPlotBoxBorderWrapper::print(ostream& out) const +{ + out << "NoBoxPlotBoxBorderWrapper[]"; +} + + diff --git a/src/attributes/NoBoxPlotBoxBorderWrapper.h b/src/attributes/NoBoxPlotBoxBorderWrapper.h new file mode 100644 index 000000000..bde7f82f2 --- /dev/null +++ b/src/attributes/NoBoxPlotBoxBorderWrapper.h @@ -0,0 +1,91 @@ + +/******************************* LICENSE ******************************* + + * (C) Copyright 1996-2016 ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * In applying this licence, ECMWF does not waive the privileges and immunities + * granted to it by virtue of its status as an intergovernmental organisation nor + * does it submit to any jurisdiction. + + ******************************* LICENSE *******************************/ + +/*! \fileNoBoxPlotBoxBorderAttributes.h + \brief Definition of NoBoxPlotBoxBorder Attributes class. + + This file is automatically generated. + Do Not Edit! + + Generated: +*/ + + +#ifndef NoBoxPlotBoxBorderWrapper_H +#define NoBoxPlotBoxBorderWrapper_H + +#include "magics.h" +#include "ParameterManager.h" +#include "Factory.h" + + + +#include "BoxPlotItem.h" + + + + + + + + + + +namespace magics { + +class MagRequest; + + + +class NoBoxPlotBoxBorderWrapper + +{ +public: +// -- constructor + NoBoxPlotBoxBorderWrapper(); + NoBoxPlotBoxBorderWrapper(NoBoxPlotBoxBorder*); +// -- destructor + virtual ~NoBoxPlotBoxBorderWrapper(); + virtual void set(const MagRequest&); + + NoBoxPlotBoxBorder* me() { return noboxplotboxborder_; } + + virtual NoBoxPlotBoxBorder* object() { return noboxplotboxborder_; } + + + virtual void object(NoBoxPlotBoxBorder* o) { + // Remember to delete the previous object + noboxplotboxborder_ = o; + + + } + + + +protected: + NoBoxPlotBoxBorder* noboxplotboxborder_; + + +// -- method + virtual void print(ostream&) const; + + +private: + string tag_; + friend ostream& operator<<(ostream& s,const NoBoxPlotBoxBorderWrapper& p) + { p.print(s); return s; } +}; + +} // namespace magics + +#endif \ No newline at end of file diff --git a/src/attributes/NoBoxPlotMedianAttributes.cc b/src/attributes/NoBoxPlotMedianAttributes.cc new file mode 100644 index 000000000..50dcf6f01 --- /dev/null +++ b/src/attributes/NoBoxPlotMedianAttributes.cc @@ -0,0 +1,100 @@ + +/****************************** LICENSE ******************************* + + * (C) Copyright 1996-2017 ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * In applying this licence, ECMWF does not waive the privileges and immunities + * granted to it by virtue of its status as an intergovernmental organisation nor + * does it submit to any jurisdiction. + + ******************************* LICENSE *******************************/ + +/*! \\file NoBoxPlotMedianAttributes.h + \\brief Definition of NoBoxPlotMedian Attributes class. + + This file is automatically generated. + Do Not Edit! +*/ + +#include "NoBoxPlotMedianAttributes.h" +#include "MagicsParameter.h" +#include "ParameterSettings.h" + +using namespace magics; + +NoBoxPlotMedianAttributes::NoBoxPlotMedianAttributes() + + +{ +} + + +NoBoxPlotMedianAttributes::~NoBoxPlotMedianAttributes() +{ + +} + + +void NoBoxPlotMedianAttributes::set(const std::map& params) +{ + vector prefix(2); + int i = 0; + prefix[i++] = "boxplot"; + prefix[i++] = "boxplot_median"; + + + +} + +void NoBoxPlotMedianAttributes::copy(const NoBoxPlotMedianAttributes& other) +{ + +} + + +bool NoBoxPlotMedianAttributes::accept(const string& node) +{ + + if ( magCompare(node, "median") ) + return true; + + return false; +} + +void NoBoxPlotMedianAttributes::set(const XmlNode& node) +{ + bool apply = false; + + if ( this->accept(node.name()) == false ) + return; + + if ( magCompare(node.name(), "median") ) + apply = true; + + + if ( apply ) + set(node.attributes()); + else { + + } + for (auto &elt : node.elements()) + { + + } +} + +void NoBoxPlotMedianAttributes::print(ostream& out) const +{ + out << "Attributes["; + + out << "]" << "\n"; +} + +void NoBoxPlotMedianAttributes::toxml(ostream& out) const +{ + out << "\"median\""; + +} + diff --git a/src/attributes/NoBoxPlotMedianAttributes.h b/src/attributes/NoBoxPlotMedianAttributes.h new file mode 100644 index 000000000..3a6b29a1c --- /dev/null +++ b/src/attributes/NoBoxPlotMedianAttributes.h @@ -0,0 +1,63 @@ + +/******************************* LICENSE ******************************* + + * (C) Copyright 1996-2016 ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * In applying this licence, ECMWF does not waive the privileges and immunities + * granted to it by virtue of its status as an intergovernmental organisation nor + * does it submit to any jurisdiction. + + ******************************* LICENSE *******************************/ + +/*! \fileNoBoxPlotMedianAttributes.h + \brief Definition of NoBoxPlotMedian Attributes class. + + This file is automatically generated. + Do Not Edit! + + Generated: +*/ + + +#ifndef NoBoxPlotMedianAttributes_H +#define NoBoxPlotMedianAttributes_H + +#include "magics.h" +namespace magics { + +class XmlNode; +class NoBoxPlotMedianAttributes +{ +public: +// -- constructor + NoBoxPlotMedianAttributes(); + +// -- destructor + virtual ~NoBoxPlotMedianAttributes(); + + virtual void set(const std::map&); + virtual void set(const XmlNode&); + virtual void copy(const NoBoxPlotMedianAttributes&); + virtual bool accept(const std::string&); + + void setTag(const std::string& tag) { tag_ = tag; } + +public: + // -- method + virtual void print(std::ostream&) const; + virtual void toxml(std::ostream& out) const; + // -- members: + string tag_; + + +private: + friend ostream& operator<<(ostream& s,const NoBoxPlotMedianAttributes& p) + { p.print(s); return s; } +}; + +} // namespace magics + +#endif + diff --git a/src/attributes/NoBoxPlotMedianWrapper.cc b/src/attributes/NoBoxPlotMedianWrapper.cc new file mode 100644 index 000000000..b3011118d --- /dev/null +++ b/src/attributes/NoBoxPlotMedianWrapper.cc @@ -0,0 +1,67 @@ + +/****************************** LICENSE ******************************* + + * (C) Copyright 1996-2017 ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * In applying this licence, ECMWF does not waive the privileges and immunities + * granted to it by virtue of its status as an intergovernmental organisation nor + * does it submit to any jurisdiction. + + ******************************* LICENSE *******************************/ + +/*! \\file NoBoxPlotMedianAttributes.h + \\brief Definition of NoBoxPlotMedian Attributes class. + + This file is automatically generated. + Do Not Edit! + +*/ + +#include "MagRequest.h" +#include "NoBoxPlotMedianWrapper.h" +#include "MagicsParameter.h" +#include "Factory.h" +#include "MagTranslator.h" +#include "MagicsGlobal.h" + +using namespace magics; + + + +NoBoxPlotMedianWrapper::NoBoxPlotMedianWrapper(): noboxplotmedian_(new NoBoxPlotMedian()) + + +{ + + + + +} +NoBoxPlotMedianWrapper::NoBoxPlotMedianWrapper(NoBoxPlotMedian* noboxplotmedian): noboxplotmedian_(noboxplotmedian) +{ + + +} + +NoBoxPlotMedianWrapper::~NoBoxPlotMedianWrapper() +{ + +} + +void NoBoxPlotMedianWrapper::set(const MagRequest& request) +{ + + + + + +} + +void NoBoxPlotMedianWrapper::print(ostream& out) const +{ + out << "NoBoxPlotMedianWrapper[]"; +} + + diff --git a/src/attributes/NoBoxPlotMedianWrapper.h b/src/attributes/NoBoxPlotMedianWrapper.h new file mode 100644 index 000000000..97b82f4ba --- /dev/null +++ b/src/attributes/NoBoxPlotMedianWrapper.h @@ -0,0 +1,91 @@ + +/******************************* LICENSE ******************************* + + * (C) Copyright 1996-2016 ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * In applying this licence, ECMWF does not waive the privileges and immunities + * granted to it by virtue of its status as an intergovernmental organisation nor + * does it submit to any jurisdiction. + + ******************************* LICENSE *******************************/ + +/*! \fileNoBoxPlotMedianAttributes.h + \brief Definition of NoBoxPlotMedian Attributes class. + + This file is automatically generated. + Do Not Edit! + + Generated: +*/ + + +#ifndef NoBoxPlotMedianWrapper_H +#define NoBoxPlotMedianWrapper_H + +#include "magics.h" +#include "ParameterManager.h" +#include "Factory.h" + + + +#include "BoxPlotItem.h" + + + + + + + + + + +namespace magics { + +class MagRequest; + + + +class NoBoxPlotMedianWrapper + +{ +public: +// -- constructor + NoBoxPlotMedianWrapper(); + NoBoxPlotMedianWrapper(NoBoxPlotMedian*); +// -- destructor + virtual ~NoBoxPlotMedianWrapper(); + virtual void set(const MagRequest&); + + NoBoxPlotMedian* me() { return noboxplotmedian_; } + + virtual NoBoxPlotMedian* object() { return noboxplotmedian_; } + + + virtual void object(NoBoxPlotMedian* o) { + // Remember to delete the previous object + noboxplotmedian_ = o; + + + } + + + +protected: + NoBoxPlotMedian* noboxplotmedian_; + + +// -- method + virtual void print(ostream&) const; + + +private: + string tag_; + friend ostream& operator<<(ostream& s,const NoBoxPlotMedianWrapper& p) + { p.print(s); return s; } +}; + +} // namespace magics + +#endif \ No newline at end of file diff --git a/src/attributes/SymbolPlottingAttributes.h b/src/attributes/SymbolPlottingAttributes.h index 75239b939..2d46d6ff7 100644 --- a/src/attributes/SymbolPlottingAttributes.h +++ b/src/attributes/SymbolPlottingAttributes.h @@ -54,7 +54,6 @@ class SymbolPlottingAttributes string tag_; bool legend_; string unit_method_; - string unit_method_; string type_; string marker_mode_; string format_; diff --git a/src/params/GribDecoder.xml b/src/params/GribDecoder.xml index 5f0b9efa1..0ec1055bf 100644 --- a/src/params/GribDecoder.xml +++ b/src/params/GribDecoder.xml @@ -47,30 +47,7 @@ does it submit to any jurisdiction. name="grib_second_component_file_name"> The name of the input file containing the v-component of wind - - - The name of the input file containing the u-component of wind - - - - The name of the input file containing the u-component of wind - - - - The name of the input file containing the v-component of wind - + Turn legend on or off (ON/OFF) : New Parameter! - Date: Mon, 4 Dec 2023 16:27:42 +0000 Subject: [PATCH 14/18] Revert OutofBond --- src/attributes/ColourTechniqueAttributes.cc | 16 +------ src/attributes/ColourTechniqueAttributes.h | 2 - src/attributes/ColourTechniqueWrapper.cc | 8 ---- src/common/ColourTableDefinitionCompute.cc | 9 ++-- src/params/ColourTechnique.xml | 16 ------- src/visualisers/ColourTechnique.cc | 46 ++------------------- src/visualisers/IntervalSelectionType.cc | 2 +- src/visualisers/LevelSelection.h | 8 +--- 8 files changed, 12 insertions(+), 95 deletions(-) diff --git a/src/attributes/ColourTechniqueAttributes.cc b/src/attributes/ColourTechniqueAttributes.cc index 77857f215..2af62957e 100644 --- a/src/attributes/ColourTechniqueAttributes.cc +++ b/src/attributes/ColourTechniqueAttributes.cc @@ -24,9 +24,7 @@ using namespace magics; -ColourTechniqueAttributes::ColourTechniqueAttributes(): - oob_min_colour_(ParameterManager::getString("contour_out_of_bound_min_colour")), - oob_max_colour_(ParameterManager::getString("contour_out_of_bound_max_colour")) +ColourTechniqueAttributes::ColourTechniqueAttributes() { @@ -45,16 +43,12 @@ void ColourTechniqueAttributes::set(const std::map& params) int i = 0; prefix[i++] = ""; - setAttribute(prefix, "contour_out_of_bound_min_colour", oob_min_colour_, params); - setAttribute(prefix, "contour_out_of_bound_max_colour", oob_max_colour_, params); } void ColourTechniqueAttributes::copy(const ColourTechniqueAttributes& other) { - oob_min_colour_ = other.oob_min_colour_; - oob_max_colour_ = other.oob_max_colour_; } @@ -93,8 +87,6 @@ void ColourTechniqueAttributes::set(const XmlNode& node) void ColourTechniqueAttributes::print(ostream& out) const { out << "Attributes["; - out << " oob_min_colour = " << oob_min_colour_; - out << " oob_max_colour = " << oob_max_colour_; out << "]" << "\n"; } @@ -102,12 +94,6 @@ void ColourTechniqueAttributes::print(ostream& out) const void ColourTechniqueAttributes::toxml(ostream& out) const { out << "\"\""; - out << ", \"contour_out_of_bound_min_colour\":"; - niceprint(out,oob_min_colour_); - out << ", \"contour_out_of_bound_max_colour\":"; - niceprint(out,oob_max_colour_); } -static MagicsParameter contour_out_of_bound_min_colour("contour_out_of_bound_min_colour", "automatic"); -static MagicsParameter contour_out_of_bound_max_colour("contour_out_of_bound_max_colour", "automatic"); diff --git a/src/attributes/ColourTechniqueAttributes.h b/src/attributes/ColourTechniqueAttributes.h index f4d011342..532f28a55 100644 --- a/src/attributes/ColourTechniqueAttributes.h +++ b/src/attributes/ColourTechniqueAttributes.h @@ -50,8 +50,6 @@ class ColourTechniqueAttributes virtual void toxml(std::ostream& out) const; // -- members: string tag_; - string oob_min_colour_; - string oob_max_colour_; private: diff --git a/src/attributes/ColourTechniqueWrapper.cc b/src/attributes/ColourTechniqueWrapper.cc index 740661f99..e615ccaed 100644 --- a/src/attributes/ColourTechniqueWrapper.cc +++ b/src/attributes/ColourTechniqueWrapper.cc @@ -55,14 +55,6 @@ void ColourTechniqueWrapper::set(const MagRequest& request) - if (request.countValues("CONTOUR_OUT_OF_BOUND_MIN_COLOUR") ) { - string oob_min_colour_value = request("CONTOUR_OUT_OF_BOUND_MIN_COLOUR"); - colourtechnique_->oob_min_colour_ = oob_min_colour_value; - } - if (request.countValues("CONTOUR_OUT_OF_BOUND_MAX_COLOUR") ) { - string oob_max_colour_value = request("CONTOUR_OUT_OF_BOUND_MAX_COLOUR"); - colourtechnique_->oob_max_colour_ = oob_max_colour_value; - } } diff --git a/src/common/ColourTableDefinitionCompute.cc b/src/common/ColourTableDefinitionCompute.cc index 8abf2042c..a62a6b515 100644 --- a/src/common/ColourTableDefinitionCompute.cc +++ b/src/common/ColourTableDefinitionCompute.cc @@ -275,10 +275,6 @@ void ColourTableDefinitionCompute::hcl(ColourTable& table, int nb) { void ColourTableDefinitionCompute::set(ColourTable& table, int nb) { prepare(); - MagLog::dev() << "ColourTableDefinitionCompute::set->min-->" << minColour_ << endl; - MagLog::dev() << "ColourTableDefinitionCompute::set->max-->" << maxColour_ << endl; - MagLog::dev() << "nb interval-->" << nb << endl; - if (nb == 1) { table.push_back(minColour_); return; @@ -292,6 +288,8 @@ void ColourTableDefinitionCompute::set(ColourTable& table, int nb) { table.push_back(maxColour_); return; } + + std::map::iterator method = methods_.find(lowerCase(method_)); if (method == methods_.end()) hsl(table, nb); @@ -394,6 +392,8 @@ void ColourTableDefinitionCompute::set(const stringarray& from, ColourTable& to, int nb, ColourListPolicy policy, const string& method) { + + cout << "SET" << policy << endl; auto colour = from.begin(); if (policy == ColourListPolicy::DYNAMIC) { auto helper = dynamicMethods_.find(method); @@ -409,6 +409,7 @@ void ColourTableDefinitionCompute::set(const stringarray& from, ColourTable& to, } for (int i = 0; i < nb - 1; i++) { + cout << i << "->" << *colour << endl; if (colour == from.end()) { if (policy == ColourListPolicy::LASTONE) { to.push_back(Colour(from.back())); diff --git a/src/params/ColourTechnique.xml b/src/params/ColourTechnique.xml index d0e223401..8826bfcc2 100644 --- a/src/params/ColourTechnique.xml +++ b/src/params/ColourTechnique.xml @@ -9,23 +9,7 @@ does it submit to any jurisdiction. - - Colour to use below the out of bound minimum value - - - Colour to use below the out of bound maximum value - diff --git a/src/visualisers/ColourTechnique.cc b/src/visualisers/ColourTechnique.cc index 5a063675a..33a88be7f 100644 --- a/src/visualisers/ColourTechnique.cc +++ b/src/visualisers/ColourTechnique.cc @@ -45,53 +45,15 @@ void ColourTechnique::print(ostream& out) const { } void ColourTechnique::prepare(LevelSelection& out, LevelSelection& levels, bool rainbow) { - if (levels.empty()) + if (levels.empty()) return; - - clear(); bands_.clear(); ColourTable table; - - - - minOutOfBound_ = out.minOutOfBond(); - maxOutOfBound_ = out.maxOutOfBond(); - - - if (rainbow) set(out, levels, table, levels.size() + 1); - else { - - LevelSelection newlevels; - int count = levels.size(); - if (out.minOutOfBond()) count--; - - if (out.maxOutOfBond()) count--; - - - - set(out, levels, table, count); - if (out.minOutOfBond()) { - Colour min_colour = magCompare(oob_min_colour_, "automatic") ? - table.front().colour() : Colour(oob_min_colour_); - table.insert(table.begin(), min_colour); - } - if (out.maxOutOfBond()) { - Colour max_colour = magCompare(oob_max_colour_, "automatic") ? - table.back().colour() : Colour(oob_max_colour_); - table.push_back(max_colour); - } - } - - - // cout << "ColourTechnique::after(" << endl; - // for (auto l = levels.begin(); l != levels.end(); ++l) - // cout << *l << endl; - - // cout << "-------------------" << endl; - + else + set(out, levels, table, levels.size()); if (table.empty()) table.push_back(Colour("none")); @@ -131,8 +93,6 @@ void ColourTechnique::prepare(LevelSelection& out, LevelSelection& levels, bool if (!rainbow) bands_.insert(make_pair(Interval(levels.back(), levels.back() + EPSILON), left)); - - MagLog::dev() << levels.back() << "<<" << left << "<<" << levels.back() + EPSILON << endl; } diff --git a/src/visualisers/IntervalSelectionType.cc b/src/visualisers/IntervalSelectionType.cc index 8b48f8bac..1ca7e2d0a 100644 --- a/src/visualisers/IntervalSelectionType.cc +++ b/src/visualisers/IntervalSelectionType.cc @@ -95,7 +95,7 @@ void IntervalSelectionType::calculate(double min, double max, bool shading) { push_back(*level); } out << "]" << endl; - // cout << out.str() << endl; + MagLog::dev() << out.str() << endl; } diff --git a/src/visualisers/LevelSelection.h b/src/visualisers/LevelSelection.h index 218d342b6..1be70cc61 100644 --- a/src/visualisers/LevelSelection.h +++ b/src/visualisers/LevelSelection.h @@ -58,15 +58,11 @@ class LevelSelection : public LevelSelectionAttributes, public doublearray { virtual double reference(int) const; virtual void thinLevels(int frequency, vector&) const; - bool minOutOfBond() { return minOutOfBond_; } - bool maxOutOfBond() { return maxOutOfBond_; } - + protected: //! Method to print string about this class on to a stream of type ostream (virtual). virtual void print(ostream&) const override; - bool minOutOfBond_; - bool maxOutOfBond_; -; + private: //! Copy constructor - No copy allowed From bb9506d29c61677d28e67fa017310f9a82f0ad8d Mon Sep 17 00:00:00 2001 From: Sylvie Lamy-Thepaut Date: Mon, 4 Dec 2023 17:35:35 +0000 Subject: [PATCH 15/18] Revert OutofBond --- src/visualisers/CountSelectionType.cc | 96 +++++++-------------------- 1 file changed, 24 insertions(+), 72 deletions(-) diff --git a/src/visualisers/CountSelectionType.cc b/src/visualisers/CountSelectionType.cc index 0fe91451b..cb6b4aa22 100644 --- a/src/visualisers/CountSelectionType.cc +++ b/src/visualisers/CountSelectionType.cc @@ -34,59 +34,21 @@ CountSelectionType::CountSelectionType() {} #define MAXSET(v) !same(v, +1.0e+21) void CountSelectionType::calculate(double min, double max, bool shading) { - - - clear(); - - - double min_limit=min; - double max_limit=max; - - - if ( MINSET(min_) ) - min_limit = min_; - - if ( MAXSET(max_) ) - max_limit = max_; - - if ( shading && MINSET(shade_min_) ) - min_limit = shade_min_; - - if ( shading && MAXSET(shade_max_) ) - max_limit = shade_max_; - - minOutOfBond_ = oob_min_ > min_limit; - maxOutOfBond_ = oob_max_ < max_limit; - +clear(); + double maxi = (max_ > 1000000000) ? max : max_; + double mini = (min_ < -1000000000) ? min : min_; int i = 0; - if ( minOutOfBond_ || !MINSET(min_)) { - i++; - } - - if ( maxOutOfBond_ || !MAXSET(max_) ) { - i++; - } + i += (max_ > 1000000000) ? 1 : 0; + i += (min_ < -1000000000) ? 1 : 0; - // Commented for now, may have to be revisited soon. - // i += ( MINSET(min_limit) ) ? 1 : 0; - // i += ( MAXSET(max_limit) ) ? 1 : 0; - double nb = levelCount_ - 1; - if (same(max_limit, min_limit)) { - push_back(min_limit); + if (same(maxi, mini)) { + push_back(mini); return; } - - if (min_limit > max_limit) { - push_back(max_limit); - push_back(min_limit); - return; - } - - - double step = (max_limit - min_limit) / nb; + double step = (maxi - mini) / nb; double toleranceProportion = (double)tolerance_ / (double)(levelCount_ + 1 + i); // tolerance as a proportion of the number of levels @@ -94,7 +56,7 @@ void CountSelectionType::calculate(double min, double max, bool shading) { // number of levels we will not actually plot, ie the min/max contours). if (same(step, 0)) { // Only one isoline! - push_back(min_limit); + push_back(mini); return; } @@ -145,12 +107,13 @@ void CountSelectionType::calculate(double min, double max, bool shading) { inc *= istep; // convert back into proper range - double first = floor(min_limit / inc) * inc; - while (first > min_limit) + double first = floor(mini / inc) * inc; + + while (first > mini) first -= inc; - push_back(min_limit); + push_back(mini); first += inc; double epsilon = inc / 10000.0; while (same(epsilon, 0)) { @@ -159,20 +122,18 @@ void CountSelectionType::calculate(double min, double max, bool shading) { } - - for (double val = first; val < max_limit; val += inc) { + for (double val = first; val < maxi; val += inc) { // special case - if the value is close to zero then set it to precisely zero to avoid later formatting issues if (fabs(val) < epsilon) push_back(0.0); - else if (same(val, max_limit)) - push_back(max_limit); + else if (same(val, maxi)) + push_back(maxi); else push_back(val); } - if (max_limit != back()) - push_back(max_limit); - + if (maxi != back()) + push_back(maxi); int si = static_cast(size()); @@ -180,37 +141,28 @@ void CountSelectionType::calculate(double min, double max, bool shading) { // so as to ensure the correct number, even if they are not nice if (si - i < levelCount_ - tolerance_ || si - i > levelCount_ + tolerance_) { - MagLog::debug() << "Not using nice levels[" << levelCount_ << ", " << tolerance_ << "]-->" << size() << endl; + MagLog::debug() << "Not using nice levels[" << levelCount_ << ", " << tolerance_ << "]-->" << size() << endl; clear(); - step = (max_limit - min_limit) / (levelCount_ - 1); - double val = min_limit; + step = (maxi - mini) / (levelCount_ - 1); + double val = mini; while (1) { - if ( val >= min_limit && val <= max_limit ) push_back(val); - if (same(val, max_limit) || val > max_limit) + if (same(val, maxi) || val > maxi) break; val += step; } MagLog::debug() << "New size-->" << size() << endl; } - if ( minOutOfBond_ ) { - insert(begin(), std::max(min, min_)); - } + MagLog::debug() << "count=" << levelCount_ << ", tolerance=" << tolerance_ << ", result=" << size() << endl; - if ( maxOutOfBond_ ) { - push_back(std::min(max, max_)); - } - - ostringstream level; for (const_iterator l = begin(); l != end(); ++l) level << *l << " "; - MagLog::debug() << level.str() << endl; + MagLog::debug() << level.str() << endl; } - CountSelectionType::~CountSelectionType() {} /*! From fbd520426ae902cc16afa15f3ebbbf579e489723 Mon Sep 17 00:00:00 2001 From: Sylvie Lamy-Thepaut Date: Mon, 4 Dec 2023 17:41:00 +0000 Subject: [PATCH 16/18] Revert OutofBond --- src/visualisers/ColourTechnique.cc | 4 +- src/visualisers/ColourTechnique.h | 6 +-- src/visualisers/LevelListSelectionType.cc | 60 ++++------------------- src/visualisers/PolyShadingTechnique.h | 1 - 4 files changed, 12 insertions(+), 59 deletions(-) diff --git a/src/visualisers/ColourTechnique.cc b/src/visualisers/ColourTechnique.cc index 33a88be7f..a6d9807e7 100644 --- a/src/visualisers/ColourTechnique.cc +++ b/src/visualisers/ColourTechnique.cc @@ -29,9 +29,7 @@ using namespace magics; -ColourTechnique::ColourTechnique() : policy_(ListPolicy::LASTONE), - minOutOfBound_(false), maxOutOfBound_(false) - {} +ColourTechnique::ColourTechnique() : policy_(ListPolicy::LASTONE) {} ColourTechnique::~ColourTechnique() {} diff --git a/src/visualisers/ColourTechnique.h b/src/visualisers/ColourTechnique.h index 75c3778b6..4e79bc9a3 100644 --- a/src/visualisers/ColourTechnique.h +++ b/src/visualisers/ColourTechnique.h @@ -87,8 +87,6 @@ class ColourTechnique : public map, void visit(LegendVisitor&); ListPolicy getPolicy() const { return policy_; } - bool minOutOfBound() const { return minOutOfBound_; } - bool maxOutOfBound() const { return maxOutOfBound_; } protected: //! Method to print string about this class on to a stream of type ostream (virtual). @@ -98,9 +96,7 @@ class ColourTechnique : public map, map > ranges_; double maxLevel_; - bool minOutOfBound_; - bool maxOutOfBound_; - + ListPolicy policy_; diff --git a/src/visualisers/LevelListSelectionType.cc b/src/visualisers/LevelListSelectionType.cc index 1f400d8d6..ae5338cb4 100644 --- a/src/visualisers/LevelListSelectionType.cc +++ b/src/visualisers/LevelListSelectionType.cc @@ -45,47 +45,12 @@ void LevelListSelectionType::print(ostream& out) const { void LevelListSelectionType::calculate(double min, double max, bool shading) { clear(); - double min_level=list_.front(); - double max_level=list_.back(); - - - if ( MINSET(min_) ) - min_level = min_; - - if ( MAXSET(max_) ) - max_level = max_; - - if ( shading && MINSET(shade_min_) ) - min_level = shade_min_; - - if ( shading && MAXSET(shade_max_) ) - max_level = shade_max_; - - - - minOutOfBond_ = oob_min_ > min_level; - maxOutOfBond_ = oob_max_ < max_level; - - - - - if (minOutOfBond_) { - push_back(min); - push_back(oob_min_); - min_level = oob_min_; - } - - if (maxOutOfBond_) { - max_level = oob_max_; - } - - doublearray::const_iterator last = list_.begin(); double prevVal = min_; for (doublearray::const_iterator val = list_.begin(); val != list_.end(); ++val) { MagLog::dev() << "LevelListSelectionType::calculate(double min, double max)--->" << *val << "\n"; - if (min_level <= *val && *val <= max_level) { + if (min_ <= *val && *val <= max_) { if (*val < prevVal) { MagLog::error() << " level list values should increase, but " << *val << " follows " << prevVal << endl; break; @@ -95,24 +60,19 @@ void LevelListSelectionType::calculate(double min, double max, bool shading) { } ++last; } - if (maxOutOfBond_) { - push_back(oob_max_); - push_back(max); - } - // Just in case add another level to close the last interval ! if (last != list_.end()) push_back(*last); - // ostringstream print; - // print << "LevelListSelectionType::calculate-->"; - // string sep = "["; - // for (vector::const_iterator val = begin(); val != end(); ++val) { - // print << sep << *val; - // sep = ", "; - // } - // print << "]"; - // cout << print.str() << endl; + ostringstream print; + print << "LevelListSelectionType::calculate-->"; + string sep = "["; + for (vector::const_iterator val = begin(); val != end(); ++val) { + print << sep << *val; + sep = ", "; + } + print << "]"; + MagLog::dev() << print.str() << endl; } diff --git a/src/visualisers/PolyShadingTechnique.h b/src/visualisers/PolyShadingTechnique.h index 5724699c8..07d24508c 100644 --- a/src/visualisers/PolyShadingTechnique.h +++ b/src/visualisers/PolyShadingTechnique.h @@ -141,7 +141,6 @@ struct LegendEntryBuilder { box->setColour(colours_.right(min)); LegendEntry* entry = new BoxEntry(min, max, box); - entry->oob(colours_.minOutOfBound(), colours_.maxOutOfBound()); if (first_) { first_ = false; entry->first(); From 8a0411cbfe8442d6b9faa6cb9caac07711ea4391 Mon Sep 17 00:00:00 2001 From: Sylvie Lamy-Thepaut Date: Mon, 4 Dec 2023 17:56:57 +0000 Subject: [PATCH 17/18] Revert OutofBond --- src/visualisers/SymbolPlotting.cc | 26 +------------------------- 1 file changed, 1 insertion(+), 25 deletions(-) diff --git a/src/visualisers/SymbolPlotting.cc b/src/visualisers/SymbolPlotting.cc index ff6d4bca0..bd847ce8a 100644 --- a/src/visualisers/SymbolPlotting.cc +++ b/src/visualisers/SymbolPlotting.cc @@ -164,31 +164,7 @@ void SymbolPlotting::by_property(Data& data, BasicGraphicsObjectContainer& out) property_lightness_list_.push_back(0.5); - 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_hue + 1 == property_hue_values_list_.end()) - break; - - 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; - } + IntervalMap hueFinder; IntervalMap lightnessFinder; From 5087dcb05daaecf9191d8702314bd25a2a55caf8 Mon Sep 17 00:00:00 2001 From: Sylvie Lamy-Thepaut Date: Tue, 5 Dec 2023 15:58:40 +0000 Subject: [PATCH 18/18] Fix issues with colour setting --- src/common/ColourTableDefinitionCompute.cc | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/src/common/ColourTableDefinitionCompute.cc b/src/common/ColourTableDefinitionCompute.cc index a62a6b515..de608024b 100644 --- a/src/common/ColourTableDefinitionCompute.cc +++ b/src/common/ColourTableDefinitionCompute.cc @@ -391,9 +391,6 @@ void ColourTableDefinitionCompute::dynamic_normal(const stringarray& from, Colou void ColourTableDefinitionCompute::set(const stringarray& from, ColourTable& to, int nb, ColourListPolicy policy, const string& method) { - - - cout << "SET" << policy << endl; auto colour = from.begin(); if (policy == ColourListPolicy::DYNAMIC) { auto helper = dynamicMethods_.find(method); @@ -409,21 +406,18 @@ void ColourTableDefinitionCompute::set(const stringarray& from, ColourTable& to, } for (int i = 0; i < nb - 1; i++) { - cout << i << "->" << *colour << endl; + to.push_back(Colour(*colour)); + colour++; + if (colour == from.end()) { if (policy == ColourListPolicy::LASTONE) { - to.push_back(Colour(from.back())); + colour--; } else { colour = from.begin(); - to.push_back(Colour(*colour)); - colour++; } } - else { - to.push_back(Colour(*colour)); - colour++; - } + }