[magics] 01/04: upstream 2.32.0 release
Alastair McKinstry
mckinstry at moszumanska.debian.org
Thu Apr 20 14:06:56 UTC 2017
This is an automated email from the git hooks/post-receive script.
mckinstry pushed a commit to branch debian/master
in repository magics.
commit 5ed8bd1c62223abea9c78602372c02ac4df4d827
Author: Alastair McKinstry <mckinstry at debian.org>
Date: Fri Mar 24 10:51:12 2017 +0000
upstream 2.32.0 release
---
CMakeLists.txt | 34 +-
VERSION.cmake | 12 +-
apps/metgram/CMakeLists.txt | 4 +-
cmake/VERSION.cmake | 4 +-
cmake/ecbuild_check_functions.cmake | 3 +
cmake/ecbuild_config.h.in | 1 +
cmake/ecbuild_declare_project.cmake | 11 +-
cmake/ecbuild_find_omp.cmake | 2 +-
cmake/ecbuild_generate_rpc.cmake | 88 +++--
magics.sublime-project | 2 +-
python/Magics/toolbox.py | 375 +++++++++++++++++--
share/CMakeLists.txt | 5 +-
share/magics/table_128.xml | 2 +-
src/basic/LegendVisitor.cc | 106 +++++-
src/basic/LegendVisitor.h | 14 +-
src/basic/TagHandler.cc | 8 +
src/basic/TagHandler.h | 1 +
src/common/Colour.cc | 2 +-
src/common/Colour.h | 5 +-
src/common/ColourTableDefinitionCompute.cc | 398 +++++++++++++++++++--
src/common/ColourTableDefinitionCompute.h | 21 ++
src/common/ColourTableDefinitionList.h | 2 +
src/common/GeoRectangularProjection.cc | 5 -
src/common/Matrix.cc | 4 +-
src/common/MatrixHandler.h | 10 +-
src/common/PolarStereographicProjection.cc | 15 +-
src/common/Proj4Projection.cc | 42 +++
src/common/Proj4Projection.h | 8 +
src/decoders/GeoPointsDecoder.cc | 51 ++-
src/decoders/GeoPointsDecoder.h | 4 +
src/decoders/GribDecoder.cc | 18 +
src/decoders/NetcdfDecoder.h | 7 +
src/decoders/NetcdfGeoMatrixInterpretor.cc | 118 +++++-
src/decoders/NetcdfGeoMatrixInterpretor.h | 15 +-
src/decoders/NetcdfGeopointsInterpretor.h | 4 +-
src/drivers/QtDriver.cc | 8 +-
src/params/CMakeLists.txt | 2 +
src/params/FortranViewNode.xml | 1 +
src/params/GradientsColourTechnique.xml | 42 +++
src/params/IsoShading.xml | 5 +-
src/params/LegendVisitor.xml | 4 +
src/params/Proj4EPSG900913.xml | 12 +
src/params/Proj4Projection.xml | 3 +
src/visualisers/Bar.cc | 4 +-
src/visualisers/CMakeLists.txt | 2 +
src/visualisers/CalculateColourTechnique.cc | 3 +-
src/visualisers/CalculateColourTechnique.h | 2 +-
src/visualisers/CellShading.cc | 2 +-
src/visualisers/CellShading.h | 2 +-
src/visualisers/ColourTechnique.cc | 8 +-
src/visualisers/ColourTechnique.h | 4 +-
src/visualisers/Curve.cc | 2 +-
src/visualisers/DotPolyShadingMethod.h | 2 +-
src/visualisers/EpsGraph.cc | 18 +-
src/visualisers/GradientsColourTechnique.cc | 177 +++++++++
...olourTechnique.h => GradientsColourTechnique.h} | 37 +-
src/visualisers/GridPlotting.cc | 4 +-
src/visualisers/HatchPolyShadingMethod.h | 2 +-
src/visualisers/IsoHighlight.h | 4 +-
src/visualisers/IsoLabel.h | 6 +-
src/visualisers/IsoPlot.cc | 9 +-
src/visualisers/IsoShading.h | 12 +-
src/visualisers/ListColourTechnique.cc | 2 +-
src/visualisers/ListColourTechnique.h | 2 +-
src/visualisers/MarkerShadingTechnique.cc | 2 +-
src/visualisers/MarkerShadingTechnique.h | 2 +-
src/visualisers/PolyShadingMethod.cc | 86 ++---
src/visualisers/PolyShadingMethod.h | 2 +-
src/visualisers/PolyShadingTechnique.h | 25 +-
src/visualisers/ShadingTechnique.h | 2 +-
src/visualisers/SimplePolylineVisualiser.cc | 2 +-
src/visualisers/SymbolAdvancedTableMode.cc | 2 +-
src/visualisers/SymbolMode.cc | 2 +-
src/visualisers/WindPlotting.cc | 2 +-
src/web/WrepJSon.cc | 20 ++
test/zoom.py | 62 ++++
76 files changed, 1660 insertions(+), 331 deletions(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 6b7275c..1769dad 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -28,7 +28,6 @@ project( magics CXX )
# note that this needs to be done before ecbuild_declare_project()
# to ensure that the ecbuild header files are also put there
# note also that we need to CACHE this so that ecbuild_declare_project() does not overwrite it
-set(MAGICS_INSTALL_INCLUDE_DIR include/magics CACHE PATH "Magics installation directory for header files")
set(INSTALL_INCLUDE_DIR include/magics CACHE PATH "Magics installation directory for header files")
set( CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake" ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/../ecbuild/cmake")
@@ -47,11 +46,10 @@ set(ECCODES_FAIL_MSG "Note: grib_api can be used instead (select with -DENABLE_E
"See https://software.ecmwf.int/wiki/display/ECC/ecCodes+Home\n"
)
-
ecbuild_add_option( FEATURE ECCODES DESCRIPTION "Use eccodes instead of grib_api"
REQUIRED_PACKAGES "PROJECT eccodes VERSION 0.14 REQUIRED FAILURE_MSG ECCODES_FAIL_MSG"
DEFAULT ON )
-
+
if( HAVE_ECCODES)
set( GRIB_API_INCLUDE_DIRS ${ECCODES_INCLUDE_DIRS} )
set( GRIB_API_LIBRARIES ${ECCODES_LIBRARIES} )
@@ -144,7 +142,7 @@ set( MAGICS_EXCEPTION "ON" )
set( MAGICS_SITE "ecmwf" )
set( MAGICS_INSTALL_PATH ${CMAKE_INSTALL_PREFIX} )
-set( MAGICS_REFERENCE_VERSIONS "2.30.0" )
+set( MAGICS_REFERENCE_VERSIONS "2.31.0" )
set( MAGICS_HTML_ROOT "${CMAKE_BINARY_DIR}/regression/html")
file(MAKE_DIRECTORY ${MAGICS_HTML_ROOT} )
@@ -206,7 +204,7 @@ ecbuild_declare_project()
# find extra packages
set( CMAKE_THREAD_PREFER_PTHREAD 1 )
-find_package( Threads )
+find_package( Threads )
# set(Boost_USE_STATIC_LIBS ON)
# set(Boost_NO_SYSTEM_PATHS ON)
@@ -222,13 +220,13 @@ find_package( EXPAT REQUIRED )
set( MAGICS_TPLS grib_api spot EXPAT NetCDF PNG Proj4 libemos )
-set( MAGICS_INCLUDE_DIRS
- ${CMAKE_CURRENT_SOURCE_DIR}/src
- ${CMAKE_BINARY_SOURCE_DIR}/src
- ${CMAKE_CURRENT_SOURCE_DIR}/src/common
- ${CMAKE_CURRENT_BINARY_DIR}/src/params
- ${CMAKE_CURRENT_BINARY_DIR}/src
- ${CMAKE_CURRENT_SOURCE_DIR}/src/common
+set( MAGICS_INCLUDE_DIRS
+ ${CMAKE_CURRENT_SOURCE_DIR}/src
+ ${CMAKE_BINARY_SOURCE_DIR}/src
+ ${CMAKE_CURRENT_SOURCE_DIR}/src/common
+ ${CMAKE_CURRENT_BINARY_DIR}/src/params
+ ${CMAKE_CURRENT_BINARY_DIR}/src
+ ${CMAKE_CURRENT_SOURCE_DIR}/src/common
${CMAKE_CURRENT_SOURCE_DIR}/src/basic
${CMAKE_CURRENT_SOURCE_DIR}/src/web
${CMAKE_CURRENT_SOURCE_DIR}/src/visualisers
@@ -310,7 +308,7 @@ add_subdirectory( src )
# shared files
add_subdirectory( share )
-# python interface
+# python interface
add_subdirectory( python )
# apps directory
@@ -325,18 +323,18 @@ endif()
# Directories not need in the distribution tar ball!
ecbuild_add_resources( TARGET old_src DONT_PACK_DIRS src/MvObs src/libTable src/xml src/terralib/functions)
ecbuild_add_resources( TARGET bamboo DONT_PACK_DIRS bamboo)
-ecbuild_add_resources( TARGET old_ressources
- DONT_PACK_DIRS tools/versioncmp
- tools/regression
+ecbuild_add_resources( TARGET old_ressources
+ DONT_PACK_DIRS tools/versioncmp
+ tools/regression
regression
docs
toolsjs
test/old
- tools/xml
+ tools/xml
tools/use_scripts
tools/versioncmp_folders)
-ecbuild_add_resources( TARGET internal
+ecbuild_add_resources( TARGET internal
DONT_PACK configure.lxab
configure.local
configure.ecgb
diff --git a/VERSION.cmake b/VERSION.cmake
index 31e8637..7fcf1ec 100644
--- a/VERSION.cmake
+++ b/VERSION.cmake
@@ -1,16 +1,16 @@
# (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
+# 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.
-set ( metabuilder_version 2.31.0 )
-set ( _version 2.31.0 )
+set ( metabuilder_version 2.32.0 )
+set ( _version 2.32.0 )
if ( MAGICS_BUILD )
- set( ${PROJECT_NAME}_VERSION_STR "${_version}-${MAGICS_BUILD}" )
+ set( ${PROJECT_NAME}_VERSION_STR "${_version}-${MAGICS_BUILD}" )
else ()
set( ${PROJECT_NAME}_VERSION_STR ${_version})
endif()
diff --git a/apps/metgram/CMakeLists.txt b/apps/metgram/CMakeLists.txt
index 19aad68..783b5a6 100644
--- a/apps/metgram/CMakeLists.txt
+++ b/apps/metgram/CMakeLists.txt
@@ -6,8 +6,8 @@ configure_file( metgram-script.in metgram.sh @ONLY )
set( MAGICS_METEOGRAM_SCRIPT ${CMAKE_CURRENT_SOURCE_DIR}/metgram
CACHE FILEPATH "Path to metgram script" )
-install ( DIRECTORY templates DESTINATION ${INSTALL_DATA_DIR}/.. FILE_PERMISSIONS OWNER_READ GROUP_READ WORLD_READ)
-
+install( DIRECTORY templates/ DESTINATION ${INSTALL_DATA_DIR}
+ FILE_PERMISSIONS OWNER_READ GROUP_READ WORLD_READ )
install ( FILES ${CMAKE_CURRENT_SOURCE_DIR}/metgram ${CMAKE_CURRENT_BINARY_DIR}/metgram.sh
DESTINATION ${INSTALL_BIN_DIR}
diff --git a/cmake/VERSION.cmake b/cmake/VERSION.cmake
index ce5f7de..ca1bacb 100644
--- a/cmake/VERSION.cmake
+++ b/cmake/VERSION.cmake
@@ -1,7 +1,7 @@
set( ECBUILD_MAJOR_VERSION "2" )
set( ECBUILD_MINOR_VERSION "6" )
-set( ECBUILD_PATCH_VERSION "0" )
+set( ECBUILD_PATCH_VERSION "1" )
-set( ECBUILD_VERSION_STR "2.6.0" )
+set( ECBUILD_VERSION_STR "2.6.1" )
set( ECBUILD_MACRO_VERSION "${ECBUILD_MAJOR_VERSION}.${ECBUILD_MINOR_VERSION}" )
diff --git a/cmake/ecbuild_check_functions.cmake b/cmake/ecbuild_check_functions.cmake
index 4307429..59fbd3a 100644
--- a/cmake/ecbuild_check_functions.cmake
+++ b/cmake/ecbuild_check_functions.cmake
@@ -96,6 +96,9 @@ if( ENABLE_OS_FUNCTIONS_TEST )
# test for struct statvfs64
ecbuild_cache_check_c_source_compiles( "#define _LARGEFILE64_SOURCE\n#include <sys/statvfs.h>\nint main(){ struct statvfs64 v; }" EC_HAVE_STRUCT_STATVFS64 )
+ # test for fopencookie
+ ecbuild_cache_check_c_source_compiles( "#define _GNU_SOURCE\n#include <stdio.h>\nint main(){ void* cookie; const char* mode; cookie_io_functions_t iof; FILE* fopencookie(void *cookie, const char *mode, cookie_io_functions_t iof); }" EC_HAVE_FOPENCOOKIE )
+
# test for fsync
ecbuild_cache_check_symbol_exists(fsync "unistd.h" EC_HAVE_FSYNC)
# test for fdatasync
diff --git a/cmake/ecbuild_config.h.in b/cmake/ecbuild_config.h.in
index 2eed359..a7d7d75 100644
--- a/cmake/ecbuild_config.h.in
+++ b/cmake/ecbuild_config.h.in
@@ -44,6 +44,7 @@
#cmakedefine EC_HAVE_FUNOPEN
#cmakedefine EC_HAVE_FLOCK
#cmakedefine EC_HAVE_MMAP
+#cmakedefine EC_HAVE_FOPENCOOKIE
#cmakedefine EC_HAVE_POSIX_MEMALIGN
diff --git a/cmake/ecbuild_declare_project.cmake b/cmake/ecbuild_declare_project.cmake
index e2f9cc8..348e2fe 100644
--- a/cmake/ecbuild_declare_project.cmake
+++ b/cmake/ecbuild_declare_project.cmake
@@ -122,12 +122,11 @@ macro( ecbuild_declare_project )
if( NOT INSTALL_INCLUDE_DIR )
set( INSTALL_INCLUDE_DIR include )
endif()
- if( NOT INSTALL_DATA_DIR )
- set( INSTALL_DATA_DIR share/${PROJECT_NAME} )
- endif()
- if( NOT INSTALL_CMAKE_DIR )
- set( INSTALL_CMAKE_DIR share/${PROJECT_NAME}/cmake )
- endif()
+ # INSTALL_DATA_DIR is package specific and needs to be reset for subpackages
+ # in a bundle. Users *cannot* override this directory (ECBUILD-315)
+ set( INSTALL_DATA_DIR share/${PROJECT_NAME} )
+ # share/${PROJECT_NAME}/cmake is a convention - it makes no sense to override it
+ set( INSTALL_CMAKE_DIR share/${PROJECT_NAME}/cmake )
mark_as_advanced( INSTALL_BIN_DIR )
mark_as_advanced( INSTALL_LIB_DIR )
diff --git a/cmake/ecbuild_find_omp.cmake b/cmake/ecbuild_find_omp.cmake
index ea9da24..15a5b81 100644
--- a/cmake/ecbuild_find_omp.cmake
+++ b/cmake/ecbuild_find_omp.cmake
@@ -155,7 +155,7 @@ macro( ecbuild_find_omp )
check_cxx_source_compiles("${_SOURCE}" ${_FLAG} )
endif()
if( _LANG STREQUAL "Fortran" )
- check_fortran_source_compiles("${_SOURCE}" ${_FLAG} )
+ check_fortran_source_compiles("${_SOURCE}" ${_FLAG} SRC_EXT f90)
endif()
set(CMAKE_REQUIRED_FLAGS "${SAVE_CMAKE_REQUIRED_FLAGS}")
endif()
diff --git a/cmake/ecbuild_generate_rpc.cmake b/cmake/ecbuild_generate_rpc.cmake
index e475f19..2eb8605 100644
--- a/cmake/ecbuild_generate_rpc.cmake
+++ b/cmake/ecbuild_generate_rpc.cmake
@@ -3,8 +3,8 @@
# 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.
+# granted to it by virtue of its status as an intergovernmental organisation
+# nor does it submit to any jurisdiction.
##############################################################################
#.rst:
@@ -38,63 +38,61 @@
macro( ecbuild_generate_rpc )
- set( options )
- set( single_value_args SOURCE TARGET_H TARGET_C )
- set( multi_value_args DEPENDANT )
+ set( options )
+ set( single_value_args SOURCE TARGET_H TARGET_C )
+ set( multi_value_args DEPENDANT )
- cmake_parse_arguments( _PAR "${options}" "${single_value_args}" "${multi_value_args}" ${_FIRST_ARG} ${ARGN} )
+ cmake_parse_arguments( _PAR "${options}" "${single_value_args}" "${multi_value_args}" ${_FIRST_ARG} ${ARGN} )
- if(_PAR_UNPARSED_ARGUMENTS)
- ecbuild_critical("Unknown keywords given to ecbuild_generate_rpc(): \"${_PAR_UNPARSED_ARGUMENTS}\"")
- endif()
+ if(_PAR_UNPARSED_ARGUMENTS)
+ ecbuild_critical("Unknown keywords given to ecbuild_generate_rpc(): \"${_PAR_UNPARSED_ARGUMENTS}\"")
+ endif()
- if( NOT _PAR_SOURCE )
- ecbuild_critical("The call to ecbuild_generate_rpc() doesn't specify the SOURCE file.")
- endif()
+ if( NOT _PAR_SOURCE )
+ ecbuild_critical("The call to ecbuild_generate_rpc() doesn't specify the SOURCE file.")
+ endif()
-# optional
-# if( NOT _PAR_DEPENDANT )
-# ecbuild_critical("The call to ecbuild_generate_rpc() doesn't specify the DEPENDANT files.")
-# endif()
+ # optional
+ # if( NOT _PAR_DEPENDANT )
+ # ecbuild_critical("The call to ecbuild_generate_rpc() doesn't specify the DEPENDANT files.")
+ # endif()
- if( NOT DEFINED _PAR_TARGET_H AND NOT DEFINED _PAR_TARGET_C )
- ecbuild_critical("The call to ecbuild_generate_rpc() doesn't specify the _PAR_TARGET_H or _PAR_TARGET_C files.")
- endif()
+ if( NOT DEFINED _PAR_TARGET_H AND NOT DEFINED _PAR_TARGET_C )
+ ecbuild_critical("The call to ecbuild_generate_rpc() doesn't specify the _PAR_TARGET_H or _PAR_TARGET_C files.")
+ endif()
- find_package( RPCGEN REQUIRED )
+ find_package( RPCGEN REQUIRED )
- if( DEFINED _PAR_TARGET_H )
+ if( DEFINED _PAR_TARGET_H )
- add_custom_command(
- OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${_PAR_TARGET_H}
- COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_CURRENT_SOURCE_DIR}/${_PAR_SOURCE} ${CMAKE_CURRENT_BINARY_DIR}/${_PAR_SOURCE}
- COMMAND ${CMAKE_COMMAND} -E remove ${CMAKE_CURRENT_BINARY_DIR}/${_PAR_TARGET_H}
- COMMAND ${RPCGEN_EXECUTABLE} -h -o ${CMAKE_CURRENT_BINARY_DIR}/${_PAR_TARGET_H} ${CMAKE_CURRENT_BINARY_DIR}/${_PAR_SOURCE}
- DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${_PAR_SOURCE} )
-
- if( DEFINED _PAR_DEPENDANT )
- foreach( file ${_PAR_DEPENDANT} )
- set_source_files_properties( ${file} PROPERTIES OBJECT_DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/${_PAR_TARGET_H}" )
- endforeach()
- endif()
+ add_custom_command(
+ OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${_PAR_TARGET_H}
+ COMMAND ${RPCGEN_EXECUTABLE} -h -o ${CMAKE_CURRENT_BINARY_DIR}/${_PAR_TARGET_H} ${_PAR_SOURCE}
+ WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
+ DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${_PAR_SOURCE} )
+ if( DEFINED _PAR_DEPENDANT )
+ foreach( file ${_PAR_DEPENDANT} )
+ set_source_files_properties( ${file} PROPERTIES OBJECT_DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/${_PAR_TARGET_H}" )
+ endforeach()
endif()
- if( DEFINED _PAR_TARGET_C )
+ endif()
- add_custom_command(
- OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${_PAR_TARGET_C}
- COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_CURRENT_SOURCE_DIR}/${_PAR_SOURCE} ${CMAKE_CURRENT_BINARY_DIR}/${_PAR_SOURCE}
- COMMAND ${CMAKE_COMMAND} -E remove ${CMAKE_CURRENT_BINARY_DIR}/${_PAR_TARGET_C}
- COMMAND ${RPCGEN_EXECUTABLE} -c -o ${CMAKE_CURRENT_BINARY_DIR}/${_PAR_TARGET_C} ${CMAKE_CURRENT_BINARY_DIR}/${_PAR_SOURCE}
- DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${_PAR_SOURCE} )
+ if( DEFINED _PAR_TARGET_C )
- if( DEFINED _PAR_DEPENDANT )
- foreach( file ${_PAR_DEPENDANT} )
- set_source_files_properties( ${file} PROPERTIES OBJECT_DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/${_PAR_TARGET_C}" )
- endforeach()
- endif()
+ add_custom_command(
+ OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${_PAR_TARGET_C}
+ COMMAND ${RPCGEN_EXECUTABLE} -c -o ${CMAKE_CURRENT_BINARY_DIR}/${_PAR_TARGET_C} ${_PAR_SOURCE}
+ WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
+ DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${_PAR_SOURCE} )
+ if( DEFINED _PAR_DEPENDANT )
+ foreach( file ${_PAR_DEPENDANT} )
+ set_source_files_properties( ${file} PROPERTIES OBJECT_DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/${_PAR_TARGET_C}" )
+ endforeach()
endif()
+ endif()
+
endmacro( ecbuild_generate_rpc )
diff --git a/magics.sublime-project b/magics.sublime-project
index 4c8dea6..30407a8 100644
--- a/magics.sublime-project
+++ b/magics.sublime-project
@@ -7,7 +7,7 @@
],
"build_systems": [
{
- "working_dir": "${project_path}/../../build/magics-bug/debug",
+ "working_dir": "${project_path}/../../build/magics-develop/debug",
"cmd": [
"make"
],
diff --git a/python/Magics/toolbox.py b/python/Magics/toolbox.py
index 28754e1..f7afbe2 100644
--- a/python/Magics/toolbox.py
+++ b/python/Magics/toolbox.py
@@ -7,13 +7,13 @@ def substitute(default, user):
for key in user:
out[key] = user[key]
- print out
+
return out
-def geoplot(data, contour=None, output=None, background=None, foreground=None, area=None, legend = None):
+def geoplot(data, contour=None, output=None, background=None, foreground=None, area=None, legend = None, title = []):
default = {
@@ -42,11 +42,7 @@ def geoplot(data, contour=None, output=None, background=None, foreground=None, a
)
contour = macro.mcont( substitute(default["contour"], contour) )
- #Define the title
- title = macro.mtext(
- text_font_size = 0.8,
- text_justification = "left"
- )
+
legend = macro.mlegend(substitute(default["legend"], legend))
return macro.plot(output, projection, background, data, contour, foreground, title, legend)
@@ -138,8 +134,67 @@ def graph(x,y, title="", graph = None) :
colour = "ecmwf_blue"
font_size = 0.35
-defaults = { "eps" :
- {
+defaults = {
+ "epswind" : {
+ "projection" : {
+ "subpage_map_projection" : 'cartesian',
+ "subpage_x_axis_type" : 'date',
+ "subpage_x_automatic" : 'on',
+ "subpage_y_axis_type" : 'regular',
+ "subpage_y_automatic" : 'off',
+ "subpage_y_max" : 43200.,
+ "subpage_y_min" : -43200.,
+ },
+ "vertical_axis" : {
+ "axis_orientation" : "vertical",
+ "axis_grid" : "on",
+ "axis_grid_colour" : "navy",
+ "axis_grid_line_style" :"dash",
+ "axis_grid_reference_level" : 0.,
+ "axis_grid_reference_thickness" : 1,
+ "axis_line" : "on",
+ "axis_line_colour" : "navy",
+ "axis_tick": "off",
+ "axis_tick_label": "off"
+
+ },
+ "epswind" : {
+ "eps_rose_wind_border_colour": "Rgb(0.5000, 0.5000, 0.5000)",
+ "eps_rose_wind_colour": "greenish_blue"
+ }
+ },
+
+ "epswave" : {
+ "projection" : {
+ "subpage_map_projection" : 'cartesian',
+ "subpage_x_axis_type" : 'date',
+ "subpage_x_automatic" : 'on',
+ "subpage_y_axis_type" : 'regular',
+ "subpage_y_automatic" : 'off',
+ "subpage_y_max" : 43200.,
+ "subpage_y_min" : -43200.,
+ },
+ "vertical_axis" : {
+ "axis_orientation" : "vertical",
+ "axis_grid" : "on",
+ "axis_grid_colour" : "navy",
+ "axis_grid_line_style" :"dash",
+ "axis_grid_reference_level" : 0.,
+ "axis_grid_reference_thickness" : 1,
+ "axis_line" : "on",
+ "axis_line_colour" : "navy",
+ "axis_tick": "off",
+ "axis_tick_label": "off"
+
+ },
+
+ "epswave": {
+ "eps_rose_wind_border_colour": "Rgb(0.5000, 0.5000, 0.5000)",
+ "eps_rose_wind_colour": "RGB(0.925,0.609,0.953)",
+ "eps_rose_wind_convention": "oceanographic"
+ },
+ },
+ "eps" : {
"projection" : {
"subpage_map_projection" : 'cartesian',
"subpage_x_axis_type" : 'date',
@@ -171,7 +226,7 @@ defaults = { "eps" :
"axis_grid_line_style" : "dash",
"axis_line_colour" : "navy",
"axis_minor_tick" : "off",
- "axis_minor_tick_colour=" : "navy",
+ "axis_minor_tick_colour" : "navy",
"axis_months_label" : "off",
"axis_tick_colour" : "navy",
"axis_type" : "date",
@@ -181,12 +236,12 @@ defaults = { "eps" :
"eps_box_border_thickness" : 2,
"eps_box_width" : 1.5,
"eps_box_colour" : colour,
- "eps_box_forecast_colour" : "black",
"eps_font_colour" :"navy",
"eps_legend_font_size" : font_size,
"eps_grey_legend" : "off",
"legend" :'off'
},
+
"epsclim" : {
"eps_shade_colour": colour,
"eps_shade_line_thickness": 4,
@@ -194,9 +249,136 @@ defaults = { "eps" :
}
}
-def epsgram(parameter, input, **args):
+
+def epswave(parameter, input, **args):
+ actions = []
+
+ projection = macro.mmap( substitute(defaults["epswave"]["projection"], args.get("projection", None)) )
+
+ # define horizontal axis
+ horizontal = macro.maxis(substitute(defaults["eps"]["horizontal_axis"], args.get("horizontal_axis", None)))
+ vertical = macro.maxis(substitute(defaults["epswave"]["vertical_axis"], args.get("vertical_axis", None)))
+
+
+ data = macro.mwrepjson(
+ wrepjson_family = "eps",
+ wrepjson_keyword = "eps",
+ wrepjson_input_filename = input,
+ wrepjson_parameter = parameter,
+ wrepjson_parameter_information = args.get("title", parameter),
+ wrepjson_parameter_scaling_factor = 1.,
+ )
+
+ wave = macro.mepswave(substitute(defaults["epswave"]["epswave"], args.get("epswave", None)) )
+
+
+ actions.append(projection)
+ actions.append(vertical)
+ actions.append(horizontal)
+
+ actions.append(data)
+ actions.append(wave)
+
+
+ text = macro.mtext(
+ text_colour = "navy",
+ text_font_size = font_size*2,
+ text_justification = "left",
+ text_lines = ["ENS Meteogram",
+ "<json_info key='station_name'/><json_info key='location'/><json_info key='grid_point'/><json_info key='height'/>",
+ "<json_info key='product_info'/><json_info key='date'/>",
+ "<font size='0.5' colour='white'>.</font>",
+ "<json_info key='parameter_info'/>",]
+
+ )
+
+ actions.append(text)
+
+ if "output" in args != "" :
+ #Setting of the output file name
+ png = macro.output(output_formats = ['png'],
+ output_name_first_page_number = "off",
+ output_name = args["output"],
+ super_page_y_length = 10.,
+ subpage_y_length = 5.,
+ subpage_y_position = 1.5)
+
+ return macro._plot(
+ png,
+ actions
+ )
+
+ return macro.plot(
+ actions
+ )
+
+def epswind(parameter, input, **args):
+ actions = []
+
+ projection = macro.mmap( substitute(defaults["epswind"]["projection"], args.get("projection", None)) )
+
+ # define horizontal axis
+ horizontal = macro.maxis(substitute(defaults["eps"]["horizontal_axis"], args.get("horizontal_axis", None)))
+ vertical = macro.maxis(substitute(defaults["epswind"]["vertical_axis"], args.get("vertical_axis", None)))
+
+
+ data = macro.mwrepjson(
+ wrepjson_family = "eps",
+ wrepjson_keyword = "eps",
+ wrepjson_input_filename = input,
+ wrepjson_parameter = parameter,
+ wrepjson_parameter_information = args.get("title", parameter),
+ wrepjson_parameter_scaling_factor = 1.,
+ )
+
+ wave = macro.mepswind(substitute(defaults["epswind"]["epswind"], args.get("epswind", None)) )
+
+
+ actions.append(projection)
+ actions.append(vertical)
+ actions.append(horizontal)
+
+ actions.append(data)
+ actions.append(wave)
+
+
+ text = macro.mtext(
+ text_colour = "navy",
+ text_font_size = font_size*2,
+ text_justification = "left",
+ text_lines = ["ENS Meteogram",
+ "<json_info key='station_name'/><json_info key='location'/><json_info key='grid_point'/><json_info key='height'/>",
+ "<json_info key='product_info'/><json_info key='date'/>",
+ "<font size='0.5' colour='white'>.</font>",
+ "<json_info key='parameter_info'/>",]
+
+ )
+
+ actions.append(text)
+
+ if "output" in args != "" :
+ #Setting of the output file name
+ png = macro.output(output_formats = ['png'],
+ output_name_first_page_number = "off",
+ output_name = args["output"],
+ super_page_y_length = 10.,
+ subpage_y_length = 5.,
+ subpage_y_position = 1.5)
+
+
+
+ return macro._plot(
+ png,
+ actions
+ )
+
+ return macro.plot(
+ actions
+ )
+
+def epsgraph(parameter, input, **args):
- print parameter, input, "ARGS--->", args
+
actions = []
@@ -213,25 +395,27 @@ def epsgram(parameter, input, **args):
wrepjson_input_filename = input,
wrepjson_parameter = parameter,
wrepjson_parameter_information = args.get("title", parameter),
- wrepjson_parameter_scaling_factor = 1.,
+ wrepjson_parameter_scaling_factor = args.get("scaling", 1.),
+ wrepjson_parameter_offset_factor = args.get("offset", 0.),
)
graph = macro.mepsgraph(substitute(defaults["eps"]["epsgraph"], args.get("epsgraph", None)) )
+
actions.append(projection)
actions.append(vertical)
actions.append(horizontal)
- print "DATA", input
-
- if "clim" in args :
- print "FILE--->", data
+
+ if "climate" in args :
+
clim = macro.mwrepjson(
wrepjson_family = "eps",
wrepjson_keyword = "clim",
wrepjson_input_filename = input,
wrepjson_parameter = parameter,
- wrepjson_parameter_scaling_factor = 1.,
+ wrepjson_parameter_scaling_factor = args.get("scaling", 1.),
+ wrepjson_parameter_offset_factor = args.get("offset", 0.),
wrepjson_ignore_keys = ["100"],
wrepjson_parameter_information = "none",
wrepjson_position_information = "off"
@@ -263,7 +447,11 @@ def epsgram(parameter, input, **args):
#Setting of the output file name
png = macro.output(output_formats = ['png'],
output_name_first_page_number = "off",
- output_name = args["output"])
+ output_name = args["output"],
+ super_page_y_length = 10.,
+ subpage_y_length = 5.,
+ subpage_y_position = 1.,
+ )
return macro._plot(
png,
@@ -274,12 +462,153 @@ def epsgram(parameter, input, **args):
actions
)
+
def epsclimgram(**kw):
- print kw
args = {"clim" :True }
args.update(kw)
- print args
- return epsgram(**args)
+ return epsgraph(**args)
+
+params = {
+ "2t": {
+ "scaling": 1.0,
+ "offset": -273.0,
+ "method": epsgraph,
+ "title": "2-metre temperature"
+ },
+ "mcc": {
+ "scaling": 1.0,
+ "offset": 0.0,
+ "method": epsgraph,
+ "title": "Medium cloud cover"
+ },
+ "10fg6": {
+ "scaling": 1.0,
+ "offset": 0.0,
+ "method": epsgraph,
+ "title": "10 metre wind gust in the last 6 hours"
+ },
+ "tp": {
+ "scaling": 1000.,
+ "offset": 0.0,
+ "method": epsgraph,
+ "title": "Total precipitation (last 6 hours) (m)"
+ },
+ "tcc": {
+ "scaling": 1.0,
+ "offset": 0.0,
+ "method": epsgraph,
+ "title": "Total cloud cover"
+ },
+ "hcc": {
+ "scaling": 1.0,
+ "offset": 0.0,
+ "method": epsgraph,
+ "title": "High cloud cover"
+ },
+ "ws": {
+ "scaling": 1.0,
+ "offset": 0.0,
+ "method": epsgraph,
+ "title": "Wind speed (m/s)"
+ },
+ "lcc": {
+ "scaling": 1.0,
+ "offset": 0.0,
+ "method": epsgraph,
+ "title": "Low cloud cover"
+ },
+ "sf": {
+ "scaling": 1000.0,
+ "offset": 0.0,
+ "method": epsgraph,
+ "title": "Snowfall (last 6 hours)"
+ },
+ "swh": {
+ "scaling": 1.0,
+ "offset": 0.0,
+ "method": epsgraph,
+ "title": "Significant wave height"
+ },
+ "mwp": {
+ "scaling": 1.0,
+ "offset": 0.0,
+ "method": epsgraph,
+ "title": "Mean wave period"
+ },
+ "dwi": {
+ "scaling": 1.0,
+ "offset": 0.0,
+ "method": epswind,
+ "title": "10 metre wind direction"
+ },
+ "mwd": {
+ "scaling": 1.0,
+ "offset": 0.0,
+ "method": epswave,
+ "title": "Mean wave direction"
+ },
+ "ws24": {
+ "scaling": 1.0,
+ "offset": 0.0,
+ "method": epsgraph,
+ "title": "Daily mean of 10m wind speed (m/s)"
+ },
+ "tcc24": {
+ "scaling": 1.0,
+ "offset": 0.0,
+ "method": epsgraph,
+ "title": "Daily mean of total cloud cover"
+ },
+ "mn2t24": {
+ "scaling": 1.0,
+ "offset": -273.15,
+ "method": epsgraph,
+ "title": "2 metre min temperature (Daily)"
+ },
+ "tp24": {
+ "scaling": 1000.0,
+ "offset": 0.0,
+ "method": epsgraph,
+ "title": "Total precipitation (mm/24hr)"
+ },
+ "mx2t24": {
+ "scaling": 1.,
+ "offset": -273.15,
+ "method": epsgraph,
+ "title": "2 metre max. temperature (Daily)"
+ },
+ "dwi24": {
+ "scaling": 1.0,
+ "offset": 0.0,
+ "method": epswind,
+ "title": "Daily distribution of 10m Wind Direction"
+ }
+
+}
+
+
+params_15days = { "mx2t24":"2 metre max. temperature (Daily)",
+ "mn2t24":"2 metre min temperature (Daily)",
+ "tcc24":"Daily mean of total cloud cover",
+ "tp24":"Total precipitation (mm/24hr)",
+ "dwi24":"Daily distribution of 10m Wind Direction",
+ "ws24":"Daily mean of 10m wind speed (m/s)",
+ }
+
+
+
+
+def epsgram(parameter, input, **args):
+
+ args["scaling"] = params[parameter]["scaling"]
+ args["offset"] = params[parameter]["offset"]
+ args["title"] = params[parameter]["title"]
+
+ params[parameter]["method"](parameter, input, **args)
+
+
+
+
diff --git a/share/CMakeLists.txt b/share/CMakeLists.txt
index 2f64ec1..63445af 100644
--- a/share/CMakeLists.txt
+++ b/share/CMakeLists.txt
@@ -1,3 +1,2 @@
-install ( DIRECTORY magics DESTINATION ${INSTALL_DATA_DIR}/.. FILE_PERMISSIONS OWNER_READ GROUP_READ WORLD_READ)
-
-
+install ( DIRECTORY magics/ DESTINATION ${INSTALL_DATA_DIR}
+ FILE_PERMISSIONS OWNER_READ GROUP_READ WORLD_READ )
diff --git a/share/magics/table_128.xml b/share/magics/table_128.xml
index 4066305..bd732ad 100644
--- a/share/magics/table_128.xml
+++ b/share/magics/table_128.xml
@@ -212,4 +212,4 @@ does it submit to any jurisdiction.
original_unit='K' derived_unit='deg c'
scaling='1.0' offset='-273.16'/>
</table>
-<centre/>
+</centre>
diff --git a/src/basic/LegendVisitor.cc b/src/basic/LegendVisitor.cc
index 74c19e9..08c059d 100644
--- a/src/basic/LegendVisitor.cc
+++ b/src/basic/LegendVisitor.cc
@@ -216,10 +216,10 @@ void LegendVisitor::build()
if ( !empty() ) {
if ( use_min_ ) {
- front()->userText(use_min_text_);
+ front()->userText(use_min_text_, "user");
}
if ( use_max_ ) {
- back()->userText(use_max_text_);
+ back()->userText(use_max_text_, "user");
}
back()->units(units_text_);
@@ -262,7 +262,7 @@ void LegendVisitor::build()
if (label == lines_.end()) --label;
}
}
-
+ (**entry).userText(text, composition_);
legend->setFont(font);
legend->setText(text);
legend->setAngle((orientation_/180.)*3.14);
@@ -781,13 +781,19 @@ void BoxEntry::rowBox(const PaperPoint& point, BasicGraphicsObjectContainer& leg
from->setVerticalAlign(MBOTTOM);
from->setAngle(angle_);
legend.push_back(from);
- if ( userText_.empty() || last_) {
+ if ( automatic_ ) {
ostringstream bottom;
bottom << MagicsFormat(format_, from_);
from->addText(bottom.str(), font_);
}
- else
- from->addText(userText_, font_);
+ else
+ if ( !last_ )
+ from->addText(userText_, font_);
+ else {
+ ostringstream bottom;
+ bottom << MagicsFormat(format_, from_);
+ from->addText(bottom.str(), font_);
+ }
}
if ( last_ ) {
Text* to = new Text();
@@ -795,24 +801,38 @@ void BoxEntry::rowBox(const PaperPoint& point, BasicGraphicsObjectContainer& leg
to->setVerticalAlign(MBOTTOM);
to->push_back(PaperPoint(x+width, y - height- 0.25));
legend.push_back(to);
- if ( userText_.empty() ) {
+ if ( automatic_ ) {
ostringstream top, bottom;
top << MagicsFormat(format_, to_);
to->addText(top.str(), font_);
}
- else
+ else
to->addText(userText_, font_);
}
+ Polyline* top = new Polyline();
+ top->push_back(PaperPoint(x-width, y+(height*2)));
+ top->push_back(PaperPoint(x+width, y+(height*2)));
+ top->setColour(borderColour_);
+ top->setThickness(2);
+
+ Polyline* bottom = new Polyline();
+ bottom->push_back(PaperPoint(x-width, y-height));
+ bottom->push_back(PaperPoint(x+width, y-height));
+ bottom->setColour(borderColour_);
+ bottom->setThickness(2);
+
box_->push_back(PaperPoint(x-width, y-height));
box_->push_back(PaperPoint(x-width, y+height+height));
box_->push_back(PaperPoint(x+width, y+height+height));
box_->push_back(PaperPoint(x+width, y-height));
box_->push_back(PaperPoint(x-width, y-height));
+
// Small check
Colour colour = ( borderColour_.automatic() ) ? box_->getFillColour() : borderColour_;
+
if ( box_->getFillColour() == Colour("none") ) {
box_->setFilled(false);
colour = Colour("black");
@@ -821,6 +841,27 @@ void BoxEntry::rowBox(const PaperPoint& point, BasicGraphicsObjectContainer& leg
legend.push_back(box_);
+ legend.push_back(top);
+ legend.push_back(bottom);
+
+ if ( last_ ) {
+ Polyline* right = new Polyline();
+ right->push_back(PaperPoint(x+width, y-height));
+ right->push_back(PaperPoint(x+width, y+(height*2)));
+ right->setColour(borderColour_);
+ right->setThickness(2);
+ legend.push_back(right);
+ }
+
+ if ( first_ ) {
+ Polyline* left = new Polyline();
+ left->push_back(PaperPoint(x-width, y-height));
+ left->push_back(PaperPoint(x-width, y+(height*2)));
+ left->setColour(borderColour_);
+ left->setThickness(2);
+ legend.push_back(left);
+ }
+
}
void BoxEntry::rowHisto(const PaperPoint& point, BasicGraphicsObjectContainer& legend, const Colour& colour)
@@ -847,7 +888,8 @@ void BoxEntry::rowHisto(const PaperPoint& point, BasicGraphicsObjectContainer& l
from->setVerticalAlign(MTOP);
from->setAngle(angle_);
legend.push_back(from);
- if ( userText_.empty() || last_) {
+
+ if ( automatic_ ) {
ostringstream bottom;
bottom << MagicsFormat(format_, from_);
from->addText(bottom.str(), font_);
@@ -867,7 +909,7 @@ void BoxEntry::rowHisto(const PaperPoint& point, BasicGraphicsObjectContainer& l
to->setVerticalAlign(MTOP);
to->push_back(PaperPoint(x+width, y + 1.3));
legend.push_back(to);
- if ( userText_.empty() ) {
+ if ( automatic_ ) {
ostringstream top, bottom;
top << MagicsFormat(format_, to_);
to->addText(top.str(), font_);
@@ -896,7 +938,7 @@ void BoxEntry::rowHisto(const PaperPoint& point, BasicGraphicsObjectContainer& l
to->setJustification(MRIGHT);
to->push_back(PaperPoint(x-width, y - 0.2 ));
legend.push_back(to);
- if ( userText_.empty() && histogram_->max() ) {
+ if ( userText_.empty() && histogram_->max() && automatic_ ) {
ostringstream top, bottom;
top << MagicsFormat(format_, totalPopulation_);
to->addText(top.str(), font_);
@@ -1008,13 +1050,14 @@ void BoxEntry::columnBox(const PaperPoint& point, BasicGraphicsObjectContainer&
Text* from = new Text();
from->setJustification(MLEFT);
from->setVerticalAlign(MHALF);
- if ( userText_.empty() || last_) {
+ if ( automatic_ ) {
ostringstream bottom;
bottom << MagicsFormat(format_, from_);
from->addText(bottom.str(), font_);
}
- else
- from->addText(userText_, font_);
+ else
+ if ( !last_ )
+ from->addText(userText_, font_);
PaperPoint pfrom(pt);
pfrom.y_ = y - height;
from->push_back(pfrom);
@@ -1026,7 +1069,7 @@ void BoxEntry::columnBox(const PaperPoint& point, BasicGraphicsObjectContainer&
to->setVerticalAlign(MHALF);
to->setJustification(MLEFT);
to->setAngle(angle_);
- if ( userText_.empty() ) {
+ if ( automatic_ ) {
ostringstream top, bottom;
top << MagicsFormat(format_, to_);
to->addText(top.str(), font_);
@@ -1049,7 +1092,40 @@ void BoxEntry::columnBox(const PaperPoint& point, BasicGraphicsObjectContainer&
}
box_->setColour(colour);
legend.push_back(box_);
+
+ Polyline* left = new Polyline();
+ left->push_back(PaperPoint(x-width, y-(height)));
+ left->push_back(PaperPoint(x-width, y+(height)));
+ left->setColour(borderColour_);
+ left->setThickness(2);
+
+ Polyline* right = new Polyline();
+ right->push_back(PaperPoint(x+width, y-height));
+ right->push_back(PaperPoint(x+width, y+(height)));
+ right->setColour(borderColour_);
+ right->setThickness(2);
+
+ legend.push_back(left);
+ legend.push_back(right);
+
+ if ( last_ ) {
+ Polyline* top = new Polyline();
+ top->push_back(PaperPoint(x-width, y+(height)));
+ top->push_back(PaperPoint(x+width, y+(height)));
+ top->setColour(borderColour_);
+ top->setThickness(2);
+ legend.push_back(top);
+ }
+ if ( first_ ) {
+ Polyline* bottom = new Polyline();
+ bottom->push_back(PaperPoint(x-width, y-height));
+ bottom->push_back(PaperPoint(x+width, y-height));
+ bottom->setColour(borderColour_);
+ bottom->setThickness(2);
+ legend.push_back(bottom);
+ }
}
+
void BoxEntry::columnHisto(const PaperPoint& point, BasicGraphicsObjectContainer& legend, const Colour& colour)
{
diff --git a/src/basic/LegendVisitor.h b/src/basic/LegendVisitor.h
index fd62ca8..f06d4ed 100644
--- a/src/basic/LegendVisitor.h
+++ b/src/basic/LegendVisitor.h
@@ -70,7 +70,12 @@ public:
string from() { return tostring(from_); }
string to() { return tostring(to_); }
- void userText(const string& text) { userText_ = text; }
+ void userText(const string& text, const string& automatic)
+ { if ( userText_.size() )
+ return;
+ userText_ = text;
+ automatic_ = magCompare(automatic, "automatic_text_only");
+ }
const string& userText() { return userText_; }
const string& units() { return units_; }
void units(const string& units) { units_ = units; }
@@ -98,11 +103,12 @@ public:
void mean(double mean) { meanValue_ = mean; meanSet_ = true; }
void histogramInformation(HistogramLegendMethod* histo) {histogram_ = histo;}
void borderColour(const Colour& colour) { borderColour_ = colour; }
-
+
protected:
bool last_;
bool first_;
bool text_;
+ bool automatic_; // True if the tlegend text is generated automaticaly from the value.
mutable string label_;
bool fromto_;
Colour borderColour_;
@@ -111,8 +117,10 @@ protected:
string userText_;
string units_;
+
double from_;
double to_;
+
string format_;
MagFont font_;
double angle_;
@@ -388,7 +396,7 @@ protected:
string both(const string& automatic, const string& user)
{ return automatic + " " + user; }
string user_only(const string&, const string& user)
- { return user; }
+ { if ( user.empty() ) return " "; return user; }
string automatic_only(const string& automatic, const string&)
{ return automatic; }
diff --git a/src/basic/TagHandler.cc b/src/basic/TagHandler.cc
index 48329a0..e5b08be 100644
--- a/src/basic/TagHandler.cc
+++ b/src/basic/TagHandler.cc
@@ -115,6 +115,7 @@ TagConverter::TagConverter(TagHandler& owner) : owner_(owner), text_(0) {
map_["text"] = &TagConverter::pass;
map_["box"] = &TagConverter::pass;
map_["br"] = &TagConverter::pass;
+ //map_["empty"] = &TagConverter::empty;
}
TagConverter::~TagConverter() {}
@@ -138,6 +139,13 @@ void TagConverter::text(const XmlNode& node) {
node.visit(*this);
}
+void TagConverter::empty(const XmlNode&) {
+ // Add emopty text
+ label_ = " ";
+ top().text(" ");
+ push();
+
+}
void TagConverter::grib(const XmlNode& node) {
//MagLog::dev()<< "checking grib!" << endl;
diff --git a/src/basic/TagHandler.h b/src/basic/TagHandler.h
index ecdf1bd..1bb1b22 100644
--- a/src/basic/TagHandler.h
+++ b/src/basic/TagHandler.h
@@ -79,6 +79,7 @@ public:
void netcdf(const XmlNode&);
void spot(const XmlNode&);
void pass(const XmlNode&);
+ void empty(const XmlNode&);
void font(const MagFont& font) { font_ = font; }
void magics(const XmlNode&);
diff --git a/src/common/Colour.cc b/src/common/Colour.cc
index 647fa0a..aab392f 100644
--- a/src/common/Colour.cc
+++ b/src/common/Colour.cc
@@ -203,7 +203,7 @@ Colour::~Colour() {}
void Colour::print(ostream& out) const
{
- out <<name_ << "["<<rgb_.red_<<", "<<rgb_.green_<< ", "<< rgb_.blue_ << ", " << rgb_.alpha_<<"] ";
+ out << "["<<rgb_.red_<<", "<<rgb_.green_<< ", "<< rgb_.blue_ << ", " << rgb_.alpha_<<"] ";
}
Hsl Colour::hsl() const
diff --git a/src/common/Colour.h b/src/common/Colour.h
index 56d9726..34b0191 100644
--- a/src/common/Colour.h
+++ b/src/common/Colour.h
@@ -139,7 +139,10 @@ public:
void set(const XmlNode&);
Colour* clone() const { return new Colour(*this); }
bool automatic() const { return automatic_; }
- bool none() const;
+ bool none() const;
+ bool white() const
+ { return ( red() == 1 && blue() == 1 && green() == 1 ) ||
+ ( red() == 256 && blue() == 256 && green() == 256 ); }
// -- Methods
float red() const { return rgb_.red_; }
float blue() const { return rgb_.blue_; }
diff --git a/src/common/ColourTableDefinitionCompute.cc b/src/common/ColourTableDefinitionCompute.cc
index 1eb8f72..6e9cc32 100644
--- a/src/common/ColourTableDefinitionCompute.cc
+++ b/src/common/ColourTableDefinitionCompute.cc
@@ -28,6 +28,18 @@ using namespace magics;
ColourTableDefinitionCompute::ColourTableDefinitionCompute()
{
+ methods_["anti_clockwise"] = &ColourTableDefinitionCompute::hsl;
+ methods_["clockwise"] = &ColourTableDefinitionCompute::hsl;
+ methods_["linear"] = &ColourTableDefinitionCompute::linear;
+
+}
+
+ColourTableDefinitionCompute::ColourTableDefinitionCompute(const string& min, const string& max, const string& method, const string& direction) :
+ minColour_(min), maxColour_(max), direction_(direction), method_(method)
+{
+ methods_["hsl"] = &ColourTableDefinitionCompute::hsl;
+ methods_["linear"] = &ColourTableDefinitionCompute::linear;
+ methods_["hcl"] = &ColourTableDefinitionCompute::hcl;
}
@@ -69,17 +81,208 @@ void ColourTableDefinitionCompute::set(const XmlNode& node)
}
+
+void ColourTableDefinitionCompute::hsl(ColourTable& table, int nb)
+{
+ float step_hue;
+ float step_light;
+ float step_alpha;
+ float step_sat;
+ Hsl hmin = minColour_.hsl();
+ Hsl hmax = maxColour_.hsl();
+
+
+ step_sat = (hmax.saturation_ - hmin.saturation_)/(nb-2);
+ step_light = (hmax.light_ - hmin.light_)/(nb-2);
+ step_alpha = (hmax.alpha_ - hmin.alpha_)/(nb-2);
+
+
+
+ if ( magCompare(direction_, "anti_clockwise") ) {
+ if ( hmax.hue_ < hmin.hue_ ) hmax.hue_ += 360;
+ step_hue = (hmax.hue_ - hmin.hue_)/(nb-2);
+ }
+ else {
+ if ( hmin.hue_ < hmax.hue_ ) hmin.hue_ += 360;
+ step_hue = (hmax.hue_ - hmin.hue_)/(nb-2);
+ }
+
+
+if ( minColour_.white() ) {
+ step_sat = 0;
+ step_hue = 0;
+ hmin.saturation_ = hmax.saturation_;
+ hmin.hue_ = hmax.hue_;
+
+}
+ //cout << maxColour_ << "WHITE???" << endl;
+ if ( maxColour_.white() ) {
+ step_sat = 0;
+ step_hue = 0;
+
+ //cout << maxColour_ << "WHITE" << endl;
+ }
+
+
+
+ // WE have nb levels : we need nb-1 colours!
+
+ for ( int i = 0; i < nb-1; i++) {
+ MagLog::dev() << "ColourTableDefinitionCompute::set->add-->" << Colour(hmin) << endl;
+ table.push_back(Colour(hmin));
+ hmin.saturation_ += step_sat;
+ hmin.hue_ += step_hue;
+ hmin.light_ += step_light;
+ hmin.alpha_ += step_alpha;
+ }
+}
+
+
+
+
+#include <math.h>
+void ColourTableDefinitionCompute::hsl_shortest(ColourTable& table, int nb)
+{
+
+ Hsl hmin = minColour_.hsl();
+ Hsl hmax = maxColour_.hsl();
+
+
+ float angle = fmod((hmax.hue_ - hmin.hue_ + 360.),360.);
+
+
+ if ( angle > 180)
+ direction_ = "clockwise";
+
+
+ else
+ direction_ = "anti_clockwise";
+
+
+
+ hsl(table, nb);
+
+
+}
+#include <math.h>
+void ColourTableDefinitionCompute::hsl_longest(ColourTable& table, int nb)
+{
+
+ Hsl hmin = minColour_.hsl();
+ Hsl hmax = maxColour_.hsl();
+
+
+ float angle = fmod((hmax.hue_ - hmin.hue_ + 360.),360.);
+
+
+ if ( angle > 180) {
+ direction_ = "anti_clockwise";
+
+ }
+ else {
+ direction_ = "clockwise";
+ }
+
+ hsl(table, nb);
+
+}
+
+void ColourTableDefinitionCompute::linear(ColourTable& table, int nb)
+{
+ float step_red;
+ float step_green;
+ float step_blue;
+ float step_alpha;
+
+ step_red = (maxColour_.red() - minColour_.red())/(nb-2);
+ step_green = (maxColour_.green() - minColour_.green())/(nb-2);
+ step_blue = (maxColour_.blue() - minColour_.blue())/(nb-2);
+ step_alpha = (maxColour_.alpha() - minColour_.alpha() )/(nb-2);
+ float red = minColour_.red();
+ float green = minColour_.green();
+ float blue = minColour_.blue();
+ float alpha = minColour_.alpha();
+
+ for ( int i = 0; i < nb-1; i++) {
+ table.push_back(Colour(red, green, blue, alpha));
+
+ red += step_red;
+ green += step_green;
+ blue += step_blue;
+ alpha += step_alpha;
+ }
+
+}
+
+void ColourTableDefinitionCompute::hcl(ColourTable& table, int nb)
+{
+ float step_h;
+ float step_c;
+ float step_l;
+ float step_alpha;
+
+ float minh, minc, minl;
+ float maxh, maxc, maxl;
+
+ hcl(maxColour_, maxh, maxc, maxl);
+ hcl(minColour_, minh, minc, minl);
+
+ if ( maxh == -1)
+ maxh = minh;
+ if ( minh == -1)
+ minh = maxh;
+
+ if ( magCompare(direction_, "shortest") ) {
+ float angle = fmod((maxh - minh + 360.),360.);
+ direction_ = ( angle > 180 ) ? "clockwise" : "anti_clockwise";
+ }
+
+ if ( magCompare(direction_, "longest") ) {
+ float angle = fmod((maxh - minh + 360.),360.);
+ direction_ = ( angle < 180 ) ? "clockwise" : "anti_clockwise";
+ }
+
+ if ( magCompare(direction_, "anti_clockwise") ) {
+ if ( maxh < minh )
+ maxh += 360;
+
+ }
+ else {
+ if ( minh < maxh )
+ minh += 360;
+ }
+
+ step_h = (maxh - minh)/(nb-2);
+ step_c = ( maxc - minc )/(nb-2);
+ step_l = ( maxl - minl )/(nb-2);
+
+ step_alpha = (maxColour_.alpha() - minColour_.alpha() )/(nb-2);
+
+ float h =minh;
+ float c =minc;
+ float l =minl;
+ float alpha = minColour_.alpha();
+
+ for ( int i = 0; i < nb-1; i++) {
+ table.push_back(rgb(h, c, l, alpha));
+
+ h += step_h;
+ c += step_c;
+ l += step_l;
+ alpha += step_alpha;
+ }
+
+}
+
+
void ColourTableDefinitionCompute::set(ColourTable& table, int nb)
{
prepare();
- double step_hue;
- double step_light;
- double step_alpha;
+
MagLog::dev() << "ColourTableDefinitionCompute::set->min-->" << minColour_ << endl;
MagLog::dev() << "ColourTableDefinitionCompute::set->max-->" << maxColour_ << endl;
MagLog::dev() << "nb interval-->" << nb << endl;
- Hsl hmin = minColour_.hsl();
- Hsl hmax = maxColour_.hsl();
+
if (nb == 1) {
table.push_back(minColour_);
return;
@@ -93,32 +296,171 @@ void ColourTableDefinitionCompute::set(ColourTable& table, int nb)
table.push_back(maxColour_);
return;
}
-
+ std::map<string, ComputeFunction>::iterator method = methods_.find(lowerCase(method_));
+ if ( method == methods_.end() )
+ hsl(table, nb);
+ else
+ (this->*method->second)(table, nb);
+
+
+}
- step_light = (hmax.light_ - hmin.light_)/(nb-2);
- step_alpha = (hmax.alpha_ - hmin.alpha_)/(nb-2);
- if ( magCompare(direction_, "anti_clockwise") ) {
- if ( hmax.hue_ < hmin.hue_ ) hmax.hue_ += 360;
- step_hue = (hmax.hue_ - hmin.hue_)/(nb-2);
- }
- else {
- if ( hmin.hue_ < hmax.hue_ ) hmin.hue_ += 360;
- step_hue = (hmax.hue_ - hmin.hue_)/(nb-2);
- }
+static const float toRadFactor=3.14159265359/180.;
+static const float toDegFactor=180./3.14159265359;
-
- float step_sat = (hmax.saturation_ - hmin.saturation_)/(nb-2);
- // WE have nb levels : we need nb-1 colours!
-
- for ( int i = 0; i < nb-1; i++) {
- MagLog::dev() << "ColourTableDefinitionCompute::set->add-->" << Colour(hmin) << endl;
- table.push_back(Colour(hmin));
- hmin.saturation_ += step_sat;
- hmin.hue_ += step_hue;
- hmin.light_ += step_light;
- hmin.alpha_ += step_alpha;
- }
+//reference values for the XYZ colour model.Observer= 2 deg, illuminant= D65
+static float REF_X=95.047;
+static float REF_Y=100.000;
+static float REF_Z=108.883;
+
+void ColourTableDefinitionCompute::hcl(const Colour& colour, float& h, float& c, float& l)
+{
+ float x, y, z;
+ rgbToXyz(colour.red(), colour.green(), colour.blue(), x, y, z);
+ xyzToHcl(x, y, z, h, c, l);
+ h *= 360;
+ if ( colour.red() == 1 && colour.green() == 1 && colour.blue() == 1 )
+ h = -1;
+}
+
+Colour ColourTableDefinitionCompute::rgb(float h, float c, float l, float alpha)
+{
+ float x, y, z;
+ float r, g, b;
+
+ hclToXyz(h/360., c, l, x, y, z);
+ xyzToRgb(x, y, z, r, g, b);
+ return Colour(r, g, b, alpha);
+
+}
+
+void ColourTableDefinitionCompute::xyzToRgb(float x, float y, float z, float& r, float& g, float& b)
+{
+ x=x/100.; //x from 0 to 95.047
+ y=y/100.; //y from 0 to 100.000
+ z=z/100.; //z from 0 to 108.883
+
+ r=x*3.2406 + y *(-1.5372) + z *(-0.4986);
+ g=x*(-0.9689) + y * 1.8758 + z* 0.0415;
+ b=x* 0.0557 + y*(-0.2040) + z* 1.0570;
+
+ if(r> 0.0031308)
+ r= 1.055 * pow(r,1./2.4) - 0.055;
+ else
+ r= 12.92 * r;
+
+ if(g > 0.0031308 )
+ g = 1.055 * pow(g,1./2.4) - 0.055;
+ else
+ g = 12.92 * g;
+
+ if(b > 0.0031308 )
+ b = 1.055 * pow(b,1./2.4) - 0.055;
+ else
+ b = 12.92 * b;
+
+ if(r>1.) r=1.;
+ if(g>1.) g=1.;
+ if(b>1.) b=1.;
+
+ if(r<0.) r=0.;
+ if(g<0.) g=0.;
+ if(b<0.) b=0.;
}
+void ColourTableDefinitionCompute::xyzToHcl(float x, float y, float z, float& h, float& c, float& l)
+{
+ x/=REF_X;
+ y/=REF_Y;
+ z/=REF_Z;
+
+ if(x> 0.008856)
+ x=pow(x,1./3.);
+ else
+ x=(7.787*x) + (16./116.);
+
+ if(y > 0.008856)
+ y = pow(y,1./3.);
+ else
+ y = (7.787*y) + ( 16. / 116. );
+
+ if(z> 0.008856)
+ z=pow(z,1./3.);
+ else
+ z = (7.787 * z) + ( 16. / 116. );
+
+ l = ( 116. * y )-16.;
+ float a = 500.*(x-y);
+ float b = 200.*(y-z);
+
+ h = atan2(b,a);
+
+ if(h>0)
+ h = h*toDegFactor;
+ else
+ h = 360.+h*toDegFactor;
+
+ h=h/360.;
+ c = sqrt(a*a + b*b);
+
+}
+
+void ColourTableDefinitionCompute::hclToXyz(float h, float c,float l,float& x, float& y, float& z)
+{
+
+ float a = cos(360*h*toRadFactor) * c;
+ float b = sin(360*h*toRadFactor) * c;
+
+ y=(l + 16.)/116.;
+ x=a/500.+ y;
+ z=y-b/200.;
+
+ if(pow(y,3) > 0.008856 )
+ y=pow(y,3);
+ else
+ y=(y - 16./116.)/7.787;
+
+ if(pow(x,3) > 0.008856)
+ x=pow(x,3);
+ else
+ x=(x-16./116.)/7.787;
+
+ if(z > 0.008856 )
+ z=pow(z,3);
+ else
+ z=(z-16./116.)/7.787;
+
+ x*=REF_X;
+ y*=REF_Y;
+ z*=REF_Z;
+
+}
+
+void ColourTableDefinitionCompute::rgbToXyz(float r, float g, float b, float& x, float& y, float& z)
+{
+
+ if(r > 0.04045)
+ r=pow((r+0.055)/1.055,2.4);
+ else
+ r = r/12.92;
+
+ if(g > 0.04045 )
+ g=pow((g + 0.055)/1.055,2.4);
+ else
+ g=g/12.92;
+
+ if(b > 0.04045)
+ b=pow((b + 0.055)/1.055,2.4);
+ else
+ b =b/12.92;
+
+ r*=100;
+ g*=100;
+ b*=100;
+
+ x = r*0.4124+g*0.3576+b*0.1805;
+ y = r*0.2126+g*0.7152+b*0.0722;
+ z = r*0.0193+g*0.1192+b*0.9505;
+}
diff --git a/src/common/ColourTableDefinitionCompute.h b/src/common/ColourTableDefinitionCompute.h
index 0869ee4..648e56a 100644
--- a/src/common/ColourTableDefinitionCompute.h
+++ b/src/common/ColourTableDefinitionCompute.h
@@ -33,6 +33,8 @@ class ColourTableDefinitionCompute: public ColourTableDefinition {
public:
ColourTableDefinitionCompute();
+
+ ColourTableDefinitionCompute(const string& min, const string& max, const string& method, const string& direction);
virtual ~ColourTableDefinitionCompute();
void set(const ColourTableDefinitionComputeInterface&);
void set(const XmlNode&);
@@ -44,14 +46,33 @@ public:
return object;
}
void set(ColourTable&, int);
+
+ typedef void (ColourTableDefinitionCompute::*ComputeFunction)(ColourTable&, int);
+ map<string, ComputeFunction > methods_;
+ void hsl(ColourTable&, int);
+ void hcl(ColourTable&, int);
+ void linear(ColourTable&, int);
+ void hsl_shortest(ColourTable&, int);
+ void hsl_longest(ColourTable&, int);
+
+
protected:
//! Method to print string about this class on to a stream of type ostream (virtual).
virtual void print(ostream&) const;
Colour minColour_;
Colour maxColour_;
string direction_;
+ string method_;
+ void hcl(const Colour& colour, float& h, float& c, float& l);
+ Colour rgb(float h, float c, float l, float alpha);
+ void xyzToRgb(float, float,float,float&,float&, float&);
+ void xyzToHcl(float, float,float,float&,float&, float&);
+ void hclToXyz(float, float,float,float&,float&, float&);
+ void rgbToXyz(float, float,float,float&,float&, float&);
+
+
private:
//! Copy constructor - No copy allowed
ColourTableDefinitionCompute(const ColourTableDefinitionCompute&);
diff --git a/src/common/ColourTableDefinitionList.h b/src/common/ColourTableDefinitionList.h
index ae7dd7f..14086ef 100644
--- a/src/common/ColourTableDefinitionList.h
+++ b/src/common/ColourTableDefinitionList.h
@@ -30,6 +30,8 @@
namespace magics {
+class LevelSelection;
+
class ColourTableDefinitionList: public ColourTableDefinition {
public:
diff --git a/src/common/GeoRectangularProjection.cc b/src/common/GeoRectangularProjection.cc
index d381c54..f56fb1e 100644
--- a/src/common/GeoRectangularProjection.cc
+++ b/src/common/GeoRectangularProjection.cc
@@ -521,11 +521,6 @@ bool MercatorProjection::fast_reproject(double& x, double& y) const
}
-double round( double x)
-{
- double prec = 100.;
- return floor(x*prec+0.5)/prec;
-}
void GeoRectangularProjection::setNewPCBox(double minx, double miny, double maxx, double maxy)
{
diff --git a/src/common/Matrix.cc b/src/common/Matrix.cc
index d36880b..1259fcf 100644
--- a/src/common/Matrix.cc
+++ b/src/common/Matrix.cc
@@ -593,7 +593,7 @@ double Proj4MatrixHandler::nearest(double row, double column) const
return MatrixHandler::nearest(y, x);
}
-double Proj4MatrixHandler::column(int i , int j)
+double Proj4MatrixHandler::column(int i , int j) const
{
double column = MatrixHandler::column(i, j);
double row = MatrixHandler::row(i, j);
@@ -606,7 +606,7 @@ double Proj4MatrixHandler::column(int i , int j)
}
-double Proj4MatrixHandler::row(int i, int j)
+double Proj4MatrixHandler::row(int i, int j) const
{
double column = MatrixHandler::column(i, j);
double row = MatrixHandler::row(i, j);
diff --git a/src/common/MatrixHandler.h b/src/common/MatrixHandler.h
index a3284ca..ab5fef3 100644
--- a/src/common/MatrixHandler.h
+++ b/src/common/MatrixHandler.h
@@ -213,7 +213,7 @@ public :
virtual double width() const { return matrix_.width(); }
virtual double height() const { return matrix_.height(); }
- virtual const AbstractMatrix& original() const { return matrix_.original(); }
+ virtual const AbstractMatrix& original() const { return delegate() ? matrix_ : matrix_.original(); }
virtual int firstRow() const { return matrix_.firstRow(); }
virtual int nextRow(int i, int f) const { return matrix_.nextRow(i, f); }
virtual int firstColumn() const { return matrix_.firstColumn(); }
@@ -498,8 +498,8 @@ public :
double interpolate(double row, double column) const { matrix_.interpolate(row, column); }
double nearest(double row, double column) const { matrix_.nearest(row, column); }
- double column(int i, int j) { matrix_.column(i, j); }
- double row(int i, int j) { matrix_.row(i, j); }
+ double column(int i, int j) const { matrix_.column(i, j); }
+ double row(int i, int j) const { matrix_.row(i, j); }
protected :
@@ -520,8 +520,8 @@ public :
double interpolate(double row, double column) const;
double nearest(double row, double column) const;
- double column(int, int);
- double row(int, int);
+ double column(int, int) const;
+ double row(int, int) const;
bool delegate() const { return true; }
diff --git a/src/common/PolarStereographicProjection.cc b/src/common/PolarStereographicProjection.cc
index 6867041..17adb17 100644
--- a/src/common/PolarStereographicProjection.cc
+++ b/src/common/PolarStereographicProjection.cc
@@ -162,11 +162,14 @@ void PolarStereographicProjection::init(double width, double height)
if ( !projection_ )
projection_ = new TePolarStereographic(TeDatum(), vertical_longitude_*TeCDR, 0., 0., "Meters", (hemisphere_ == NORTH) ? TeNORTH_HEM : TeSOUTH_HEM);
+
+
if ( magCompare(area_, "full") ) {
ymin_ = ( hemisphere_ == NORTH ) ? -20. : 20.;
ymax_ = ( hemisphere_ == NORTH ) ? -20. : 20.;
- xmin_ = ( hemisphere_ == NORTH ) ? -45. : 45.;
- xmax_ = ( hemisphere_ == NORTH ) ? 135. : -135.;
+ xmin_ = ( hemisphere_ == NORTH ) ? -45. + vertical_longitude_ : 45. + vertical_longitude_;
+ xmax_ = ( hemisphere_ == NORTH ) ? 135. + vertical_longitude_ : -135. + vertical_longitude_;
+ cout << "xmin --> " << xmin_ << " xmax --> " << xmax_ << endl;
}
else
magCompare(area_, "corners" ) ? corners() : centre(width, height);
@@ -582,7 +585,7 @@ void PolarStereographicProjection::labels(const LabelPlotting& label, DrawingVis
const vector<double>& latitudes = label.latitudes();
//const vector<double>& longitudes = label.longitudes();
vector<double> longitudes;
- longitudes.push_back(0);
+ longitudes.push_back(vertical_longitude_);
unsigned int flat = (unsigned int) std::max(1, (int) maground(latitudes.size()/4));
unsigned int flon = (unsigned int) std::max(1, (int) maground(longitudes.size()/4));
@@ -680,10 +683,12 @@ void PolarStereographicProjection::corners()
// For backwards compatibility!
if ( min_longitude_ == -180 && max_longitude_ == 180 &&
min_latitude_ == -90 && max_latitude_ == 90 ) {
+
+
min_latitude_ = ( hemisphere_ == NORTH ) ? -20. : 20.;
max_latitude_ = ( hemisphere_ == NORTH ) ? -20. : 20.;
- min_longitude_ = ( hemisphere_ == NORTH ) ? -45. : 45.;
- max_longitude_ = ( hemisphere_ == NORTH ) ? 135. : -135.;
+ min_longitude_ = ( hemisphere_ == NORTH ) ? -45. + vertical_longitude_: 45.+ vertical_longitude_;
+ max_longitude_ = ( hemisphere_ == NORTH ) ? 135. + vertical_longitude_: -135.+ vertical_longitude_;
}
xmin_ = min_longitude_;
diff --git a/src/common/Proj4Projection.cc b/src/common/Proj4Projection.cc
index 3761585..1644902 100644
--- a/src/common/Proj4Projection.cc
+++ b/src/common/Proj4Projection.cc
@@ -236,9 +236,13 @@ void Proj4Projection::init()
ASSERT(false);
}
+
methods_["geos"] = &Proj4Projection::geos;
methods_["conic"] = &Proj4Projection::conic;
methods_["simple"] = &Proj4Projection::simple;
+
+
+
map<string, InitMethod >::iterator method = methods_.find(projection_->method_);
if ( method != methods_.end() )
(this->*method->second)();
@@ -249,6 +253,10 @@ void Proj4Projection::init()
helpers_["full"] = &Proj4Projection::full;
helpers_["corners"] = &Proj4Projection::corners;
helpers_["centre"] = &Proj4Projection::centre;
+ helpers_["projection"] = &Proj4Projection::projectionSimple;
+
+ if ( coordinates_system_ == "projection" )
+ setting_ = "projection";
map<string, SettingHelper >::iterator helper = helpers_.find(lowerCase(setting_));
@@ -452,6 +460,40 @@ void Proj4Projection::simple()
add(projection_->minlon_, projection_->minlat_);
}
+void Proj4Projection::projectionSimple()
+{
+
+ min_pcx_ = min_longitude_;
+ min_pcy_ = min_latitude_;
+ max_pcx_ = max_longitude_;
+ max_pcy_ = max_latitude_;
+ pj_transform(to_, from_, 1, 1, &min_longitude_, &min_latitude_, NULL );
+ pj_transform(to_, from_, 1, 1, &max_longitude_, &max_latitude_, NULL );
+
+ min_longitude_ *= RAD_TO_DEG;
+ min_latitude_ *= RAD_TO_DEG;
+ max_longitude_ *= RAD_TO_DEG;
+ max_latitude_ *= RAD_TO_DEG;
+
+ Polyline box;
+ box.box(PaperPoint(min_pcx_, min_pcy_), PaperPoint(max_pcx_, max_pcy_));
+
+ vector<Polyline> newbox;
+ PCEnveloppe_->intersect(box, newbox);
+ if ( newbox.empty() ) {
+ MagLog::warning() << "Proj4 : the sub-area is not valid : use global view instead" << endl;
+ }
+ else {
+ PCEnveloppe_ = newbox.front().clone();
+ }
+ // reset
+ setting_ = "corners";
+ coordinates_system_ = "latlon";
+
+}
+
+
+
void Proj4Projection::geos()
{
userEnveloppe_->clear();
diff --git a/src/common/Proj4Projection.h b/src/common/Proj4Projection.h
index 9dedc59..0b82e39 100644
--- a/src/common/Proj4Projection.h
+++ b/src/common/Proj4Projection.h
@@ -199,7 +199,10 @@ public:
void conic();
void geos();
void simple();
+ void projectionSimple();
+
void add(double, double);
+
double patchDistance(double) const;
const string& name() const { return definition_; }
void getNewDefinition(const UserPoint&, const UserPoint&, string&) const;
@@ -260,6 +263,11 @@ class Proj4EPSG3857 : public Proj4Projection
public:
Proj4EPSG3857() : Proj4Projection("EPSG:3857") {}
};
+class Proj4EPSG900913 : public Proj4Projection
+{
+public:
+ Proj4EPSG900913() : Proj4Projection("EPSG:3857") {}
+};
class Proj4Geos : public Proj4Projection
{
public:
diff --git a/src/decoders/GeoPointsDecoder.cc b/src/decoders/GeoPointsDecoder.cc
index 2491efd..13c5a9b 100644
--- a/src/decoders/GeoPointsDecoder.cc
+++ b/src/decoders/GeoPointsDecoder.cc
@@ -89,6 +89,11 @@ void GeoPointsDecoder::yxdtlv2(const string& line, const Transformation& transfo
std::istringstream in(line);
double lat, lon, date, time, level, value;
in >> lat >> lon >> level >> date >> time >> value;
+ if ( useProj4_) {
+ int error = pj_transform(proj4_, latlon_, 1, 1, &lon, &lat, NULL);
+ lon *= RAD_TO_DEG;
+ lat *= RAD_TO_DEG;
+ }
UserPoint geo(lon, lat, value, value == missing_);
add(transformation, geo);
}
@@ -98,6 +103,13 @@ void GeoPointsDecoder::xyv2(const string& line, const Transformation& transforma
std::istringstream in(line);
double lat, lon, value;
in >> lon >> lat >> value;
+
+ if ( useProj4_) {
+ int error = pj_transform(proj4_, latlon_, 1, 1, &lon, &lat, NULL);
+ lon *= RAD_TO_DEG;
+ lat *= RAD_TO_DEG;
+ }
+
UserPoint geo(lon, lat, value, value == missing_);
add(transformation, geo);
@@ -107,6 +119,11 @@ void GeoPointsDecoder::lluv(const string& line, const Transformation& transforma
std::istringstream in(line);
double lat, lon, height, date, time, u, v;
in >> lat >> lon >> height >> date >> time >> u >> v;
+ if ( useProj4_) {
+ int error = pj_transform(proj4_, latlon_, 1, 1, &lon, &lat, NULL);
+ lon *= RAD_TO_DEG;
+ lat *= RAD_TO_DEG;
+ }
CustomisedPoint geo(lon, lat, "lluv");
geo["x_component"] = u;
geo["y_component"] = v;
@@ -121,6 +138,11 @@ void GeoPointsDecoder::polar(const string& line, const Transformation& transform
double lat, lon, height, date, time, speed, direction;
in >> lat >> lon >> height >> date >> time >> speed >> direction;
+ if ( useProj4_) {
+ int error = pj_transform(proj4_, latlon_, 1, 1, &lon, &lat, NULL);
+ lon *= RAD_TO_DEG;
+ lat *= RAD_TO_DEG;
+ }
CustomisedPoint geo(lon, lat, "polar");
if ( speed == missing_ || direction == missing_ )
@@ -142,7 +164,11 @@ void GeoPointsDecoder::yxdtlv1(const string& line)
std::istringstream in(line);
double lat, lon, date, time, level, value;
in >> lat >> lon >> level >> date >> time >> value;
-
+ if ( useProj4_) {
+ int error = pj_transform(proj4_, latlon_, 1, 1, &lon, &lat, NULL);
+ lon *= RAD_TO_DEG;
+ lat *= RAD_TO_DEG;
+ }
push_back(new UserPoint(lon, lat, value, value == missing_));
}
@@ -151,8 +177,14 @@ void GeoPointsDecoder::xyv1(const string& line)
std::istringstream in(line);
double lat, lon, value;
in >> lon >> lat >> value;
- push_back(new UserPoint(lon, lat, value, value == missing_));
+ if ( useProj4_) {
+ int error = pj_transform(proj4_, latlon_, 1, 1, &lon, &lat, NULL);
+ lon *= RAD_TO_DEG;
+ lat *= RAD_TO_DEG;
+ }
+
+ push_back(new UserPoint(lat, lon, value, value == missing_));
}
void GeoPointsDecoder::decode(const Transformation& transformation)
{
@@ -162,7 +194,7 @@ void GeoPointsDecoder::decode(const Transformation& transformation)
formats_["XY_VECTOR"] = &GeoPointsDecoder::lluv;
formats_["POLAR_VECTOR"] = &GeoPointsDecoder::polar;
}
-
+ useProj4_ = false;
GeoPointsDecoder::Decode method = &GeoPointsDecoder::yxdtlv2;
if ( !empty() ) return;
@@ -171,13 +203,21 @@ void GeoPointsDecoder::decode(const Transformation& transformation)
ifstream in(path_.c_str());
while( in.getline( line, sizeof(line) ) ) {
- if( strncmp( line, "#DATA", 5 ) == 0 )
+ if ( strncmp( line, "#DATA", 5 ) == 0 )
break;
- if( strncmp( line, "#FORMAT ", 8 ) == 0 ) {
+ if ( strncmp( line, "#PROJECTION ", 12 ) == 0 ) {
+ useProj4_ = true;
+ string proj4(line+12);
+
+ proj4_ = pj_init_plus(line+11);
+ latlon_ = pj_init_plus("+proj=longlat +ellps=WGS84 +datum=WGS84");
+ }
+ if ( strncmp( line, "#FORMAT ", 8 ) == 0 ) {
const char* fp = line+7;
while( fp && *fp == ' ' )
++fp;
string format(fp);
+
map<string, GeoPointsDecoder::Decode>::iterator m = formats_.find(format);
method = ( m != formats_.end() ) ? m->second : &GeoPointsDecoder::yxdtlv2;
}
@@ -231,6 +271,7 @@ void GeoPointsDecoder::decode()
while( in.getline( line, sizeof(line) ) ) {
if( strncmp( line, "#DATA", 5 ) == 0 )
break;
+
if( strncmp( line, "#FORMAT ", 8 ) == 0 ) {
const char* fp = line+7;
while( fp && *fp == ' ' )
diff --git a/src/decoders/GeoPointsDecoder.h b/src/decoders/GeoPointsDecoder.h
index c1710da..f06ce21 100644
--- a/src/decoders/GeoPointsDecoder.h
+++ b/src/decoders/GeoPointsDecoder.h
@@ -28,6 +28,7 @@
#include "Data.h"
#include "Decoder.h"
#include "UserPoint.h"
+#include <proj_api.h>
namespace magics {
@@ -87,6 +88,9 @@ protected:
std::map<string, Decode> formats_;
std::map<string, SimpleDecode> simple_formats_;
vector<CustomisedPoint*> customisedPoints_;
+ projPJ proj4_;
+ projPJ latlon_;
+ bool useProj4_;
private:
//! Copy constructor - No copy allowed
GeoPointsDecoder(const GeoPointsDecoder&);
diff --git a/src/decoders/GribDecoder.cc b/src/decoders/GribDecoder.cc
index c1d635d..0122f71 100644
--- a/src/decoders/GribDecoder.cc
+++ b/src/decoders/GribDecoder.cc
@@ -535,13 +535,17 @@ struct Compare
void GribDecoder::customisedPoints(const Transformation& transformation, CustomisedPointsList& out, double thinx, double thiny, double gap)
{
+
+
decode2D();
+
double minlon = 0.;
double maxlon = 360.;
double missing = getDouble("missingValue");
+
if ( thiny ) {
vector<pair<double, double> > positions;
@@ -574,6 +578,8 @@ void GribDecoder::customisedPoints(const Transformation& transformation, Customi
add->insert(make_pair("x_component", value.first));
add->insert(make_pair("y_component", value.second));
+ if (colourComponent_)
+ add->insert(make_pair("colour_component", (*colourComponent_)[w]));
// cout << " Point " << *add << endl;
out.push_back(add);
@@ -613,6 +619,8 @@ void GribDecoder::customisedPoints(const Transformation& transformation, Customi
CustomisedPoint *add = new CustomisedPoint(p->x(), p->y(), "");
add->insert(make_pair("x_component", value.first));
add->insert(make_pair("y_component", value.second));
+ if (colourComponent_)
+ add->insert(make_pair("colour_component", (*colourComponent_)[index]));
out.push_back(add);
}
}
@@ -2290,6 +2298,7 @@ public:
static map<long, string> names;
if ( names.empty() ){
names[54] = "METEOSAT-7";
+ names[55] = "METEOSAT-8";
names[57] = "METEOSAT-10";
names[172] = "MTSAT-2";
names[257] = "GOES-13";
@@ -2320,6 +2329,15 @@ public:
l54[2] = "IR 11-5";
l54[3] = "VIS 00-7";
channels[54] = l54;
+ map<long, string> l55;
+ l55[1] = "VIS 0-6";
+ l55[4] = "IR 3-9";
+ l55[5] = "WV 6-2";
+ l55[6] = "WV 7-3";
+ l55[8] = "IR 9-7";
+ l55[9] = "IR 10-8";
+ l55[10] = "IR 12-0";
+ channels[55] = l55;
map<long, string> l57;
l57[1] = "VIS 0-6";
l57[4] = "IR 3-9";
diff --git a/src/decoders/NetcdfDecoder.h b/src/decoders/NetcdfDecoder.h
index f603d54..c77e1d1 100644
--- a/src/decoders/NetcdfDecoder.h
+++ b/src/decoders/NetcdfDecoder.h
@@ -64,10 +64,17 @@ public:
void getReady(const Transformation& transformation)
{
+
(*interpretor_).getReady(transformation);
}
void visit(Transformation& transformation) {
+ if ( !transformation.getAutomaticX() && !transformation.getAutomaticY())
+ return;
+
+ if ( !data_ )
+ valid_ = (*interpretor_).interpretAsMatrix(&data_);
+ if ( valid_ )
(*interpretor_).visit(transformation);
}
diff --git a/src/decoders/NetcdfGeoMatrixInterpretor.cc b/src/decoders/NetcdfGeoMatrixInterpretor.cc
index 18f5f97..50a37d0 100644
--- a/src/decoders/NetcdfGeoMatrixInterpretor.cc
+++ b/src/decoders/NetcdfGeoMatrixInterpretor.cc
@@ -42,7 +42,6 @@ bool NetcdfGeoMatrixInterpretor::interpretAsMatrix(Matrix** data)
Netcdf netcdf(path_, dimension_method_);
-
string proj4 = netcdf.getAttribute("projection", "");
if ( proj4.empty() ) {
@@ -68,43 +67,100 @@ bool NetcdfGeoMatrixInterpretor::interpretAsMatrix(Matrix** data)
{
map<string, string> first, last;
setDimensions(dimension_, first, last);
+ vector<double> inlon, outlon;
+ vector<double> inlat, outlat;
+
netcdf.get(longitude_, matrix_->columnsAxis(), first, last);
netcdf.get(latitude_, matrix_->rowsAxis(), first, last);
+ /*
+ netcdf.get(longitude_, inlon, first, last);
+ netcdf.get(latitude_, inlat, first, last);
+ projPJ google_ = pj_init_plus("+proj=merc +lon_0=0 +k=1 +x_0=0 +y_0=0 +a=6378137 +b=6378137 +towgs84=0,0,0,0,0,0,0 +nadgrids=@null +units=m +no_defs");
+ proj4_ = pj_init_plus(proj4.c_str());
+ latlon_ = pj_init_plus("+proj=longlat +ellps=WGS84 +datum=WGS84");
+
+
+ //-20037508.34,-20037508.34,20037508.34,20037508.342361521.9885199675,4639307.212604788,3746560.9408545615,5923449.287616995
+//-20037508.34,-20037508.34,20037508.34,20037508.34
+ double minx = -20037508.34;
+ double maxx = 20037508.34;
+ double miny = -20037508.34;
+ double maxy = 20037508.34;
+ double minx = 0;
+ double maxx = 20037508.34;
+ double miny = -20037508.34;
+ double maxy = 0;
+
+ double stepx = (maxx-minx)/(inlon.size() - 1);
+ double stepy = (maxy-miny)/(inlat.size() - 1);
+
+ for (int i = 0; i < inlon.size(); i++)
+ matrix_->columnsAxis().push_back(minx + (i*stepx));
+ for (int i = 0; i < inlat.size(); i++)
+ matrix_->rowsAxis().push_back(miny + (i*stepy));
+ */
+
+
+
+
matrix_->missing(missing_value);
- if ( magCompare(primary_index_, "latitude") ) {
- // WE reserve the matrix_ since we are used to lat/lon matrix_!
+ if ( magCompare(primary_index_, "latitude") ) {
vector<double> data;
netcdf.get(field_, data, first, last);
int columns = matrix_->columnsAxis().size();
int rows = matrix_->rowsAxis().size();
-
- for (int lon = 0; lon < columns; lon++)
- for (int lat = 0; lat < rows; lat++) {
- matrix_->push_back(data[lon + lat*rows]);
+ for (int lat = 0; lat < rows; lat++) {
+ for (int lon = 0; lon < columns; lon++)
+ matrix_->push_back(data[lat + lon*rows]);
}
}
- else {
+ else {
vector<double> data;
netcdf.get(field_, data, first, last);
- int i = 0;
- for (vector<double>::iterator d = data.begin(); d != data.end(); ++d ) {
+/*
+ vector<double>::iterator lon = inlon.begin();
+ vector<double>::iterator lat = inlat.begin();
+*/
+ matrix_->reserve(data.size());
+ fill(matrix_->begin(), matrix_->end(), missing_value);
+ for (vector<double>::iterator d = data.begin(); d != data.end(); ++d )
+ {
+
+ /* double x = *lon;
+ double y = *lat;
+
+ //cout << "avant " << x << " " << y << endl;
+ pj_transform(proj4_, google_, 1, 1, &x, &y, NULL);
+ //cout << "apres " << x << " " << y << endl;
+
+ int i = (x-minx)/stepx;
+ int j = (y-miny)/stepy;
+ //cout << "index " << i << " " << j << endl;
+ int index = (j* inlon.size()) + i;
+ ++lon;
+ if ( lon == inlon.end() ) {
+ ++lat;
+ lon = inlon.begin();
+ }
+ if (index < 0 || index > data.size()) continue;
+ */
if ( !std::isnan(*d) ) {
matrix_->push_back(*d);
}
else
+ //(*matrix_)[index] = missing_value;
matrix_->push_back(missing_value);
- i++;
+
}
}
matrix_->multiply(scaling_);
matrix_->plus(offset_);
-
matrix_->setMapsAxis();
}
catch (MagicsException& e)
@@ -126,10 +182,44 @@ void NetcdfGeoMatrixInterpretor::print(ostream& out) const
out << "]";
}
+
+UserPoint* NetcdfGeoMatrixInterpretor::newPoint(const string& proj4, double lon, double lat, double val)
+{
+ double x = lon;
+ double y = lat;
+
+ if ( !proj4.empty() ) {
+ int error = pj_transform(proj4_, latlon_, 1, 1, &x, &y, NULL);
+ return new UserPoint(x * RAD_TO_DEG, y *RAD_TO_DEG, val);
+ }
+ else {
+ return new UserPoint(x, y, val);
+ }
+
+}
+
+void NetcdfGeoMatrixInterpretor::visit(Transformation& transformation) {
+
+ // Here are in a dump ode .. the coordinates are pixels.
+ if ( transformation.getAutomaticX() ) {
+ transformation.setMinMaxX(matrix_->columnsAxis().front(),matrix_->columnsAxis().back() );
+ }
+ if ( transformation.getAutomaticY() ) {
+ transformation.setMinMaxY(matrix_->rowsAxis().front(),matrix_->rowsAxis().back());
+ }
+
+}
+
+
bool NetcdfGeoMatrixInterpretor::interpretAsPoints(PointsList& list)
{
Netcdf netcdf(path_, dimension_method_);
-
+ string proj4 = netcdf.getAttribute("projection", "");
+
+ if ( !proj4.empty() ) {
+ proj4_ = pj_init_plus(proj4.c_str());
+ latlon_ = pj_init_plus("+proj=longlat +ellps=WGS84 +datum=WGS84");
+ }
// get the data ...
try
{
@@ -152,7 +242,7 @@ bool NetcdfGeoMatrixInterpretor::interpretAsPoints(PointsList& list)
if ( values[val] < suppress_below_ ) continue;
if ( values[val] > suppress_above_ ) continue;
if ( same(values[val], missing_value ) ) continue;
- list.push_back(new UserPoint(longitudes[lon], latitudes[lat], (values[val]*scaling_) + offset_));
+ list.push_back(newPoint(proj4, longitudes[lon], latitudes[lat], (values[val]*scaling_) + offset_));
}
}
MagLog::dev()<< "everything ok" << endl;
diff --git a/src/decoders/NetcdfGeoMatrixInterpretor.h b/src/decoders/NetcdfGeoMatrixInterpretor.h
index 0939e44..6637605 100644
--- a/src/decoders/NetcdfGeoMatrixInterpretor.h
+++ b/src/decoders/NetcdfGeoMatrixInterpretor.h
@@ -28,7 +28,7 @@
#include "NetcdfInterpretor.h"
#include "Matrix.h"
#include "XmlNode.h"
-
+#include <proj_api.h>
namespace magics {
@@ -43,6 +43,9 @@ public:
NetcdfInterpretorAttributes::set(params);
NetcdfGeoMatrixInterpretorAttributes::set(params);
}
+
+ void visit(Transformation& transformation);
+
void set(const XmlNode& node) {
MagLog::debug() << "NetcdfGeoMatrixInterpretor::set(params)" << "\n";
NetcdfInterpretorAttributes::set(node);
@@ -62,16 +65,18 @@ public:
}
bool interpretAsMatrix(Matrix**);
bool interpretAsPoints(PointsList&);
-
+ UserPoint* newPoint(const string&, double, double, double);
virtual void statsData(map<string,vector<double> >&);
virtual void visit(MetaDataCollector&);
virtual void visit(ValuesCollector&,PointsList&);
void customisedPoints(const Transformation&, const std::set<string>&, CustomisedPointsList&, int);
protected:
//! Method to print string about this class on to a stream of type ostream (virtual).
- virtual void print(ostream&) const;
- Matrix* matrix_;
-
+ virtual void print(ostream&) const;
+ Matrix* matrix_;
+ projPJ proj4_;
+ projPJ latlon_;
+
private:
//! Copy constructor - No copy allowed
NetcdfGeoMatrixInterpretor(const NetcdfGeoMatrixInterpretor&);
diff --git a/src/decoders/NetcdfGeopointsInterpretor.h b/src/decoders/NetcdfGeopointsInterpretor.h
index b169e7e..187f486 100644
--- a/src/decoders/NetcdfGeopointsInterpretor.h
+++ b/src/decoders/NetcdfGeopointsInterpretor.h
@@ -61,7 +61,7 @@ public:
}
bool interpretAsPoints(PointsList&);
bool interpretAsPoints(PointsList&, const Transformation&);
- bool interpretAsMatrix(Matrix**) { throw MagicsException("Not Yet"); }
+ bool interpretAsMatrix(Matrix**) { return false; }
virtual void visit(MetaDataCollector&);
virtual void visit(ValuesCollector&,PointsList&);
@@ -113,7 +113,7 @@ public:
bool interpretAsPoints(PointsList&, const std::set<string>&);
bool interpretAsPoints(PointsList&);
bool interpretAsPoints(PointsList&, const Transformation&);
- bool interpretAsMatrix(Matrix**) { throw MagicsException("Not Yet"); }
+ bool interpretAsMatrix(Matrix**) { return false; }
virtual void visit(Transformation&);
virtual void customisedPoints(const Transformation&, const std::set<string>&, CustomisedPointsList&, int s);
virtual void visit(MetaDataCollector&);
diff --git a/src/drivers/QtDriver.cc b/src/drivers/QtDriver.cc
index 659878c..10de87a 100644
--- a/src/drivers/QtDriver.cc
+++ b/src/drivers/QtDriver.cc
@@ -2428,6 +2428,7 @@ QColor QtDriver::getQtColour(const Colour &col) const
qreal r=col.red();
qreal g=col.green();
qreal b=col.blue();
+ qreal alpha=col.alpha();
if(r < 0.) r=0.;
else if(r > 1.) r=1.;
@@ -2437,8 +2438,11 @@ QColor QtDriver::getQtColour(const Colour &col) const
if(b < 0.) b=0.;
else if(b > 1.) b=1.;
-
- return QColor::fromRgbF(r,g,b);
+
+ if(alpha < 0.) alpha=0.;
+ else if(alpha > 1.) alpha=1.;
+
+ return QColor::fromRgbF(r,g,b,alpha);
}
static SimpleObjectMaker<QtDriver, BaseDriver> Qt_driver("Qt");
diff --git a/src/params/CMakeLists.txt b/src/params/CMakeLists.txt
index a5661bf..fb88d36 100644
--- a/src/params/CMakeLists.txt
+++ b/src/params/CMakeLists.txt
@@ -13,6 +13,7 @@ BinningObject.xml
BothValuePlotMethod.xml
Boundaries.xml
CalculateColourTechnique.xml
+GradientsColourTechnique.xml
CalculateHeightTechnique.xml
CalmIndicator.xml
CartesianTransformation.xml
@@ -141,6 +142,7 @@ Proj4Collignon.xml
Proj4EPSG32661.xml
Proj4EPSG4326.xml
Proj4EPSG3857.xml
+Proj4EPSG900913.xml
Proj4Geos.xml
Proj4Goode.xml
Proj4Lambert.xml
diff --git a/src/params/FortranViewNode.xml b/src/params/FortranViewNode.xml
index 23ff56b..fc627ca 100644
--- a/src/params/FortranViewNode.xml
+++ b/src/params/FortranViewNode.xml
@@ -47,6 +47,7 @@ does it submit to any jurisdiction.
<option fortran="goes_east" include="Proj4Projection.h" name="Proj4Geose"> </option>
<option fortran="lambert" include="Proj4Projection.h" name="Proj4Lambert"> </option>
<option fortran="EPSG:3857" include="Proj4Projection.h" name="Proj4EPSG3857"> </option>
+ <option fortran="EPSG:900913" include="Proj4Projection.h" name="Proj4EPSG900913"> </option>
<option fortran="EPSG:4326" include="Proj4Projection.h" name="Proj4EPSG4326"> </option>
<option fortran="goode" include="Proj4Projection.h" name="Proj4Goode"> </option>
<option fortran="collignon" include="Proj4Projection.h" name="Proj4Collignon"> </option>
diff --git a/src/params/GradientsColourTechnique.xml b/src/params/GradientsColourTechnique.xml
new file mode 100644
index 0000000..7e6011e
--- /dev/null
+++ b/src/params/GradientsColourTechnique.xml
@@ -0,0 +1,42 @@
+<magics>
+<class inherits="ColourTechnique" name="GradientsColourTechnique" directory="visualisers" action="pcont">
+<!--
+(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.
+-->
+
+
+ <parameter member="colours" to="stringarray" default="stringarray()" from="stringarray" name="contour_gradients_colour_list">
+ <documentation> Colour used at the stops : the gradeint will be calculated between 2 consecutive ones. </documentation>
+
+ </parameter>
+
+ <parameter member="stops" to="floatarray" default="floatarray()" from="floatarray" name="contour_gradients_waypoint_list">
+ <documentation> List of waypoints. </documentation>
+
+ </parameter>
+ <parameter member="stop_method" to="string" default="both" from="string" name="contour_gradients_waypoint_method" values='both/ignore/left/right'>
+ <documentation> waypoints at the left, right, middle of the interval. </documentation>
+
+ </parameter>
+
+ <parameter member="technique" to="string" default="linear" from="string" name="contour_gradients_technique" values='linear/hcl/hsl'>
+ <documentation> Technique to apply to compute the gradients linear-clockwise/linear-anticlockwise </documentation>
+
+ </parameter>
+ <parameter member="technique_direction" to="string" default="clockwise" from="string" name="contour_gradients_technique_direction" values='clockwise/anti_clockwise/shortest/longest'>
+ <documentation> Technique to apply to compute the gradients linear-clockwise/linear-anticlockwise </documentation>
+
+ </parameter>
+
+ <parameter member="steps" to="intarray" default="intarray()" from="intarray" name="contour_gradients_step_list">
+ <documentation> Number of steps to compute for each interval </documentation>
+
+ </parameter>
+
+</class></magics>
diff --git a/src/params/IsoShading.xml b/src/params/IsoShading.xml
index 413399e..4d21be6 100644
--- a/src/params/IsoShading.xml
+++ b/src/params/IsoShading.xml
@@ -36,10 +36,11 @@ does it submit to any jurisdiction.
<release>0.2 </release>
</parameter>
- <parameter member="colourMethod" to="ColourTechnique" default="calculate" from="string" name="contour_shade_colour_method">
- <documentation> Method of generating the colours of the bands in contour shading (LIST/CALCULATE) </documentation>
+ <parameter member="colourMethod" to="ColourTechnique" default="calculate" from="string" name="contour_shade_colour_method" >
+ <documentation> Method of generating the colours of the bands in contour shading (list/calculate/advanced) </documentation>
<option xml="calculate" fortran="calculate" include="CalculateColourTechnique.h" name="CalculateColourTechnique"> </option>
<option xml="list" fortran="list" include="ListColourTechnique.h" name="ListColourTechnique"> </option>
+ <option xml="gradients" fortran="gradients" include="GradientsColourTechnique.h" name="GradientsColourTechnique"> </option>
</parameter>
<metview_parameter from="string" name="contour_shade_label_blanking" default="on" metview="hidden" member="" to="bool">
diff --git a/src/params/LegendVisitor.xml b/src/params/LegendVisitor.xml
index 4787651..a59297a 100644
--- a/src/params/LegendVisitor.xml
+++ b/src/params/LegendVisitor.xml
@@ -143,6 +143,10 @@ does it submit to any jurisdiction.
<set name="legend_user_lines" value="user_text_only"> </set>
<set name="legend_user_lines" value="both"> </set>
</parameter>
+
+ <parameter from="floatarray" name="legend_values_list" visible="on" default="floatarray()" member="values_list" to="floatarray">
+ <documentation> List of values to show in the legend </documentation>
+ </parameter>
<parameter from="string" name="legend_user_text" visible="off" default="" member="text" to="string">
<documentation> User text to be associated with a legend sub-entry from a multiple entry </documentation>
diff --git a/src/params/Proj4EPSG900913.xml b/src/params/Proj4EPSG900913.xml
new file mode 100644
index 0000000..a0217a8
--- /dev/null
+++ b/src/params/Proj4EPSG900913.xml
@@ -0,0 +1,12 @@
+<!--
+(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.
+-->
+
+<magics>
+<class inherits="Proj4Projection" directory="common" prefix="subpage" include="Proj4Projection.h" name="Proj4EPSG900913"/></magics>
diff --git a/src/params/Proj4Projection.xml b/src/params/Proj4Projection.xml
index e00a9b0..13d2516 100644
--- a/src/params/Proj4Projection.xml
+++ b/src/params/Proj4Projection.xml
@@ -50,4 +50,7 @@ does it submit to any jurisdiction.
<parameter from="string" name="subpage_map_proj4_definition" visible="no" default="" member="proj4_definition" to="string">
<documentation> Proj4 defintion string : to be used very carefully --> possible side effect </documentation>
</parameter>
+ <parameter from="string" name="subpage_coordinates_system" visible="no" default="latlon" member="coordinates_system" to="string">
+ <documentation> Proj4 defintion string : to be used very carefully --> possible side effect </documentation>
+ </parameter>
</class></magics>
diff --git a/src/visualisers/Bar.cc b/src/visualisers/Bar.cc
index 2307c69..0db3f52 100644
--- a/src/visualisers/Bar.cc
+++ b/src/visualisers/Bar.cc
@@ -368,7 +368,7 @@ void Bar::visit(LegendVisitor& legend)
curve->setFilled(true);
shade_->legend(*curve);
LegendEntry * entry = new BoxEntry(legend_text_, curve);
- entry->userText(legend_text_);
+ entry->userText(legend_text_, "user");
legend.add(entry);
}
else if ( magCompare(bar_style_, "linebar") ) {
@@ -379,7 +379,7 @@ void Bar::visit(LegendVisitor& legend)
curve->setFilled(true);
shade_->legend(*curve);
LegendEntry * entry = new LineEntry(legend_text_, curve);
- entry->userText(legend_text_);
+ entry->userText(legend_text_, "user");
legend.add(entry);
}
}
diff --git a/src/visualisers/CMakeLists.txt b/src/visualisers/CMakeLists.txt
index cbd1d18..4d657ae 100644
--- a/src/visualisers/CMakeLists.txt
+++ b/src/visualisers/CMakeLists.txt
@@ -29,6 +29,8 @@ BoxPlotVisualiser.cc
BoxPlotVisualiser.h
CalculateColourTechnique.cc
CalculateColourTechnique.h
+GradientsColourTechnique.cc
+GradientsColourTechnique.h
CalcStreamlines.cc
CalcStreamlines.h
CalmIndicator.h
diff --git a/src/visualisers/CalculateColourTechnique.cc b/src/visualisers/CalculateColourTechnique.cc
index c1de945..3b63a7f 100644
--- a/src/visualisers/CalculateColourTechnique.cc
+++ b/src/visualisers/CalculateColourTechnique.cc
@@ -29,12 +29,11 @@ CalculateColourTechnique::CalculateColourTechnique()
{
}
-
CalculateColourTechnique::~CalculateColourTechnique()
{
}
-void CalculateColourTechnique::set(ColourTable& table, int nb) const
+void CalculateColourTechnique::set(LevelSelection&, LevelSelection&, ColourTable& table, int nb) const
{
ColourTableDefinitionCompute helper;
helper.set(*this);
diff --git a/src/visualisers/CalculateColourTechnique.h b/src/visualisers/CalculateColourTechnique.h
index 2ff53bc..3ef6a41 100644
--- a/src/visualisers/CalculateColourTechnique.h
+++ b/src/visualisers/CalculateColourTechnique.h
@@ -55,7 +55,7 @@ public:
const string& getDirection() const { return direction_; }
protected:
- void set(ColourTable&, int) const;
+ void set(LevelSelection&, LevelSelection&, ColourTable&, int) const;
//! Method to print string about this class on to a stream of type ostream (virtual).
virtual void print(ostream&) const;
diff --git a/src/visualisers/CellShading.cc b/src/visualisers/CellShading.cc
index 1ff9c5c..8d6ead5 100644
--- a/src/visualisers/CellShading.cc
+++ b/src/visualisers/CellShading.cc
@@ -203,7 +203,7 @@ void DumpShading::operator()( IsoPlot*,MatrixHandler& data, BasicGraphicsObjectC
parent.push_back(image);
}
-bool CellShading::prepare(const LevelSelection& levels, const ColourTechnique& technique)
+bool CellShading::prepare(LevelSelection& levels, const ColourTechnique& technique)
{
// First Interval ...
map_.clear();
diff --git a/src/visualisers/CellShading.h b/src/visualisers/CellShading.h
index bdca80b..32d21b3 100644
--- a/src/visualisers/CellShading.h
+++ b/src/visualisers/CellShading.h
@@ -59,7 +59,7 @@ public:
bool hasLegend() { return true; } // Isolien legend is not needed!
virtual void operator()(IsoPlot*, MatrixHandler&, BasicGraphicsObjectContainer&);
- virtual bool prepare(const LevelSelection&, const ColourTechnique&);
+ virtual bool prepare(LevelSelection&, const ColourTechnique&);
virtual void colour(double, Colour&);
CellArray* array(MatrixHandler& matrix, IntervalMap<int>& range,
const Transformation& transformation, int width, int height,
diff --git a/src/visualisers/ColourTechnique.cc b/src/visualisers/ColourTechnique.cc
index ff57140..0727c53 100644
--- a/src/visualisers/ColourTechnique.cc
+++ b/src/visualisers/ColourTechnique.cc
@@ -47,16 +47,16 @@ void ColourTechnique::print(ostream& out) const
out << "]";
}
-void ColourTechnique::prepare(const LevelSelection& levels, bool rainbow)
+void ColourTechnique::prepare(LevelSelection& out, LevelSelection& levels, bool rainbow)
{
if (levels.empty() ) return;
clear();
bands_.clear();
ColourTable table;
if ( rainbow )
- set(table, levels.size()+1);
+ set(out, levels, table, levels.size()+1);
else
- set(table, levels.size());
+ set(out, levels, table, levels.size());
if ( table.empty()) table.push_back(Colour("none"));
ColourTable::ColourIterator colour = table.begin();
@@ -83,7 +83,7 @@ void ColourTechnique::prepare(const LevelSelection& levels, bool rainbow)
if ( min != std::numeric_limits<double>::max() ) {
bands_.insert(make_pair(Interval(min, *val), left));
- MagLog::dev() << min << "<<" << left << "<<" << *val << endl;
+
}
min = *val;
left = right;
diff --git a/src/visualisers/ColourTechnique.h b/src/visualisers/ColourTechnique.h
index 1cd3b82..a849b58 100644
--- a/src/visualisers/ColourTechnique.h
+++ b/src/visualisers/ColourTechnique.h
@@ -79,8 +79,8 @@ public:
double leftRange(double) const;
double rightRange(double) const;
- virtual void set(ColourTable&, int) const {}
- void prepare(const LevelSelection&, bool rainbow = false);
+ virtual void set(LevelSelection&, LevelSelection&, ColourTable&, int) const {}
+ void prepare(LevelSelection&, LevelSelection&, bool rainbow = false);
void colours(vector<string>&) const;
diff --git a/src/visualisers/Curve.cc b/src/visualisers/Curve.cc
index a8a798c..8c6ea11 100644
--- a/src/visualisers/Curve.cc
+++ b/src/visualisers/Curve.cc
@@ -380,7 +380,7 @@ void Curve::visit(LegendVisitor& legend)
{
if ( !legend_) return;
CurveEntry* entry = new CurveEntry(legend_text_, *this);
- entry->userText(legend_text_);
+ entry->userText(legend_text_, "user");
legend.add(entry);
}
diff --git a/src/visualisers/DotPolyShadingMethod.h b/src/visualisers/DotPolyShadingMethod.h
index 5ac45b9..f7b9537 100644
--- a/src/visualisers/DotPolyShadingMethod.h
+++ b/src/visualisers/DotPolyShadingMethod.h
@@ -49,7 +49,7 @@ public:
return object;
}
- virtual void prepare(const LevelSelection& levels, const ColourTechnique& colours);
+ virtual void prepare(LevelSelection& levels, const ColourTechnique& colours);
virtual void operator()(Polyline& poly) const;
diff --git a/src/visualisers/EpsGraph.cc b/src/visualisers/EpsGraph.cc
index 3b226b7..d11c9a7 100644
--- a/src/visualisers/EpsGraph.cc
+++ b/src/visualisers/EpsGraph.cc
@@ -1401,9 +1401,9 @@ void EpsWind::operator()(Data& data, BasicGraphicsObjectContainer& visitor)
map<string, float> directions;
if ( magCompare(convention_, "oceanographic" ) ) {
directions["east"] = 0 + 3.14;
- directions["nord"] = 3.14 * 0.5 +3.14;
- directions["nord_east"] = 3.14*0.25 +3.14;
- directions["nord_west"] = 3.14*0.75 +3.14;
+ directions["north"] = 3.14 * 0.5 +3.14;
+ directions["north_east"] = 3.14*0.25 +3.14;
+ directions["north_west"] = 3.14*0.75 +3.14;
directions["south"] = 3.14*1.5 +3.14;
directions["south_east"] = 3.14*1.75 +3.14;
directions["south_west"] = 3.14*1.25 +3.14;
@@ -1411,9 +1411,9 @@ void EpsWind::operator()(Data& data, BasicGraphicsObjectContainer& visitor)
}
else {
directions["east"] = 0;
- directions["nord"] = 3.14 * 0.5;
- directions["nord_east"] = 3.14*0.25;
- directions["nord_west"] = 3.14*0.75;
+ directions["north"] = 3.14 * 0.5;
+ directions["north_east"] = 3.14*0.25;
+ directions["north_west"] = 3.14*0.75;
directions["south"] = 3.14*1.5;
directions["south_east"] = 3.14*1.75;
directions["south_west"] = 3.14*1.25;
@@ -1753,9 +1753,9 @@ void EpsWave::operator()(Data& data, BasicGraphicsObjectContainer& visitor)
map<string, float> directions;
directions["east"] = 0 + 3.14;
- directions["nord"] = 3.14 * 0.5 +3.14;
- directions["nord_east"] = 3.14*0.25 +3.14;
- directions["nord_west"] = 3.14*0.75 +3.14;
+ directions["north"] = 3.14 * 0.5 +3.14;
+ directions["north_east"] = 3.14*0.25 +3.14;
+ directions["north_west"] = 3.14*0.75 +3.14;
directions["south"] = 3.14*1.5 +3.14;
directions["south_east"] = 3.14*1.75 +3.14;
directions["south_west"] = 3.14*1.25 +3.14;
diff --git a/src/visualisers/GradientsColourTechnique.cc b/src/visualisers/GradientsColourTechnique.cc
new file mode 100644
index 0000000..4fe5635
--- /dev/null
+++ b/src/visualisers/GradientsColourTechnique.cc
@@ -0,0 +1,177 @@
+/*
+ * (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.
+ */
+
+/*! \file GradientsColourTechnique.cc
+ \brief Implementation of the Template class GradientsColourTechnique.
+
+ Magics Team - ECMWF 2004
+
+ Started: Wed 18-Aug-2004
+
+ Changes:
+
+*/
+
+#include "GradientsColourTechnique.h"
+#include "LevelSelection.h"
+#include "ColourTableDefinitionCompute.h"
+
+using namespace magics;
+
+GradientsColourTechnique::GradientsColourTechnique()
+{
+
+}
+
+
+GradientsColourTechnique::~GradientsColourTechnique()
+{
+}
+
+void GradientsColourTechnique::set(LevelSelection& out, LevelSelection& in, ColourTable& table, int nb) const
+{
+ // First make sure that
+ ColourTableDefinitionCompute helper;
+
+
+ vector<double>::const_iterator val = stops_.begin();
+ vector<int>::const_iterator step = steps_.begin();
+
+
+ if ( colours_.empty() ) {
+ MagLog::warning() << " No colours given to the gradients method" << endl;
+ return;
+ }
+ if ( stops_.empty() ) {
+ MagLog::warning() << " No intervals given to the gradients method" << endl;
+ return;
+ }
+
+ out.clear();
+ in.clear();
+
+ //ColourTable colours;
+ int last = colours_.size() -1;
+ for ( int col = 1; col < colours_.size(); ++col) {
+ string left = colours_[col-1];
+ string right = colours_[col];
+ int istep = ( steps_.empty() ) ? 10 : *step;
+
+ // right
+ ColourTableDefinitionCompute helper(left, right, technique_, technique_direction_);
+
+ int nb;
+ if ( stop_method_ == "right")
+ nb = (col == 1 ) ? istep + 1 : istep + 2;
+ else if ( stop_method_ == "left" )
+ nb = (col == last ) ? istep + 1 : istep + 2;
+ else if ( stop_method_ == "ignore" )
+ nb = (col == 1 || col == last ) ? istep + 2 : istep + 3;
+ else if ( stop_method_ == "both" )
+ nb = istep+1;
+
+ helper.set(table, nb);
+
+ // Next block
+ if ( !steps_.empty() && step != steps_.end() )
+ ++step;
+
+ }
+
+
+ step = steps_.begin();
+ int col = 0;
+
+ // Now the interval ...
+ for (int stop = 1; stop < stops_.size(); ++stop) {
+ double from = stops_[stop-1];
+ double to = stops_[stop];
+ int istep = ( steps_.empty() ) ? 10 : *step;
+ if ( stop_method_ == "ignore") {
+
+ in.push_back(from);
+ out.push_back(from);
+ if ( stop != 1) {
+ in.push_back(from);
+ out.push_back(from);
+ }
+ }
+ if ( stop_method_ == "right") {
+
+ in.push_back(from);
+ out.push_back(from);
+ }
+ if ( stop_method_ == "left") {
+
+ in.push_back(from);
+ out.push_back(from);
+ }
+ if ( stop_method_ == "both") {
+
+ in.push_back(from);
+ out.push_back(from);
+ }
+ nb = istep;
+ double inc = (to - from )/(nb);
+ for (int i = 1; i < nb; i++) {
+ in.push_back(from +(i*inc));
+ out.push_back(from +(i*inc));
+
+
+ }
+ if ( stop_method_ == "ignore") {
+ in.push_back(to);
+ out.push_back(to);
+
+ }
+ if ( stop_method_ == "right") {
+ in.push_back(to);
+ out.push_back(to);
+
+ }
+ if ( stop_method_ == "left") {
+
+ in.push_back(to);
+ out.push_back(to);
+ }
+ if ( stop_method_ == "both" && stop == stops_.size()-1) {
+ in.push_back(to);
+ out.push_back(to);
+
+ }
+
+ if ( !steps_.empty() && step != steps_.end() )
+ ++step;
+ }
+
+
+
+
+
+ // now we compute the new levels list :
+
+
+
+}
+
+/*!
+ Class information are given to the output-stream.
+*/
+void GradientsColourTechnique::print(ostream& out) const
+{
+ out << "GradientsColourTechnique[";
+ out << "]";
+}
+
+void GradientsColourTechnique::set(const ColourTechniqueInterface& attributes)
+{
+
+}
+
diff --git a/src/visualisers/CalculateColourTechnique.h b/src/visualisers/GradientsColourTechnique.h
similarity index 55%
copy from src/visualisers/CalculateColourTechnique.h
copy to src/visualisers/GradientsColourTechnique.h
index 2ff53bc..e1f562b 100644
--- a/src/visualisers/CalculateColourTechnique.h
+++ b/src/visualisers/GradientsColourTechnique.h
@@ -8,8 +8,8 @@
* does it submit to any jurisdiction.
*/
-/*! \file CalculateColourTechnique.h
- \brief Definition of the Template class CalculateColourTechnique.
+/*! \file GradientsColourTechnique.h
+ \brief Definition of the Template class GradientsColourTechnique.
Magics Team - ECMWF 2004
@@ -19,55 +19,52 @@
*/
-#ifndef CalculateColourTechnique_H
-#define CalculateColourTechnique_H
+#ifndef GradientsColourTechnique_H
+#define GradientsColourTechnique_H
#include "magics.h"
#include "ColourTechnique.h"
-#include "CalculateColourTechniqueAttributes.h"
+#include "GradientsColourTechniqueAttributes.h"
namespace magics {
-class CalculateColourTechnique: public ColourTechnique, public CalculateColourTechniqueAttributes {
+class GradientsColourTechnique: public ColourTechnique, public GradientsColourTechniqueAttributes {
public:
- CalculateColourTechnique();
- virtual ~CalculateColourTechnique();
+ GradientsColourTechnique();
+ virtual ~GradientsColourTechnique();
void set(const map<string, string>& map) {
- CalculateColourTechniqueAttributes::set(map);
+ GradientsColourTechniqueAttributes::set(map);
}
void set(const XmlNode& node) {
- CalculateColourTechniqueAttributes::set(node);
+ GradientsColourTechniqueAttributes::set(node);
}
- bool accept(const string& node) { return CalculateColourTechniqueAttributes::accept(node); }
+ bool accept(const string& node) { return GradientsColourTechniqueAttributes::accept(node); }
void set(const ColourTechniqueInterface&);
virtual ColourTechnique* clone() const {
- CalculateColourTechnique* object = new CalculateColourTechnique();
+ GradientsColourTechnique* object = new GradientsColourTechnique();
object->copy(*this);
return object;
}
- const Colour& getMax() const { return *max_; }
- const Colour& getMin() const { return *min_; }
- const string& getDirection() const { return direction_; }
-
+
protected:
- void set(ColourTable&, int) const;
+ void set(LevelSelection&, LevelSelection&, ColourTable&, int) const;
//! Method to print string about this class on to a stream of type ostream (virtual).
virtual void print(ostream&) const;
private:
//! Copy constructor - No copy allowed
- CalculateColourTechnique(const CalculateColourTechnique&);
+ GradientsColourTechnique(const GradientsColourTechnique&);
//! Overloaded << operator to copy - No copy allowed
- CalculateColourTechnique& operator=(const CalculateColourTechnique&);
+ GradientsColourTechnique& operator=(const GradientsColourTechnique&);
// -- Friends
//! Overloaded << operator to call print().
- friend ostream& operator<<(ostream& s,const CalculateColourTechnique& p)
+ friend ostream& operator<<(ostream& s,const GradientsColourTechnique& p)
{ p.print(s); return s; }
};
diff --git a/src/visualisers/GridPlotting.cc b/src/visualisers/GridPlotting.cc
index 3b326ae..61c7fc5 100644
--- a/src/visualisers/GridPlotting.cc
+++ b/src/visualisers/GridPlotting.cc
@@ -121,10 +121,10 @@ const vector<double>& NoGridPlotting::latitudes(const Transformation& transforma
if(latitudes_.empty())
{
for(double lat = latReference_; lat > min; lat -=latIncrement_)
- {
+ {/*
if ( lat < -90 )
latitudes_.push_back(180. - lat);
- else
+ else */
latitudes_.push_back(lat);
}
for(double lat = latReference_ + latIncrement_; lat < max; lat += latIncrement_)
diff --git a/src/visualisers/HatchPolyShadingMethod.h b/src/visualisers/HatchPolyShadingMethod.h
index 3f48fbc..9f67a2b 100644
--- a/src/visualisers/HatchPolyShadingMethod.h
+++ b/src/visualisers/HatchPolyShadingMethod.h
@@ -48,7 +48,7 @@ public:
return object;
}
- virtual void prepare(const LevelSelection& levels, const ColourTechnique&);
+ virtual void prepare(LevelSelection& levels, const ColourTechnique&);
virtual void operator()(Polyline& poly) const;
protected:
diff --git a/src/visualisers/IsoHighlight.h b/src/visualisers/IsoHighlight.h
index 98845ce..07d8371 100644
--- a/src/visualisers/IsoHighlight.h
+++ b/src/visualisers/IsoHighlight.h
@@ -46,7 +46,7 @@ public:
virtual void toxml(ostream&, int = 0) const {}
virtual bool accept(const string&) { return true;}
- virtual void prepare(const LevelSelection&) {}
+ virtual void prepare(LevelSelection&) {}
virtual void visit(Polyline*& ) {
}
@@ -90,7 +90,7 @@ public:
line->setThickness(this->thickness_);
}
- virtual void prepare(const LevelSelection& levels)
+ virtual void prepare(LevelSelection& levels)
{
vector<double> todo;
clear();
diff --git a/src/visualisers/IsoLabel.h b/src/visualisers/IsoLabel.h
index 91126bf..0434c86 100644
--- a/src/visualisers/IsoLabel.h
+++ b/src/visualisers/IsoLabel.h
@@ -45,8 +45,8 @@ public:
return object;
}
virtual void operator()(Polyline&, double) const;
- virtual void prepare(const LevelSelection&) {}
- virtual void prepare(const LevelSelection&, const string&) { }
+ virtual void prepare(LevelSelection&) {}
+ virtual void prepare(LevelSelection&, const string&) { }
virtual bool label() { return false; }
protected:
@@ -76,7 +76,7 @@ public:
virtual bool accept(const string& verb) { return IsoLabelAttributes::accept(verb); }
virtual void operator()(Polyline&, double) const;
virtual bool label() { return true; }
- virtual void prepare(const LevelSelection& levels, const string& colour)
+ virtual void prepare(LevelSelection& levels, const string& colour)
{
// int label = 0;
diff --git a/src/visualisers/IsoPlot.cc b/src/visualisers/IsoPlot.cc
index f80ca9e..08f8fc1 100644
--- a/src/visualisers/IsoPlot.cc
+++ b/src/visualisers/IsoPlot.cc
@@ -1338,8 +1338,9 @@ void IsoPlot::isoline(MatrixHandler& data, BasicGraphicsObjectContainer& parent)
double max = data.max();
(*levelSelection_).clear();
(*levelSelection_).calculate(min , max , true);
- (*label_).prepare(*levelSelection_, (*colour_).name());
- return (*shading_)(*levelSelection_);
+ bool need_isolines = (*shading_)(*levelSelection_);
+ (*label_).prepare(*levelSelection_, (*colour_).name());
+ return need_isolines;
}
@@ -1353,7 +1354,7 @@ void IsoPlot::isoline(MatrixHandler& data, BasicGraphicsObjectContainer& parent)
if ( legend_only_ ) {
if ( rainbow_ ) {
rainbowMethod_->set(*this);
- rainbowMethod_->prepare(*levelSelection_, true);
+ rainbowMethod_->prepare(*levelSelection_, *levelSelection_, true);
setThicknessAndStyle();
}
return;
@@ -1378,7 +1379,7 @@ void IsoPlot::isoline(MatrixHandler& data, BasicGraphicsObjectContainer& parent)
if ( rainbow_ ) {
rainbowMethod_->set(*this);
- rainbowMethod_->prepare(*levelSelection_, true);
+ rainbowMethod_->prepare(*levelSelection_, *levelSelection_, true);
setThicknessAndStyle();
}
diff --git a/src/visualisers/IsoShading.h b/src/visualisers/IsoShading.h
index 2fe0302..c6bdf0f 100644
--- a/src/visualisers/IsoShading.h
+++ b/src/visualisers/IsoShading.h
@@ -67,7 +67,7 @@ public:
virtual int rightIndex (double ) { return -1; }
virtual double leftRange(double) { return 0; }
virtual double rightRange(double) { return 0; }
- virtual bool operator()(const LevelSelection&) { return false; }
+ virtual bool operator()(LevelSelection&) { return false; }
virtual void visit(LegendVisitor&) {}
virtual void operator()(Polyline*) const {}
virtual void colour(double, Colour&) {};
@@ -119,15 +119,21 @@ public:
virtual int rightIndex(double);
virtual bool needClipping() { return (*this->technique_).needClipping(); }
- virtual bool operator()(const LevelSelection& list)
+ virtual bool operator()(LevelSelection& list)
{
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(filter);
+
+
+ (*this->colourMethod_).prepare(list, filter);
+
+
if ( !filter.empty() && ( filter.back() == filter.front() ) )
filter.push_back(filter.front());
+
+
return (*this->technique_).prepare(filter, *this->colourMethod_);
}
// returns true, if the contouring lines have to be created... False, is the shading is finished...
diff --git a/src/visualisers/ListColourTechnique.cc b/src/visualisers/ListColourTechnique.cc
index 680886c..7a1e8ee 100644
--- a/src/visualisers/ListColourTechnique.cc
+++ b/src/visualisers/ListColourTechnique.cc
@@ -31,7 +31,7 @@ ListColourTechnique::ListColourTechnique()
}
-void ListColourTechnique::set(ColourTable& table, int nb) const
+void ListColourTechnique::set(LevelSelection&, LevelSelection&, ColourTable& table, int nb) const
{
ColourTableDefinitionList helper;
//policy = table.getPolicy();
diff --git a/src/visualisers/ListColourTechnique.h b/src/visualisers/ListColourTechnique.h
index 2d33d2a..7267161 100644
--- a/src/visualisers/ListColourTechnique.h
+++ b/src/visualisers/ListColourTechnique.h
@@ -47,7 +47,7 @@ public:
return object;
}
- virtual void set(ColourTable&, int) const;
+ virtual void set(LevelSelection&, LevelSelection&, ColourTable&, int) const;
void set(const ColourTechniqueInterface&);
stringarray getValues() const { return values_; }
diff --git a/src/visualisers/MarkerShadingTechnique.cc b/src/visualisers/MarkerShadingTechnique.cc
index 8d203d8..6123017 100644
--- a/src/visualisers/MarkerShadingTechnique.cc
+++ b/src/visualisers/MarkerShadingTechnique.cc
@@ -103,7 +103,7 @@ CellArray* MarkerShadingTechnique::array(MatrixHandler& matrix, IntervalMap<int>
}
-bool MarkerShadingTechnique::prepare(const LevelSelection& levels, const ColourTechnique& technique)
+bool MarkerShadingTechnique::prepare(LevelSelection& levels, const ColourTechnique& technique)
{
if ( colour_.empty() ) {
technique.colours(colour_);
diff --git a/src/visualisers/MarkerShadingTechnique.h b/src/visualisers/MarkerShadingTechnique.h
index 5e111f3..e2ca532 100644
--- a/src/visualisers/MarkerShadingTechnique.h
+++ b/src/visualisers/MarkerShadingTechnique.h
@@ -57,7 +57,7 @@ public:
Symbol* operator()(double);
virtual void operator()(const PaperPoint&);
//virtual void operator()(MatrixHandler&, BasicGraphicsObjectContainer&);
- virtual bool prepare(const LevelSelection&, const ColourTechnique&);
+ virtual bool prepare(LevelSelection&, const ColourTechnique&);
virtual void visit(LegendVisitor&, const ColourTechnique&);
bool hasLegend() { return true; } // Isolien legend is not needed!
CellArray* array(MatrixHandler& matrix, IntervalMap<int>& range,
diff --git a/src/visualisers/PolyShadingMethod.cc b/src/visualisers/PolyShadingMethod.cc
index 0f5591a..3c3fa0f 100644
--- a/src/visualisers/PolyShadingMethod.cc
+++ b/src/visualisers/PolyShadingMethod.cc
@@ -1,22 +1,22 @@
/*
* (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
+ * 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.
*/
/*! \file PolyShadingMethod.h
\brief Definition of the Template class PolyShadingMethod.
-
+
Magics Team - ECMWF 2004
-
+
Started: Wed 18-Aug-2004
-
+
Changes:cc
-
+
*/
@@ -29,27 +29,28 @@ using namespace magics;
-
-
void PolyShadingMethod::operator()(Polyline& poly) const
- {
-
+{
int index = poly.index();
- if (index < 0 )
+ if (index < 0 )
return;
- poly.setFilled(true);
- poly.setStroke(false);
poly.setFilled(true);
- if ( index >= colours_.size() )
- poly.setFillColour(colours_.back());
- else
- poly.setFillColour(colours_[index]);
- FillShadingProperties* shading = new FillShadingProperties();
+ poly.setStroke(true);
+ poly.setFilled(true);
+ if ( index >= colours_.size() ){
+ poly.setColour(colours_.back());
+ poly.setFillColour(colours_.back());
+ }
+ else{
+ poly.setColour(colours_[index]);
+ poly.setFillColour(colours_[index]);
+ }
+ FillShadingProperties* shading = new FillShadingProperties();
poly.setShading(shading);
- };
-
+};
+
void PolyShadingMethod::visit(LegendVisitor& legend, const ColourTechnique& colour) {
-
+
MagLog::dev() << "Create legend information" << "\n";
LegendEntryBuilder helper(legend, colour);
std::adjacent_find(colour.begin(), colour.end(), LegendEntryBuilder(legend, this, colour));
@@ -57,13 +58,10 @@ void PolyShadingMethod::visit(LegendVisitor& legend, const ColourTechnique& col
helper(*colour.begin(), *colour.begin());
}
legend.last(); // Flag the last entry as being the last! To get a nice labelling in countinuous mode!!!
-
- }
+}
int PolyShadingMethod::index(double value)
{
-
-
if ( same(value, last_) )
return indexes_.size() -1;
return indexes_.find(value, -1);
@@ -83,22 +81,18 @@ int PolyShadingMethod::leftIndex(double value)
if ( same(value, last_) ) return indexes_.size() -1;
int index = indexes_.find(value, -1);
return ( index == -1 ) ? - 1 : index -1;
-
}
-void PolyShadingMethod::prepare(const LevelSelection& levels, const ColourTechnique& colours)
-{
+void PolyShadingMethod::prepare(LevelSelection& levels, const ColourTechnique& colours)
+{
if (levels.empty() )return;
first_ = levels.front();
last_ = levels.back();
-
LevelSelection::const_iterator from = levels.begin();
LevelSelection::const_iterator level = levels.begin();
level++;
-
-
indexes_.clear();
colours_.clear();
@@ -108,15 +102,12 @@ void PolyShadingMethod::prepare(const LevelSelection& levels, const ColourTechni
colours_.push_back(colours.right(*from));
from++;
index++;
-
-
}
-
}
-void DotPolyShadingMethod::prepare(const LevelSelection& levels, const ColourTechnique& colours)
+void DotPolyShadingMethod::prepare(LevelSelection& levels, const ColourTechnique& colours)
{
if (levels.empty() )return;
@@ -133,48 +124,41 @@ void DotPolyShadingMethod::prepare(const LevelSelection& levels, const ColourTec
colours_.clear();
dots_.clear();
for ( ; level != levels.end(); ++level) {
-
indexes_.insert(make_pair(Interval(*from, *level), index));
colours_.push_back(colours.right(*from));
dots_.push_back(density);
from++;
index++;
density+=step;
-
}
-
}
void DotPolyShadingMethod::operator()(Polyline& poly) const {
DotShadingProperties* shading = new DotShadingProperties();
-
int index = poly.index();
-
-
-
shading->size_ = size_;
shading->density_ = dots_[index];
poly.setFilled(true);
poly.setFillColour(colours_[index]);
- poly.setStroke(false);
+ poly.setStroke(false);
poly.setShading(shading);
//MagLog::dev() << "Attach DotShading Information" << *shading << "\n";
}
-void HatchPolyShadingMethod::prepare(const LevelSelection& levels, const ColourTechnique& colours) {
+void HatchPolyShadingMethod::prepare(LevelSelection& levels, const ColourTechnique& colours) {
int index = 1;
if (index_ >= 7 || index_ <0) {
MagLog::warning() << "index should be < 7--> reset to 1 "<< endl;
index_ = 1 ;
}
first_ = levels.front();
- last_ = levels.back();
+ last_ = levels.back();
LevelSelection::const_iterator from = levels.begin();
LevelSelection::const_iterator level = levels.begin();
@@ -182,7 +166,7 @@ void HatchPolyShadingMethod::prepare(const LevelSelection& levels, const ColourT
colours_.clear();
hatches_.clear();
- level++;
+ level++;
int i = 0;
for ( ; level != levels.end(); ++level) {
@@ -194,10 +178,7 @@ void HatchPolyShadingMethod::prepare(const LevelSelection& levels, const ColourT
from++;
if ( index == 7 ) index = 1;
}
-
-
-
- }
+}
void HatchPolyShadingMethod::operator()(Polyline& poly) const
{
@@ -212,7 +193,4 @@ void HatchPolyShadingMethod::operator()(Polyline& poly) const
poly.setFillColour(colours_[index]);
poly.setStroke(false);
poly.setShading(shading);
-
}
-
-
diff --git a/src/visualisers/PolyShadingMethod.h b/src/visualisers/PolyShadingMethod.h
index bb3738b..deb4faa 100644
--- a/src/visualisers/PolyShadingMethod.h
+++ b/src/visualisers/PolyShadingMethod.h
@@ -51,7 +51,7 @@ public:
virtual int index(double);
virtual int rightIndex(double);
virtual int leftIndex(double);
- virtual void prepare(const LevelSelection&, const ColourTechnique&);
+ virtual void prepare(LevelSelection&, const ColourTechnique&);
virtual void operator()(Polyline& poly) const;
diff --git a/src/visualisers/PolyShadingTechnique.h b/src/visualisers/PolyShadingTechnique.h
index 4227aab..875ca90 100644
--- a/src/visualisers/PolyShadingTechnique.h
+++ b/src/visualisers/PolyShadingTechnique.h
@@ -63,7 +63,7 @@ public:
int rightIndex(double value) { return method_->rightIndex(value); }
int leftIndex(double value) { return method_->leftIndex(value); }
- virtual bool prepare(const LevelSelection& levels, const ColourTechnique& colours) {
+ virtual bool prepare(LevelSelection& levels, const ColourTechnique& colours) {
method_->prepare(levels, colours);
// True if the shading technique needs the isolines to be calculated...
return true;
@@ -130,10 +130,10 @@ struct LegendEntryBuilder
{
LegendEntryBuilder(LegendVisitor& legend, const PolyShadingMethod* method,
const ColourTechnique& colours) :
- legend_(legend), method_(method), colours_(colours) {};
+ legend_(legend), method_(method), colours_(colours), first_(true) {};
LegendEntryBuilder(LegendVisitor& legend,
const ColourTechnique& colours) :
- legend_(legend), method_(0), colours_(colours) {};
+ legend_(legend), method_(0), colours_(colours), first_(true) {};
~LegendEntryBuilder() {};
bool operator()(const pair<double, ColourInfo>& first, const pair<double, ColourInfo>& second) {
Polyline* box = new Polyline();
@@ -149,14 +149,29 @@ struct LegendEntryBuilder
box->setFillColour(colours_.right(min));
box->setFilled(true);
box->setStroke(true);
- box->setColour(Colour("black"));
- legend_.add(new BoxEntry(min, max, box));
+ box->setColour(colours_.right(min));
+
+ LegendEntry* entry = new BoxEntry(min, max, box);
+ if ( first_ ) {
+ first_ = false;
+ entry->first();
+ }
+ for ( vector<double>::iterator val = legend_.values_list_.begin(); val != legend_.values_list_.end(); ++val){
+
+ if ( min <= *val && *val < max) {
+ string text = tostring(*val);
+ entry->userText(text, "user");
+ break;
+ }
+ }
+ legend_.add(entry);
return false;
}
LegendVisitor& legend_;
const PolyShadingMethod* method_;
const ColourTechnique& colours_;
+ bool first_;
};
} // namespace magics
diff --git a/src/visualisers/ShadingTechnique.h b/src/visualisers/ShadingTechnique.h
index fbd7314..a2d63aa 100644
--- a/src/visualisers/ShadingTechnique.h
+++ b/src/visualisers/ShadingTechnique.h
@@ -59,7 +59,7 @@ public:
virtual void operator()(Data&, BasicGraphicsObjectContainer&) {}
virtual void operator()(IsoPlot* iso, MatrixHandler& data, BasicGraphicsObjectContainer& parent);
virtual void operator()(Polyline*) const {};
- virtual bool prepare(const LevelSelection&, const ColourTechnique&) { return false; }
+ virtual bool prepare(LevelSelection&, const ColourTechnique&) { return false; }
virtual void visit(LegendVisitor&, const ColourTechnique&) {}
virtual int index(double) { return -1; }
virtual int leftIndex(double) { return -1; }
diff --git a/src/visualisers/SimplePolylineVisualiser.cc b/src/visualisers/SimplePolylineVisualiser.cc
index c04ccb8..ad87262 100644
--- a/src/visualisers/SimplePolylineVisualiser.cc
+++ b/src/visualisers/SimplePolylineVisualiser.cc
@@ -58,7 +58,7 @@ void SimplePolylineVisualiser::basic(Data& data, BasicGraphicsObjectContainer& p
if (shade_) {
colourMethod_->set(*this);
- colourMethod_->prepare(*levelSelection_);
+ colourMethod_->prepare(*levelSelection_, *levelSelection_);
}
const Transformation& transformation = parent.transformation();
diff --git a/src/visualisers/SymbolAdvancedTableMode.cc b/src/visualisers/SymbolAdvancedTableMode.cc
index 264a878..d90f322 100644
--- a/src/visualisers/SymbolAdvancedTableMode.cc
+++ b/src/visualisers/SymbolAdvancedTableMode.cc
@@ -106,7 +106,7 @@ void SymbolAdvancedTableMode::adjust(double min, double max)
}
colourMethod_->set(*this);
height_method_->set(*this);
- colourMethod_->prepare(*levels_);
+ colourMethod_->prepare(*levels_, *levels_);
height_method_->prepare(*levels_);
if ( markers_.empty() ) {
diff --git a/src/visualisers/SymbolMode.cc b/src/visualisers/SymbolMode.cc
index 65e52ce..518da12 100644
--- a/src/visualisers/SymbolMode.cc
+++ b/src/visualisers/SymbolMode.cc
@@ -278,7 +278,7 @@ void SymbolIndividualMode::visit(Data& data, LegendVisitor& legend)
if ( legend_height_ != -1)
symbol->setHeight(legend_height_);
SimpleSymbolEntry *entry = new SimpleSymbolEntry(legend_text_, symbol);
- entry->userText(legend_text_);
+ entry->userText(legend_text_, "user");
legend.add(entry);
}
diff --git a/src/visualisers/WindPlotting.cc b/src/visualisers/WindPlotting.cc
index fd09f85..283bf86 100644
--- a/src/visualisers/WindPlotting.cc
+++ b/src/visualisers/WindPlotting.cc
@@ -75,7 +75,7 @@ void WindPlotting::setAdvanced(double& min, double& max)
colourMethod_->set(*this);
levels_->calculate(min, max, false);
LevelSelection::const_iterator level = levels_->begin();
- colourMethod_->prepare(*levels_);
+ colourMethod_->prepare(*levels_, *levels_);
Colour last;
map_.clear();
while ( true) {
diff --git a/src/web/WrepJSon.cc b/src/web/WrepJSon.cc
index 8de6b87..1b5b8d4 100644
--- a/src/web/WrepJSon.cc
+++ b/src/web/WrepJSon.cc
@@ -263,6 +263,26 @@ string binding(const string& version, const string& key) {
bindings["v0"].insert(make_pair("25", "twenty_five"));
bindings["v0"].insert(make_pair("75", "seventy_five"));
bindings["v0"].insert(make_pair("50", "fifty"));
+ bindings["v0"].insert(make_pair("nord", "north"));
+ bindings["v0"].insert(make_pair("nord_one", "north_one"));
+ bindings["v0"].insert(make_pair("nord_two", "north_two"));
+ bindings["v0"].insert(make_pair("nord_three", "north_three"));
+ bindings["v0"].insert(make_pair("nord_four", "north_four"));
+ bindings["v0"].insert(make_pair("nord_five", "north_five"));
+ bindings["v0"].insert(make_pair("nord_six", "north_six"));
+ bindings["v0"].insert(make_pair("nord_east", "north_east"));
+ bindings["v0"].insert(make_pair("nord_east_one", "north_east_one"));
+ bindings["v0"].insert(make_pair("nord_east_two", "north_east_two"));
+ bindings["v0"].insert(make_pair("nord_east_three", "north_east_three"));
+ bindings["v0"].insert(make_pair("nord_east_four", "north_east_four"));
+ bindings["v0"].insert(make_pair("nord_east_five", "north_east_five"));
+ bindings["v0"].insert(make_pair("nord_west", "north_west"));
+ bindings["v0"].insert(make_pair("nord_west_one", "north_west_one"));
+ bindings["v0"].insert(make_pair("nord_west_two", "north_west_two"));
+ bindings["v0"].insert(make_pair("nord_west_three", "north_west_three"));
+ bindings["v0"].insert(make_pair("nord_west_four", "north_west_four"));
+ bindings["v0"].insert(make_pair("nord_west_five", "north_west_five"));
+ bindings["v0"].insert(make_pair("nord_west_six", "north_west_six"));
}
map<string, map<string, string> >::iterator bind = bindings.find(version);
diff --git a/test/zoom.py b/test/zoom.py
new file mode 100644
index 0000000..a370f68
--- /dev/null
+++ b/test/zoom.py
@@ -0,0 +1,62 @@
+# (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.
+
+# importing Magics module
+
+from Magics.macro import *
+
+
+# Example reference
+
+ref = 'zoom'
+
+# Setting of the output file name
+
+output = output(output_formats=['png'],
+ output_name_first_page_number='off',
+ output_name=ref)
+
+# Setting the coordinates of the geographical area
+
+europe = mmap(
+ subpage_upper_right_longitude=20.,
+ isubpage_map_projection='cylindrical',
+ subpage_map_projection='polar_stereographic',
+ subpage_lower_left_longitude=-20.,
+ subpage_lower_left_latitude=40.,
+ subpage_upper_right_latitude=60.,
+ )
+
+# Coastlines setting
+
+coast = mcoast(map_grid='on', map_grid_colour='tan',
+ map_coastline_colour='tan',
+ )
+
+# Import andthe data
+
+obs = mobs(obs_input_file_name='synop.bufr')
+
+
+
+
+title = \
+ mtext(text_lines=["<font size='1'>Observation Plotting [Synop] </font>"
+ , '',
+ ], text_justification='left', text_font_size=0.5,
+ text_colour='charcoal')
+
+
+
+# To the plot
+
+print "plot"
+plot( output, europe, obs, coast, )
+tofortran(ref, output, europe, obs, coast, )
+
+
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/magics.git
More information about the debian-science-commits
mailing list